From 8ec03fefa862f1e2d34cc9947fec6f6fe2acb677 Mon Sep 17 00:00:00 2001 From: Zakarya Date: Sat, 4 Nov 2023 13:45:37 -0700 Subject: [PATCH] The stone axe is given to the player at level 5 --- data/character/character.gd | 6 ++++++ data/character/character.tscn | 4 +--- scripts/game_data.gd | 5 +++++ 3 files changed, 12 insertions(+), 3 deletions(-) diff --git a/data/character/character.gd b/data/character/character.gd index 1f82c1c..1057416 100644 --- a/data/character/character.gd +++ b/data/character/character.gd @@ -64,6 +64,12 @@ func _process(delta): if inventory.points >= (get_total_points_for_next_level()): inventory.points -= get_total_points_for_next_level() status.level += 1 + level_up() + + +func level_up(): + if status.level in game_data.level_tools: + change_tool(game_data.level_tools[status.level]) func _input(event): if event is InputEventMouseMotion: diff --git a/data/character/character.tscn b/data/character/character.tscn index 74963b0..da631af 100644 --- a/data/character/character.tscn +++ b/data/character/character.tscn @@ -1,8 +1,7 @@ -[gd_scene load_steps=8 format=3 uid="uid://4dsm0l7s6vki"] +[gd_scene load_steps=7 format=3 uid="uid://4dsm0l7s6vki"] [ext_resource type="Texture2D" uid="uid://gfxfxkfu8uk4" path="res://textures/character/character.svg" id="1_f7cgp"] [ext_resource type="Script" path="res://data/character/character.gd" id="1_qlitf"] -[ext_resource type="Texture2D" uid="uid://b7hh5vuwdmg0v" path="res://textures/tools/stick.svg" id="3_q8qyo"] [ext_resource type="PackedScene" uid="uid://vaapoj5q16ko" path="res://data/character/hud.tscn" id="4_vgn11"] [sub_resource type="CircleShape2D" id="CircleShape2D_653al"] @@ -56,6 +55,5 @@ texture = ExtResource("1_f7cgp") [node name="tool" type="Sprite2D" parent="body_pivot/body"] z_index = -1 -texture = ExtResource("3_q8qyo") [node name="hud" parent="." instance=ExtResource("4_vgn11")] diff --git a/scripts/game_data.gd b/scripts/game_data.gd index a98cd8a..06e02ca 100644 --- a/scripts/game_data.gd +++ b/scripts/game_data.gd @@ -15,3 +15,8 @@ var tools = { "offset": Vector2(-80, -195) } } + +var level_tools = { + 1: "stick", + 5: "stone_axe" +}