diff --git a/common/inventory/assets/icons/scuba-diving-tank.svg b/common/inventory/assets/icons/scuba-diving-tank.svg new file mode 100644 index 0000000..c362303 --- /dev/null +++ b/common/inventory/assets/icons/scuba-diving-tank.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/common/inventory/assets/icons/scuba-diving-tank.svg.import b/common/inventory/assets/icons/scuba-diving-tank.svg.import new file mode 100644 index 0000000..b6f8eef --- /dev/null +++ b/common/inventory/assets/icons/scuba-diving-tank.svg.import @@ -0,0 +1,37 @@ +[remap] + +importer="texture" +type="CompressedTexture2D" +uid="uid://bo3o2qf3i20ke" +path="res://.godot/imported/scuba-diving-tank.svg-d6c94087bb8fe7a9f788baf1911a56a2.ctex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://common/inventory/assets/icons/scuba-diving-tank.svg" +dest_files=["res://.godot/imported/scuba-diving-tank.svg-d6c94087bb8fe7a9f788baf1911a56a2.ctex"] + +[params] + +compress/mode=0 +compress/high_quality=false +compress/lossy_quality=0.7 +compress/hdr_compression=1 +compress/normal_map=0 +compress/channel_pack=0 +mipmaps/generate=false +mipmaps/limit=-1 +roughness/mode=0 +roughness/src_normal="" +process/fix_alpha_border=true +process/premult_alpha=false +process/normal_map_invert_y=false +process/hdr_as_srgb=false +process/hdr_clamp_exposure=false +process/size_limit=0 +detect_3d/compress_to=1 +svg/scale=2.0 +editor/scale_with_editor_scale=false +editor/convert_colors_with_editor_theme=false diff --git a/common/inventory/assets/icons/shovel.svg b/common/inventory/assets/icons/shovel.svg new file mode 100644 index 0000000..4d9efcc --- /dev/null +++ b/common/inventory/assets/icons/shovel.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/common/inventory/assets/icons/shovel.svg.import b/common/inventory/assets/icons/shovel.svg.import new file mode 100644 index 0000000..b7761dc --- /dev/null +++ b/common/inventory/assets/icons/shovel.svg.import @@ -0,0 +1,37 @@ +[remap] + +importer="texture" +type="CompressedTexture2D" +uid="uid://bf6nw4onkhavr" +path="res://.godot/imported/shovel.svg-f17d484b3a88170abdf08077458176fb.ctex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://common/inventory/assets/icons/shovel.svg" +dest_files=["res://.godot/imported/shovel.svg-f17d484b3a88170abdf08077458176fb.ctex"] + +[params] + +compress/mode=0 +compress/high_quality=false +compress/lossy_quality=0.7 +compress/hdr_compression=1 +compress/normal_map=0 +compress/channel_pack=0 +mipmaps/generate=false +mipmaps/limit=-1 +roughness/mode=0 +roughness/src_normal="" +process/fix_alpha_border=true +process/premult_alpha=false +process/normal_map_invert_y=false +process/hdr_as_srgb=false +process/hdr_clamp_exposure=false +process/size_limit=0 +detect_3d/compress_to=1 +svg/scale=2.0 +editor/scale_with_editor_scale=false +editor/convert_colors_with_editor_theme=false diff --git a/common/inventory/resources/items/default_seed.tres b/common/inventory/resources/items/default_seed.tres new file mode 100644 index 0000000..e44f7c9 --- /dev/null +++ b/common/inventory/resources/items/default_seed.tres @@ -0,0 +1,11 @@ +[gd_resource type="Resource" script_class="SeedItem" load_steps=3 format=3 uid="uid://lrl2okkhyxmx"] + +[ext_resource type="Texture2D" uid="uid://dcgnamu7sb3ov" path="res://gui/player_info/assets/icons/bolt.svg" id="1_dy25s"] +[ext_resource type="Script" uid="uid://bypjcvlc15gsm" path="res://common/inventory/scripts/items/seed_item.gd" id="2_mgcdi"] + +[resource] +script = ExtResource("2_mgcdi") +plant_type = "" +name = "Boule" +icon = ExtResource("1_dy25s") +metadata/_custom_type_script = "uid://bypjcvlc15gsm" diff --git a/common/inventory/resources/items/shovel.tres b/common/inventory/resources/items/shovel.tres new file mode 100644 index 0000000..27e26ac --- /dev/null +++ b/common/inventory/resources/items/shovel.tres @@ -0,0 +1,11 @@ +[gd_resource type="Resource" script_class="Item" load_steps=3 format=3 uid="uid://bb8etgye1qtfx"] + +[ext_resource type="Script" uid="uid://bq7admu4ahs5r" path="res://common/inventory/scripts/item.gd" id="1_0wi27"] +[ext_resource type="Texture2D" uid="uid://bf6nw4onkhavr" path="res://common/inventory/assets/icons/shovel.svg" id="1_cxwlc"] + +[resource] +script = ExtResource("1_0wi27") +name = "Shovel" +description = "Transform plants to seeds" +icon = ExtResource("1_cxwlc") +metadata/_custom_type_script = "uid://bq7admu4ahs5r" diff --git a/common/inventory/resources/items/water_can.tres b/common/inventory/resources/items/water_can.tres new file mode 100644 index 0000000..6d48c93 --- /dev/null +++ b/common/inventory/resources/items/water_can.tres @@ -0,0 +1,11 @@ +[gd_resource type="Resource" script_class="Item" load_steps=3 format=3 uid="uid://dbja8xm7ehw1v"] + +[ext_resource type="Texture2D" uid="uid://bo3o2qf3i20ke" path="res://common/inventory/assets/icons/scuba-diving-tank.svg" id="1_sy4rh"] +[ext_resource type="Script" uid="uid://bq7admu4ahs5r" path="res://common/inventory/scripts/item.gd" id="2_aikyk"] + +[resource] +script = ExtResource("2_aikyk") +name = "Water Can" +description = "Water all plants" +icon = ExtResource("1_sy4rh") +metadata/_custom_type_script = "uid://bq7admu4ahs5r" diff --git a/common/inventory/scripts/inventory.gd b/common/inventory/scripts/inventory.gd new file mode 100644 index 0000000..8e6c567 --- /dev/null +++ b/common/inventory/scripts/inventory.gd @@ -0,0 +1,46 @@ +extends Resource +class_name Inventory + +signal inventory_changed(inventory: Inventory) + +@export var items: Array[Item] = [] +@export var max_items: int = 1 + +func add_item(item: Item): + if items.size() < max_items: + items.append(item) + emit_signal("inventory_changed", self) + return true + else: + return false + +func add_items(items_to_add: Array[Item], fillup: bool = false): + if fillup: + var has_changed := false + for i in min(items_to_add.size(), max_items - items.size()): + items.append(items_to_add[i]) + has_changed = true + if has_changed: + emit_signal("inventory_changed", self) + return has_changed + elif !fillup && items.size() + items_to_add.size() < max_items: + items.append_array(items_to_add) + emit_signal("inventory_changed", self) + return true + +func lenght() -> int: + return len(items) + +func get_item(ind: int = 0): + return items[ind] + +func pop_item(ind: int = 0): + var item_removed: Item = items.pop_at(ind) + emit_signal("inventory_changed", self) + return item_removed + +func swap_items(item_to_add: Item, ind_to_get: int = 0): + var item_to_get := items[ind_to_get] + items[ind_to_get] = item_to_add + emit_signal("inventory_changed", self) + return item_to_get diff --git a/common/inventory/scripts/inventory.gd.uid b/common/inventory/scripts/inventory.gd.uid new file mode 100644 index 0000000..1b79328 --- /dev/null +++ b/common/inventory/scripts/inventory.gd.uid @@ -0,0 +1 @@ +uid://fnu2d6wna4yc diff --git a/common/inventory/scripts/item.gd b/common/inventory/scripts/item.gd new file mode 100644 index 0000000..4f4a382 --- /dev/null +++ b/common/inventory/scripts/item.gd @@ -0,0 +1,12 @@ +extends Resource +class_name Item + +@export var name: String +@export var description: String +@export var icon: Texture2D + +func can_use() -> bool: + return false + +func use() -> bool: + return false \ No newline at end of file diff --git a/common/inventory/scripts/item.gd.uid b/common/inventory/scripts/item.gd.uid new file mode 100644 index 0000000..0ab93d5 --- /dev/null +++ b/common/inventory/scripts/item.gd.uid @@ -0,0 +1 @@ +uid://bq7admu4ahs5r diff --git a/common/inventory/scripts/items/seed_item.gd b/common/inventory/scripts/items/seed_item.gd new file mode 100644 index 0000000..bbab597 --- /dev/null +++ b/common/inventory/scripts/items/seed_item.gd @@ -0,0 +1,11 @@ +extends Item +class_name SeedItem + +@export var plant_type: PlantType + +func _init(): + if plant_type: + if plant_type.name: + name = plant_type.name + if plant_type.seed_texture: + icon = plant_type.seed_texture \ No newline at end of file diff --git a/common/inventory/scripts/items/seed_item.gd.uid b/common/inventory/scripts/items/seed_item.gd.uid new file mode 100644 index 0000000..99fddb0 --- /dev/null +++ b/common/inventory/scripts/items/seed_item.gd.uid @@ -0,0 +1 @@ +uid://bypjcvlc15gsm diff --git a/entities/interactables/item_object/assets/sprites/shadow.svg b/entities/interactables/item_object/assets/sprites/shadow.svg new file mode 100644 index 0000000..d3dbc3a --- /dev/null +++ b/entities/interactables/item_object/assets/sprites/shadow.svg @@ -0,0 +1,52 @@ + + + + + + + diff --git a/entities/interactables/item_object/assets/sprites/shadow.svg.import b/entities/interactables/item_object/assets/sprites/shadow.svg.import new file mode 100644 index 0000000..667d421 --- /dev/null +++ b/entities/interactables/item_object/assets/sprites/shadow.svg.import @@ -0,0 +1,37 @@ +[remap] + +importer="texture" +type="CompressedTexture2D" +uid="uid://c1eiu5ag7lcp8" +path="res://.godot/imported/shadow.svg-3484c898461c709704cdbeef0cc1d3c3.ctex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://entities/interactables/item_object/assets/sprites/shadow.svg" +dest_files=["res://.godot/imported/shadow.svg-3484c898461c709704cdbeef0cc1d3c3.ctex"] + +[params] + +compress/mode=0 +compress/high_quality=false +compress/lossy_quality=0.7 +compress/hdr_compression=1 +compress/normal_map=0 +compress/channel_pack=0 +mipmaps/generate=false +mipmaps/limit=-1 +roughness/mode=0 +roughness/src_normal="" +process/fix_alpha_border=true +process/premult_alpha=false +process/normal_map_invert_y=false +process/hdr_as_srgb=false +process/hdr_clamp_exposure=false +process/size_limit=0 +detect_3d/compress_to=1 +svg/scale=2.0 +editor/scale_with_editor_scale=false +editor/convert_colors_with_editor_theme=false diff --git a/entities/interactables/item_object/item_object.tscn b/entities/interactables/item_object/item_object.tscn new file mode 100644 index 0000000..e6f4d3a --- /dev/null +++ b/entities/interactables/item_object/item_object.tscn @@ -0,0 +1,6 @@ +[gd_scene load_steps=2 format=3 uid="uid://cd3re3552pt7m"] + +[ext_resource type="Script" uid="uid://dedg615xudpoq" path="res://entities/interactables/item_object/script/item_object.gd" id="1_hxea8"] + +[node name="ItemObject" type="Area2D"] +script = ExtResource("1_hxea8") diff --git a/entities/interactables/item_object/item_object_sprite.tscn b/entities/interactables/item_object/item_object_sprite.tscn new file mode 100644 index 0000000..680d3c7 --- /dev/null +++ b/entities/interactables/item_object/item_object_sprite.tscn @@ -0,0 +1,106 @@ +[gd_scene load_steps=6 format=3 uid="uid://bcj812ox8xv2t"] + +[ext_resource type="Texture2D" uid="uid://bf6nw4onkhavr" path="res://common/inventory/assets/icons/shovel.svg" id="1_7u8ru"] +[ext_resource type="Texture2D" uid="uid://c1eiu5ag7lcp8" path="res://entities/interactables/item_object/assets/sprites/shadow.svg" id="2_ng201"] + +[sub_resource type="Animation" id="Animation_ng201"] +resource_name = "default" +length = 2.0 +loop_mode = 1 +tracks/0/type = "value" +tracks/0/imported = false +tracks/0/enabled = true +tracks/0/path = NodePath(".:position") +tracks/0/interp = 2 +tracks/0/loop_wrap = true +tracks/0/keys = { +"times": PackedFloat32Array(0, 1, 2), +"transitions": PackedFloat32Array(1, 1, 1), +"update": 0, +"values": [Vector2(0, 0), Vector2(0, -5), Vector2(0, 0)] +} +tracks/1/type = "value" +tracks/1/imported = false +tracks/1/enabled = true +tracks/1/path = NodePath("Shadow:position") +tracks/1/interp = 2 +tracks/1/loop_wrap = true +tracks/1/keys = { +"times": PackedFloat32Array(0, 1, 2), +"transitions": PackedFloat32Array(1, 1, 1), +"update": 0, +"values": [Vector2(0, 23), Vector2(0, 28), Vector2(0, 23)] +} +tracks/2/type = "value" +tracks/2/imported = false +tracks/2/enabled = true +tracks/2/path = NodePath("Shadow:scale") +tracks/2/interp = 2 +tracks/2/loop_wrap = true +tracks/2/keys = { +"times": PackedFloat32Array(0, 1, 2), +"transitions": PackedFloat32Array(1, 1, 1), +"update": 0, +"values": [Vector2(0.875, 0.875), Vector2(0.7, 0.7), Vector2(0.875, 0.875)] +} + +[sub_resource type="Animation" id="Animation_wing4"] +length = 0.001 +tracks/0/type = "value" +tracks/0/imported = false +tracks/0/enabled = true +tracks/0/path = NodePath(".:position") +tracks/0/interp = 1 +tracks/0/loop_wrap = true +tracks/0/keys = { +"times": PackedFloat32Array(0), +"transitions": PackedFloat32Array(1), +"update": 0, +"values": [Vector2(0, 0)] +} +tracks/1/type = "value" +tracks/1/imported = false +tracks/1/enabled = true +tracks/1/path = NodePath("Shadow:position") +tracks/1/interp = 1 +tracks/1/loop_wrap = true +tracks/1/keys = { +"times": PackedFloat32Array(0), +"transitions": PackedFloat32Array(1), +"update": 0, +"values": [Vector2(0, 23)] +} +tracks/2/type = "value" +tracks/2/imported = false +tracks/2/enabled = true +tracks/2/path = NodePath("Shadow:scale") +tracks/2/interp = 1 +tracks/2/loop_wrap = true +tracks/2/keys = { +"times": PackedFloat32Array(0), +"transitions": PackedFloat32Array(1), +"update": 0, +"values": [Vector2(0.875, 0.875)] +} + +[sub_resource type="AnimationLibrary" id="AnimationLibrary_ng3e4"] +_data = { +&"RESET": SubResource("Animation_wing4"), +&"default": SubResource("Animation_ng201") +} + +[node name="ItemObjectSprite" type="Sprite2D"] +texture = ExtResource("1_7u8ru") + +[node name="Shadow" type="Sprite2D" parent="."] +modulate = Color(1, 1, 1, 0.227451) +z_index = -1 +position = Vector2(0, 23) +scale = Vector2(0.875, 0.875) +texture = ExtResource("2_ng201") + +[node name="AnimationPlayer" type="AnimationPlayer" parent="."] +libraries = { +&"": SubResource("AnimationLibrary_ng3e4") +} +autoplay = "default" diff --git a/entities/interactables/item_object/script/item_object.gd b/entities/interactables/item_object/script/item_object.gd new file mode 100644 index 0000000..dd75a67 --- /dev/null +++ b/entities/interactables/item_object/script/item_object.gd @@ -0,0 +1,48 @@ +extends Interactable +class_name ItemObject + +const ITEM_AREA_WIDTH = 10 +const SPRITE_SCENE : PackedScene = preload("res://entities/interactables/item_object/item_object_sprite.tscn") + +@export var item : Item : + set(_item): + item = _item + if sprite: + sprite.texture = item.icon + +@onready var sprite : Sprite2D = generate_sprite() + +func _init(_item = null): + if _item: + item = _item + +func _ready(): + generate_collision(10) + +func interact(player : Player) -> bool: + if player.inventory.lenght() < player.inventory.max_items: + player.inventory.add_item(item) + pickup_animation(player) + else : + var swaped_item = player.inventory.swap_items(item) + item = swaped_item + + return true + +func pickup_animation(player : Player): + available = false + var tween : Tween = get_tree().create_tween() + + tween.tween_property(self, "position", player.position, 0.2) + tween.tween_callback( + func(): + queue_free() + ) + +func generate_sprite() -> Sprite2D: + var s = SPRITE_SCENE.instantiate() as Sprite2D + add_child(s) + + s.texture = item.icon + + return s diff --git a/entities/interactables/item_object/script/item_object.gd.uid b/entities/interactables/item_object/script/item_object.gd.uid new file mode 100644 index 0000000..0d095a2 --- /dev/null +++ b/entities/interactables/item_object/script/item_object.gd.uid @@ -0,0 +1 @@ +uid://dedg615xudpoq diff --git a/entities/interactables/resources/actions/default_water_plant.tres b/entities/interactables/resources/actions/default_water_plant.tres deleted file mode 100644 index d43f2b3..0000000 --- a/entities/interactables/resources/actions/default_water_plant.tres +++ /dev/null @@ -1,7 +0,0 @@ -[gd_resource type="Resource" script_class="WaterPlantAction" load_steps=2 format=3 uid="uid://bk0kop0m75pjy"] - -[ext_resource type="Script" uid="uid://bb38yqsd072ws" path="res://entities/interactables/scripts/actions/water_plant.gd" id="1_ghdb0"] - -[resource] -script = ExtResource("1_ghdb0") -metadata/_custom_type_script = "uid://bb38yqsd072ws" diff --git a/entities/interactables/scripts/actions/water_plant.gd b/entities/interactables/scripts/actions/water_plant.gd deleted file mode 100644 index 2e9ec71..0000000 --- a/entities/interactables/scripts/actions/water_plant.gd +++ /dev/null @@ -1,8 +0,0 @@ -extends InteractableAction -class_name WaterPlantAction - -func action(_p: Player, _i : Interactable): - if _i is Plant: - _i.watered = true - else : - printerr("No plant selected or interactable is not a plant") \ No newline at end of file diff --git a/entities/interactables/scripts/actions/water_plant.gd.uid b/entities/interactables/scripts/actions/water_plant.gd.uid deleted file mode 100644 index a175c78..0000000 --- a/entities/interactables/scripts/actions/water_plant.gd.uid +++ /dev/null @@ -1 +0,0 @@ -uid://bb38yqsd072ws diff --git a/entities/interactables/scripts/interactable.gd b/entities/interactables/scripts/interactable.gd index 16c0091..03e4c7b 100644 --- a/entities/interactables/scripts/interactable.gd +++ b/entities/interactables/scripts/interactable.gd @@ -1,8 +1,19 @@ extends Area2D class_name Interactable -@export var actions : Array[InteractableAction] = []; +var available : bool = true -func interact(p : Player): - for a in actions: - a.action(p, self) \ No newline at end of file +func _ready(): + printerr("Abstract Interactable class used") + +func interact(_p : Player) -> bool: + printerr("Interact function called on abstract Interactable class") + return false + +func generate_collision(area_width : float): + var collision = CollisionShape2D.new() + var collision_shape = CircleShape2D.new() + collision_shape.radius = area_width + + collision.shape = collision_shape + add_child(collision) \ No newline at end of file diff --git a/entities/interactables/scripts/interactable_action.gd b/entities/interactables/scripts/interactable_action.gd deleted file mode 100644 index 346aa63..0000000 --- a/entities/interactables/scripts/interactable_action.gd +++ /dev/null @@ -1,6 +0,0 @@ -# Classe abstraite permettant de développer diverses actions -extends Resource -class_name InteractableAction - -func action(_p: Player, _i : Interactable): - printerr("Méthode action de la classe abstraite InteractableAction appelée") \ No newline at end of file diff --git a/entities/interactables/scripts/interactable_action.gd.uid b/entities/interactables/scripts/interactable_action.gd.uid deleted file mode 100644 index 7ef9a22..0000000 --- a/entities/interactables/scripts/interactable_action.gd.uid +++ /dev/null @@ -1 +0,0 @@ -uid://yutflvdgdk04 diff --git a/entities/plants/default_plant.tscn b/entities/plants/default_plant.tscn deleted file mode 100644 index cff90d7..0000000 --- a/entities/plants/default_plant.tscn +++ /dev/null @@ -1,37 +0,0 @@ -[gd_scene load_steps=6 format=3 uid="uid://clpcqkdlj3d8e"] - -[ext_resource type="Script" uid="uid://cega715smavh3" path="res://entities/plants/scripts/plant.gd" id="1_d8u7e"] -[ext_resource type="Texture2D" uid="uid://c6vby5r0pfni2" path="res://entities/plants/assets/sprites/default_plant.png" id="4_dq24f"] -[ext_resource type="Texture2D" uid="uid://b3wom2xu26g43" path="res://entities/plants/assets/sprites/default_plant_glowing.png" id="5_2gcie"] - -[sub_resource type="CircleShape2D" id="CircleShape2D_cdbrd"] - -[sub_resource type="SpriteFrames" id="SpriteFrames_ocwgi"] -animations = [{ -"frames": [{ -"duration": 1.0, -"texture": ExtResource("4_dq24f") -}], -"loop": true, -"name": &"default", -"speed": 5.0 -}, { -"frames": [{ -"duration": 1.0, -"texture": ExtResource("5_2gcie") -}], -"loop": true, -"name": &"watered", -"speed": 5.0 -}] - -[node name="DefaultPlant" type="Area2D"] -script = ExtResource("1_d8u7e") - -[node name="CollisionShape2D" type="CollisionShape2D" parent="."] -scale = Vector2(4.01154, 4.01154) -shape = SubResource("CircleShape2D_cdbrd") - -[node name="AnimatedSprite2D" type="AnimatedSprite2D" parent="."] -scale = Vector2(0.160462, 0.160462) -sprite_frames = SubResource("SpriteFrames_ocwgi") diff --git a/entities/plants/scripts/plant_type.gd b/entities/plants/scripts/plant_type.gd index a6cd5f9..1b232e5 100644 --- a/entities/plants/scripts/plant_type.gd +++ b/entities/plants/scripts/plant_type.gd @@ -1,6 +1,8 @@ extends Resource class_name PlantType +@export var name : String + @export var growing_time : int @export var seed_texture : Texture diff --git a/entities/player/player.tscn b/entities/player/player.tscn index 666aaa8..65e6a31 100644 --- a/entities/player/player.tscn +++ b/entities/player/player.tscn @@ -13,16 +13,16 @@ radius = 40.0 script = ExtResource("1_abrql") [node name="Sprite" type="Sprite2D" parent="."] -position = Vector2(2, -20) +position = Vector2(2, -55) scale = Vector2(0.084375, 0.084375) texture = ExtResource("1_symyc") [node name="CollisionShape2D" type="CollisionShape2D" parent="."] -position = Vector2(-2, 15) +position = Vector2(-2, -20) shape = SubResource("CircleShape2D_sglur") [node name="InteractArea2D" type="Area2D" parent="."] -position = Vector2(0, 21) +position = Vector2(0, -14) [node name="CollisionShape2D" type="CollisionShape2D" parent="InteractArea2D"] shape = SubResource("CircleShape2D_abrql") diff --git a/entities/player/scripts/player.gd b/entities/player/scripts/player.gd index f8ebf89..8e81655 100644 --- a/entities/player/scripts/player.gd +++ b/entities/player/scripts/player.gd @@ -1,23 +1,39 @@ extends CharacterBody2D class_name Player -signal player_stats_updated(player : Player) +signal player_updated(player: Player) -var controlling_player : bool = true var planet : Planet # mis à jour par la classe Planet @export var speed = 400 @export var testPlantType : PlantType +@onready var inventory : Inventory = Inventory.new() + var max_energy : int = 10 +var controlling_player : bool = true : + set(v): + controlling_player = v + velocity = Vector2.ZERO + +var closest_interactable : Interactable = null : + set(v): + var old = closest_interactable + closest_interactable = v + if old != closest_interactable: + player_updated.emit(self) var energy : int = max_energy : set(v): energy = v - emit_signal("player_stats_updated", self) + emit_signal("player_updated", self) func _ready(): - emit_signal("player_stats_updated", self) + emit_signal("player_updated", self) + inventory.inventory_changed.connect(_on_inventory_updated) + +func _on_inventory_updated(_inventory: Inventory): + emit_signal("player_updated", self) func get_input(): if controlling_player: @@ -25,9 +41,14 @@ func get_input(): if Input.is_action_just_pressed("action") and energy > 0: action() + if Input.is_action_just_pressed("interact") and closest_interactable: + closest_interactable.interact(self) + if Input.is_action_just_pressed("drop") and inventory.lenght() > 0: + var item_to_drop = inventory.pop_item() + planet.drop_item(item_to_drop, global_position) func calculate_direction(): - var input_direction : Vector2 = Input.get_vector("move_left", "move_right", "move_up", "move_down") + var input_direction: Vector2 = Input.get_vector("move_left", "move_right", "move_up", "move_down") velocity = input_direction * speed if input_direction.x: $Sprite.flip_h = (input_direction.x < 0) @@ -42,9 +63,26 @@ func action(): func pass_day(): energy = max_energy -func _physics_process(_delta): +func detect_closest_interactable(): + var in_range_interactables : Array[Interactable] = [] + for area in $InteractArea2D.get_overlapping_areas(): + if area is Interactable and area.available: + in_range_interactables.append(area) + + in_range_interactables.sort_custom( + func(a : Node2D, b : Node2D) : + return a.global_position.distance_to(global_position) > b.global_position.distance_to(global_position) + ) + + if len(in_range_interactables) > 0: + closest_interactable = in_range_interactables[0] + else : + closest_interactable = null + +func _process(_delta): get_input() move_and_slide() + detect_closest_interactable() func _on_root_gui_day_pass_pressed(): controlling_player = false diff --git a/gui/assets/texture/Tablette info.png b/gui/assets/texture/Tablette info.png new file mode 100644 index 0000000..34cdd75 Binary files /dev/null and b/gui/assets/texture/Tablette info.png differ diff --git a/gui/assets/texture/Tablette info.png.import b/gui/assets/texture/Tablette info.png.import new file mode 100644 index 0000000..86b4c43 --- /dev/null +++ b/gui/assets/texture/Tablette info.png.import @@ -0,0 +1,34 @@ +[remap] + +importer="texture" +type="CompressedTexture2D" +uid="uid://c2pgaklnj5w3d" +path="res://.godot/imported/Tablette info.png-0d02a3ea4c574d196b3e778477072d61.ctex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://gui/assets/texture/Tablette info.png" +dest_files=["res://.godot/imported/Tablette info.png-0d02a3ea4c574d196b3e778477072d61.ctex"] + +[params] + +compress/mode=0 +compress/high_quality=false +compress/lossy_quality=0.7 +compress/hdr_compression=1 +compress/normal_map=0 +compress/channel_pack=0 +mipmaps/generate=false +mipmaps/limit=-1 +roughness/mode=0 +roughness/src_normal="" +process/fix_alpha_border=true +process/premult_alpha=false +process/normal_map_invert_y=false +process/hdr_as_srgb=false +process/hdr_clamp_exposure=false +process/size_limit=0 +detect_3d/compress_to=1 diff --git a/gui/player_info/player_info.tscn b/gui/player_info/player_info.tscn index 2a22b63..935a4b7 100644 --- a/gui/player_info/player_info.tscn +++ b/gui/player_info/player_info.tscn @@ -58,3 +58,11 @@ text = "0" label_settings = ExtResource("5_s4ggy") horizontal_alignment = 1 vertical_alignment = 1 + +[node name="Inventory" type="HBoxContainer" parent="."] +layout_mode = 0 +offset_left = 157.0 +offset_top = 86.0 +offset_right = 291.0 +offset_bottom = 126.0 +alignment = 1 diff --git a/gui/player_info/scripts/player_info.gd b/gui/player_info/scripts/player_info.gd index d2a45eb..fff21d3 100644 --- a/gui/player_info/scripts/player_info.gd +++ b/gui/player_info/scripts/player_info.gd @@ -1,4 +1,4 @@ extends Control -func _on_root_gui_player_stats_updated(player:Player): +func player_update(player: Player): $EnergyInfo/Label.text = str(player.energy) diff --git a/gui/ressources/Tablette info.png b/gui/ressources/Tablette info.png new file mode 100644 index 0000000..34cdd75 Binary files /dev/null and b/gui/ressources/Tablette info.png differ diff --git a/gui/ressources/Tablette info.png.import b/gui/ressources/Tablette info.png.import new file mode 100644 index 0000000..c2c6341 --- /dev/null +++ b/gui/ressources/Tablette info.png.import @@ -0,0 +1,34 @@ +[remap] + +importer="texture" +type="CompressedTexture2D" +uid="uid://qx75h1k3wmm1" +path="res://.godot/imported/Tablette info.png-e89cd3fdb4a303341f3bbad730de279c.ctex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://gui/ressources/Tablette info.png" +dest_files=["res://.godot/imported/Tablette info.png-e89cd3fdb4a303341f3bbad730de279c.ctex"] + +[params] + +compress/mode=0 +compress/high_quality=false +compress/lossy_quality=0.7 +compress/hdr_compression=1 +compress/normal_map=0 +compress/channel_pack=0 +mipmaps/generate=false +mipmaps/limit=-1 +roughness/mode=0 +roughness/src_normal="" +process/fix_alpha_border=true +process/premult_alpha=false +process/normal_map_invert_y=false +process/hdr_as_srgb=false +process/hdr_clamp_exposure=false +process/size_limit=0 +detect_3d/compress_to=1 diff --git a/gui/ressources/default_label_settings.tres b/gui/ressources/default_label_settings.tres index a08c886..37bbcd6 100644 --- a/gui/ressources/default_label_settings.tres +++ b/gui/ressources/default_label_settings.tres @@ -1,6 +1,6 @@ [gd_resource type="LabelSettings" load_steps=2 format=3 uid="uid://dqwayi8yjwau2"] -[ext_resource type="FontFile" uid="uid://byyfovm1ha5ya" path="res://gui/ressources/fonts/AtomicMd-3zXDZ.ttf" id="1_w0wva"] +[ext_resource type="FontFile" uid="uid://cpnsnrqhfkj3k" path="res://gui/ressources/fonts/spincycle_ot.otf" id="1_w0wva"] [resource] font = ExtResource("1_w0wva") diff --git a/gui/ressources/default_theme.tres b/gui/ressources/default_theme.tres index 249889a..c260647 100644 --- a/gui/ressources/default_theme.tres +++ b/gui/ressources/default_theme.tres @@ -1,6 +1,6 @@ [gd_resource type="Theme" load_steps=5 format=3 uid="uid://bgcmd213j6gk1"] -[ext_resource type="FontFile" uid="uid://byyfovm1ha5ya" path="res://gui/ressources/fonts/AtomicMd-3zXDZ.ttf" id="1_hv6r3"] +[ext_resource type="FontFile" uid="uid://cpnsnrqhfkj3k" path="res://gui/ressources/fonts/spincycle_ot.otf" id="1_hv6r3"] [sub_resource type="StyleBoxFlat" id="StyleBoxFlat_hv6r3"] bg_color = Color(0.976471, 0.741176, 0.4, 1) @@ -44,7 +44,8 @@ Button/fonts/font = ExtResource("1_hv6r3") Button/styles/hover = SubResource("StyleBoxFlat_hv6r3") Button/styles/normal = SubResource("StyleBoxFlat_y48f0") Button/styles/pressed = SubResource("StyleBoxFlat_st1o2") -MarginContainer/constants/margin_bottom = 10 -MarginContainer/constants/margin_left = 10 -MarginContainer/constants/margin_right = 10 -MarginContainer/constants/margin_top = 10 +HBoxContainer/constants/separation = 15 +MarginContainer/constants/margin_bottom = 15 +MarginContainer/constants/margin_left = 15 +MarginContainer/constants/margin_right = 15 +MarginContainer/constants/margin_top = 15 diff --git a/gui/ressources/fonts/spincycle_3d_ot.otf b/gui/ressources/fonts/spincycle_3d_ot.otf new file mode 100644 index 0000000..8a5514b Binary files /dev/null and b/gui/ressources/fonts/spincycle_3d_ot.otf differ diff --git a/gui/ressources/fonts/spincycle_3d_ot.otf.import b/gui/ressources/fonts/spincycle_3d_ot.otf.import new file mode 100644 index 0000000..d3f3376 --- /dev/null +++ b/gui/ressources/fonts/spincycle_3d_ot.otf.import @@ -0,0 +1,35 @@ +[remap] + +importer="font_data_dynamic" +type="FontFile" +uid="uid://c8xf3tfnpufk3" +path="res://.godot/imported/spincycle_3d_ot.otf-f71d33fbaded9da2ba85d0eb20bfd1e1.fontdata" + +[deps] + +source_file="res://gui/ressources/fonts/spincycle_3d_ot.otf" +dest_files=["res://.godot/imported/spincycle_3d_ot.otf-f71d33fbaded9da2ba85d0eb20bfd1e1.fontdata"] + +[params] + +Rendering=null +antialiasing=1 +generate_mipmaps=false +disable_embedded_bitmaps=true +multichannel_signed_distance_field=false +msdf_pixel_range=8 +msdf_size=48 +allow_system_fallback=true +force_autohinter=false +hinting=1 +subpixel_positioning=4 +keep_rounding_remainders=true +oversampling=0.0 +Fallbacks=null +fallbacks=[] +Compress=null +compress=true +preload=[] +language_support={} +script_support={} +opentype_features={} diff --git a/gui/ressources/fonts/spincycle_ot.otf b/gui/ressources/fonts/spincycle_ot.otf new file mode 100644 index 0000000..eb546fb Binary files /dev/null and b/gui/ressources/fonts/spincycle_ot.otf differ diff --git a/gui/ressources/fonts/spincycle_ot.otf.import b/gui/ressources/fonts/spincycle_ot.otf.import new file mode 100644 index 0000000..d2d6484 --- /dev/null +++ b/gui/ressources/fonts/spincycle_ot.otf.import @@ -0,0 +1,35 @@ +[remap] + +importer="font_data_dynamic" +type="FontFile" +uid="uid://cpnsnrqhfkj3k" +path="res://.godot/imported/spincycle_ot.otf-be21809daa8fde21c00f1cf664ce2342.fontdata" + +[deps] + +source_file="res://gui/ressources/fonts/spincycle_ot.otf" +dest_files=["res://.godot/imported/spincycle_ot.otf-be21809daa8fde21c00f1cf664ce2342.fontdata"] + +[params] + +Rendering=null +antialiasing=1 +generate_mipmaps=false +disable_embedded_bitmaps=true +multichannel_signed_distance_field=false +msdf_pixel_range=8 +msdf_size=48 +allow_system_fallback=true +force_autohinter=false +hinting=1 +subpixel_positioning=4 +keep_rounding_remainders=true +oversampling=0.0 +Fallbacks=null +fallbacks=[] +Compress=null +compress=true +preload=[] +language_support={} +script_support={} +opentype_features={} diff --git a/gui/root_gui.tscn b/gui/root_gui.tscn index af2e67a..6002303 100644 --- a/gui/root_gui.tscn +++ b/gui/root_gui.tscn @@ -1,25 +1,17 @@ -[gd_scene load_steps=10 format=3 uid="uid://12nak7amd1uq"] +[gd_scene load_steps=14 format=3 uid="uid://12nak7amd1uq"] [ext_resource type="PackedScene" uid="uid://baqrmhsgqda6v" path="res://gui/player_info/player_info.tscn" id="1_8kw6x"] [ext_resource type="Script" uid="uid://cqao7n800qy40" path="res://gui/scripts/root_gui.gd" id="1_udau0"] [ext_resource type="Theme" uid="uid://bgcmd213j6gk1" path="res://gui/ressources/default_theme.tres" id="2_nq5i2"] [ext_resource type="Texture2D" uid="uid://dcgnamu7sb3ov" path="res://gui/player_info/assets/icons/bolt.svg" id="4_k4juk"] [ext_resource type="LabelSettings" uid="uid://dqwayi8yjwau2" path="res://gui/ressources/default_label_settings.tres" id="4_ujg5r"] +[ext_resource type="Texture2D" uid="uid://c2pgaklnj5w3d" path="res://gui/assets/texture/Tablette info.png" id="6_fovlv"] +[ext_resource type="Texture2D" uid="uid://bf6nw4onkhavr" path="res://common/inventory/assets/icons/shovel.svg" id="7_n4kem"] +[ext_resource type="FontFile" uid="uid://cpnsnrqhfkj3k" path="res://gui/ressources/fonts/spincycle_ot.otf" id="8_n4kem"] -[sub_resource type="Animation" id="Animation_k4juk"] -resource_name = "recharge_fade_in" -tracks/0/type = "value" -tracks/0/imported = false -tracks/0/enabled = true -tracks/0/path = NodePath("RechargeFade:color") -tracks/0/interp = 1 -tracks/0/loop_wrap = true -tracks/0/keys = { -"times": PackedFloat32Array(0, 1), -"transitions": PackedFloat32Array(1, 1), -"update": 0, -"values": [Color(0, 0, 0, 0), Color(0, 0, 0, 1)] -} +[sub_resource type="LabelSettings" id="LabelSettings_ek73b"] +font = ExtResource("8_n4kem") +font_size = 20 [sub_resource type="Animation" id="Animation_iyvkh"] length = 0.001 @@ -35,6 +27,45 @@ tracks/0/keys = { "update": 0, "values": [Color(0, 0, 0, 0)] } +tracks/1/type = "value" +tracks/1/imported = false +tracks/1/enabled = true +tracks/1/path = NodePath("RechargeFade:visible") +tracks/1/interp = 1 +tracks/1/loop_wrap = true +tracks/1/keys = { +"times": PackedFloat32Array(0), +"transitions": PackedFloat32Array(1), +"update": 1, +"values": [false] +} + +[sub_resource type="Animation" id="Animation_k4juk"] +resource_name = "recharge_fade_in" +tracks/0/type = "value" +tracks/0/imported = false +tracks/0/enabled = true +tracks/0/path = NodePath("RechargeFade:color") +tracks/0/interp = 1 +tracks/0/loop_wrap = true +tracks/0/keys = { +"times": PackedFloat32Array(0, 1), +"transitions": PackedFloat32Array(1, 1), +"update": 0, +"values": [Color(0, 0, 0, 0), Color(0, 0, 0, 1)] +} +tracks/1/type = "value" +tracks/1/imported = false +tracks/1/enabled = true +tracks/1/path = NodePath("RechargeFade:visible") +tracks/1/interp = 1 +tracks/1/loop_wrap = true +tracks/1/keys = { +"times": PackedFloat32Array(0), +"transitions": PackedFloat32Array(1), +"update": 1, +"values": [true] +} [sub_resource type="Animation" id="Animation_fovlv"] resource_name = "recharge_fade_out" @@ -50,6 +81,18 @@ tracks/0/keys = { "update": 0, "values": [Color(0, 0, 0, 1), Color(0, 0, 0, 0)] } +tracks/1/type = "value" +tracks/1/imported = false +tracks/1/enabled = true +tracks/1/path = NodePath("RechargeFade:visible") +tracks/1/interp = 1 +tracks/1/loop_wrap = true +tracks/1/keys = { +"times": PackedFloat32Array(1), +"transitions": PackedFloat32Array(1), +"update": 1, +"values": [false] +} [sub_resource type="AnimationLibrary" id="AnimationLibrary_n4kem"] _data = { @@ -106,15 +149,95 @@ size_flags_horizontal = 8 size_flags_vertical = 0 label_settings = ExtResource("4_ujg5r") -[node name="RechargeFade" type="ColorRect" parent="."] -physics_interpolation_mode = 0 +[node name="ItemInfo" type="TextureRect" parent="MarginContainer"] +unique_name_in_owner = true +custom_minimum_size = Vector2(0, 300) +layout_mode = 2 +size_flags_horizontal = 0 +size_flags_vertical = 8 +theme = ExtResource("2_nq5i2") +texture = ExtResource("6_fovlv") +expand_mode = 3 +stretch_mode = 4 + +[node name="MarginContainer" type="MarginContainer" parent="MarginContainer/ItemInfo"] +layout_mode = 1 +anchors_preset = 15 +anchor_right = 1.0 +anchor_bottom = 1.0 +grow_horizontal = 2 +grow_vertical = 2 +theme_override_constants/margin_left = 35 +theme_override_constants/margin_top = 35 +theme_override_constants/margin_right = 20 +theme_override_constants/margin_bottom = 75 + +[node name="VBoxContainer" type="VBoxContainer" parent="MarginContainer/ItemInfo/MarginContainer"] +layout_mode = 2 +theme = ExtResource("2_nq5i2") + +[node name="ItemIcon" type="TextureRect" parent="MarginContainer/ItemInfo/MarginContainer/VBoxContainer"] +unique_name_in_owner = true +custom_minimum_size = Vector2(0, 50) +layout_mode = 2 +texture = ExtResource("7_n4kem") +stretch_mode = 3 + +[node name="ItemName" type="Label" parent="MarginContainer/ItemInfo/MarginContainer/VBoxContainer"] +unique_name_in_owner = true +layout_mode = 2 +text = "fdqsd" +label_settings = SubResource("LabelSettings_ek73b") +horizontal_alignment = 1 + +[node name="ItemDesc" type="Label" parent="MarginContainer/ItemInfo/MarginContainer/VBoxContainer"] +unique_name_in_owner = true +layout_mode = 2 +size_flags_vertical = 3 +text = "Ceci est une pelle qui sert exclusivement à faire des choses intéressantes. Ceci est une pelle qui sert exclusivement à faire des choses intéressantes. Ceci est une pelle qui sert exclusivement à faire des choses intéressantes. Ceci est une pelle qui sert exclusivement à faire des choses intéressantes. " +autowrap_mode = 3 +clip_text = true + +[node name="AvailableActions" type="HBoxContainer" parent="MarginContainer"] +unique_name_in_owner = true +layout_mode = 2 +size_flags_horizontal = 4 +size_flags_vertical = 8 +theme = ExtResource("2_nq5i2") + +[node name="GetItem" type="Label" parent="MarginContainer/AvailableActions"] +visible = false +layout_mode = 2 +text = "E - Take Item" +label_settings = ExtResource("4_ujg5r") + +[node name="SwapItem" type="Label" parent="MarginContainer/AvailableActions"] +visible = false +layout_mode = 2 +text = "E - Swap Item" +label_settings = ExtResource("4_ujg5r") + +[node name="DropItem" type="Label" parent="MarginContainer/AvailableActions"] +visible = false +layout_mode = 2 +text = "w - Drop Item" +label_settings = ExtResource("4_ujg5r") + +[node name="UseItem" type="Label" parent="MarginContainer/AvailableActions"] +visible = false +layout_mode = 2 +text = "space/click - Use Item" +label_settings = ExtResource("4_ujg5r") + +[node name="RechargeFade" type="ColorRect" parent="."] +physics_interpolation_mode = 0 +visible = false layout_mode = 1 anchors_preset = 15 anchor_right = 1.0 anchor_bottom = 1.0 grow_horizontal = 2 grow_vertical = 2 -mouse_filter = 2 color = Color(0, 0, 0, 0) [node name="AnimationPlayer" type="AnimationPlayer" parent="."] @@ -122,6 +245,10 @@ libraries = { &"": SubResource("AnimationLibrary_n4kem") } -[connection signal="player_stats_updated" from="." to="MarginContainer/PlayerInfo" method="_on_root_gui_player_stats_updated"] +[node name="GridContainer" type="GridContainer" parent="."] +layout_mode = 0 +offset_right = 40.0 +offset_bottom = 40.0 + [connection signal="button_down" from="GameAction" to="." method="_on_game_action_button_down"] [connection signal="pressed" from="MarginContainer/DayPass" to="." method="_on_day_pass_pressed"] diff --git a/gui/scripts/root_gui.gd b/gui/scripts/root_gui.gd index b1654cb..74575f1 100644 --- a/gui/scripts/root_gui.gd +++ b/gui/scripts/root_gui.gd @@ -1,15 +1,24 @@ extends Control class_name RootGui -signal player_stats_updated(player : Player) signal game_click signal day_pass_pressed signal day_pass_proceed signal day_pass_finished -func _on_player_player_stats_updated(player:Player): - emit_signal("player_stats_updated", player) +func _on_player_updated(player:Player): + $MarginContainer/PlayerInfo.player_update(player) + %AvailableActions/GetItem.visible = player.closest_interactable is ItemObject and player.inventory.lenght() == 0 + %AvailableActions/SwapItem.visible = player.closest_interactable is ItemObject and player.inventory.lenght() > 0 + %AvailableActions/DropItem.visible = player.inventory.lenght() > 0 + + %ItemInfo.visible = player.inventory.lenght() > 0 + if player.inventory.lenght() > 0: + var item : Item = player.inventory.get_item() + %ItemIcon.texture = item.icon + %ItemName.text = item.name + %ItemDesc.text = item.description func _on_planet_planet_stats_updated(day:int): $MarginContainer/DayCount.text = "Day " + str(day) diff --git a/project.godot b/project.godot index 9589bb4..c8cae62 100644 --- a/project.godot +++ b/project.godot @@ -41,11 +41,21 @@ move_down={ , Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":4194322,"key_label":0,"unicode":0,"location":0,"echo":false,"script":null) ] } +interact={ +"deadzone": 0.2, +"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":69,"key_label":0,"unicode":101,"location":0,"echo":false,"script":null) +] +} action={ "deadzone": 0.2, "events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":32,"key_label":0,"unicode":32,"location":0,"echo":false,"script":null) ] } +drop={ +"deadzone": 0.2, +"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":90,"key_label":0,"unicode":119,"location":0,"echo":false,"script":null) +] +} [rendering] diff --git a/root.tscn b/root.tscn index 41f23c1..76bc108 100644 --- a/root.tscn +++ b/root.tscn @@ -1,10 +1,13 @@ -[gd_scene load_steps=6 format=3 uid="uid://c5bruelvqbm1k"] +[gd_scene load_steps=9 format=3 uid="uid://c5bruelvqbm1k"] [ext_resource type="PackedScene" uid="uid://12nak7amd1uq" path="res://gui/root_gui.tscn" id="1_jnlp7"] [ext_resource type="PackedScene" uid="uid://tsi5j1uxppa4" path="res://stages/terrain/planet/planet.tscn" id="1_pyidc"] [ext_resource type="PackedScene" uid="uid://bgvbgeq46wee2" path="res://entities/player/player.tscn" id="2_vvh5c"] [ext_resource type="Resource" uid="uid://dmbu538b3utec" path="res://entities/plants/resources/plants/default.tres" id="3_jnlp7"] [ext_resource type="PackedScene" uid="uid://dj7gp3crtg2yt" path="res://entities/camera/camera.tscn" id="3_vvh5c"] +[ext_resource type="PackedScene" uid="uid://cd3re3552pt7m" path="res://entities/interactables/item_object/item_object.tscn" id="4_vyht1"] +[ext_resource type="Resource" uid="uid://bb8etgye1qtfx" path="res://common/inventory/resources/items/shovel.tres" id="5_bf3um"] +[ext_resource type="Resource" uid="uid://dbja8xm7ehw1v" path="res://common/inventory/resources/items/water_can.tres" id="6_bf3um"] [node name="Root" type="Node2D"] @@ -18,6 +21,14 @@ y_sort_enabled = true [node name="Player" parent="Entities" instance=ExtResource("2_vvh5c")] testPlantType = ExtResource("3_jnlp7") +[node name="Shovel" parent="Entities" instance=ExtResource("4_vyht1")] +position = Vector2(172, -31) +item = ExtResource("5_bf3um") + +[node name="WaterCan" parent="Entities" instance=ExtResource("4_vyht1")] +position = Vector2(-250, -116) +item = ExtResource("6_bf3um") + [node name="Planet" parent="." node_paths=PackedStringArray("import_entities_from_node") instance=ExtResource("1_pyidc")] import_entities_from_node = NodePath("../Entities") @@ -29,5 +40,5 @@ following = NodePath("../Entities/Player") [connection signal="day_pass_pressed" from="CanvasLayer/RootGui" to="Entities/Player" method="_on_root_gui_day_pass_pressed"] [connection signal="day_pass_proceed" from="CanvasLayer/RootGui" to="Planet" method="_on_root_gui_day_pass_proceed"] [connection signal="game_click" from="CanvasLayer/RootGui" to="Entities/Player" method="_on_root_gui_game_click"] -[connection signal="player_stats_updated" from="Entities/Player" to="CanvasLayer/RootGui" method="_on_player_player_stats_updated"] +[connection signal="player_updated" from="Entities/Player" to="CanvasLayer/RootGui" method="_on_player_updated"] [connection signal="planet_stats_updated" from="Planet" to="CanvasLayer/RootGui" method="_on_planet_planet_stats_updated"] diff --git a/stages/terrain/scripts/terrain.gd b/stages/terrain/scripts/terrain.gd index 50ce5e0..d887fbb 100644 --- a/stages/terrain/scripts/terrain.gd +++ b/stages/terrain/scripts/terrain.gd @@ -14,7 +14,7 @@ func _init(): if not terrainData: terrainData = TerrainData.new() -func add_entity(e : Node2D, container : Node2D): +func add_entity(e : Node2D, container : Node2D = entityContainer): if e.get_parent(): e.get_parent().remove_child(e) @@ -33,6 +33,11 @@ func create_entity_container() -> Node2D: return container +func drop_item(item: Item, item_position : Vector2): + var item_object = ItemObject.new(item) + add_entity(item_object) + item_object.global_position = item_position + func create_border_limit() -> StaticBody2D: var staticBody = StaticBody2D.new() var staticBodyCollision = CollisionPolygon2D.new()