parent
0afb93454e
commit
f5be43767a
@ -7,40 +7,40 @@ signal inventory_changed(inventory: Inventory)
|
|||||||
@export var max_items: int = 1
|
@export var max_items: int = 1
|
||||||
|
|
||||||
func add_item(item: Item):
|
func add_item(item: Item):
|
||||||
if items.size() < max_items:
|
if items.size() < max_items:
|
||||||
items.append(item)
|
items.append(item)
|
||||||
emit_signal("inventory_changed", self)
|
emit_signal("inventory_changed", self)
|
||||||
return true
|
return true
|
||||||
else:
|
else:
|
||||||
return false
|
return false
|
||||||
|
|
||||||
func add_items(items_to_add: Array[Item], fillup: bool = false):
|
func add_items(items_to_add: Array[Item], fillup: bool = false):
|
||||||
if fillup:
|
if fillup:
|
||||||
var has_changed := false
|
var has_changed := false
|
||||||
for i in min(items_to_add.size(), max_items - items.size()):
|
for i in min(items_to_add.size(), max_items - items.size()):
|
||||||
items.append(items_to_add[i])
|
items.append(items_to_add[i])
|
||||||
has_changed = true
|
has_changed = true
|
||||||
if has_changed:
|
if has_changed:
|
||||||
emit_signal("inventory_changed", self)
|
emit_signal("inventory_changed", self)
|
||||||
return has_changed
|
return has_changed
|
||||||
elif !fillup && items.size() + items_to_add.size() < max_items:
|
elif !fillup && items.size() + items_to_add.size() < max_items:
|
||||||
items.append_array(items_to_add)
|
items.append_array(items_to_add)
|
||||||
emit_signal("inventory_changed", self)
|
emit_signal("inventory_changed", self)
|
||||||
return true
|
return true
|
||||||
|
|
||||||
func lenght() -> int:
|
func lenght() -> int:
|
||||||
return len(items)
|
return len(items)
|
||||||
|
|
||||||
func get_item(ind: int = 0):
|
func get_item(ind: int = 0):
|
||||||
return items[ind]
|
return items[ind]
|
||||||
|
|
||||||
func pop_item(ind: int = 0):
|
func pop_item(ind: int = 0):
|
||||||
var item_removed: Item = items.pop_at(ind)
|
var item_removed: Item = items.pop_at(ind)
|
||||||
emit_signal("inventory_changed", self)
|
emit_signal("inventory_changed", self)
|
||||||
return item_removed
|
return item_removed
|
||||||
|
|
||||||
func swap_items(item_to_add: Item, ind_to_get: int = 0):
|
func swap_items(item_to_add: Item, ind_to_get: int = 0):
|
||||||
var item_to_get := items[ind_to_get]
|
var item_to_get := items[ind_to_get]
|
||||||
items[ind_to_get] = item_to_add
|
items[ind_to_get] = item_to_add
|
||||||
emit_signal("inventory_changed", self)
|
emit_signal("inventory_changed", self)
|
||||||
return item_to_get
|
return item_to_get
|
||||||
|
|||||||
@ -5,8 +5,11 @@ class_name Item
|
|||||||
@export var description: String
|
@export var description: String
|
||||||
@export var icon: Texture2D
|
@export var icon: Texture2D
|
||||||
|
|
||||||
func can_use() -> bool:
|
func is_one_time_use():
|
||||||
return false
|
return false
|
||||||
|
|
||||||
func use() -> bool:
|
func can_use(_player : Player) -> bool:
|
||||||
|
return false
|
||||||
|
|
||||||
|
func use(_player : Player) -> bool:
|
||||||
return false
|
return false
|
||||||
@ -1,11 +1,25 @@
|
|||||||
|
@tool
|
||||||
extends Item
|
extends Item
|
||||||
class_name SeedItem
|
class_name SeedItem
|
||||||
|
|
||||||
@export var plant_type: PlantType
|
@export var plant_type: PlantType :
|
||||||
|
set(v):
|
||||||
|
plant_type = v
|
||||||
|
if plant_type:
|
||||||
|
name = plant_type.name
|
||||||
|
description = plant_type.description
|
||||||
|
icon = plant_type.seed_texture
|
||||||
|
|
||||||
func _init():
|
func _init(_plant_type : PlantType = null):
|
||||||
if plant_type:
|
plant_type = _plant_type
|
||||||
if plant_type.name:
|
|
||||||
name = plant_type.name
|
func is_one_time_use():
|
||||||
if plant_type.seed_texture:
|
return true
|
||||||
icon = plant_type.seed_texture
|
|
||||||
|
func can_use(player : Player) -> bool:
|
||||||
|
return not player.planet.is_there_contamination(player.global_position)
|
||||||
|
|
||||||
|
func use(player : Player) -> bool:
|
||||||
|
if not can_use(player):
|
||||||
|
return false
|
||||||
|
return player.planet.plant(plant_type, player.global_position)
|
||||||
|
|||||||
@ -1,8 +1,36 @@
|
|||||||
[gd_scene load_steps=6 format=3 uid="uid://bcj812ox8xv2t"]
|
[gd_scene load_steps=7 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="Script" uid="uid://reliyx2pg7kf" path="res://entities/interactables/item_object/script/item_object_sprite.gd" id="1_wing4"]
|
||||||
|
[ext_resource type="Texture2D" uid="uid://bo3o2qf3i20ke" path="res://common/inventory/assets/icons/scuba-diving-tank.svg" id="2_ng3e4"]
|
||||||
[ext_resource type="Texture2D" uid="uid://c1eiu5ag7lcp8" path="res://entities/interactables/item_object/assets/sprites/shadow.svg" id="2_ng201"]
|
[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_wing4"]
|
||||||
|
length = 0.001
|
||||||
|
tracks/0/type = "value"
|
||||||
|
tracks/0/imported = false
|
||||||
|
tracks/0/enabled = true
|
||||||
|
tracks/0/path = NodePath("Shadow:scale")
|
||||||
|
tracks/0/interp = 1
|
||||||
|
tracks/0/loop_wrap = true
|
||||||
|
tracks/0/keys = {
|
||||||
|
"times": PackedFloat32Array(0),
|
||||||
|
"transitions": PackedFloat32Array(1),
|
||||||
|
"update": 0,
|
||||||
|
"values": [Vector2(0.875, 0.875)]
|
||||||
|
}
|
||||||
|
tracks/1/type = "value"
|
||||||
|
tracks/1/imported = false
|
||||||
|
tracks/1/enabled = true
|
||||||
|
tracks/1/path = NodePath("Icon:position")
|
||||||
|
tracks/1/interp = 1
|
||||||
|
tracks/1/loop_wrap = true
|
||||||
|
tracks/1/keys = {
|
||||||
|
"times": PackedFloat32Array(0),
|
||||||
|
"transitions": PackedFloat32Array(1),
|
||||||
|
"update": 0,
|
||||||
|
"values": [Vector2(0, 0)]
|
||||||
|
}
|
||||||
|
|
||||||
[sub_resource type="Animation" id="Animation_ng201"]
|
[sub_resource type="Animation" id="Animation_ng201"]
|
||||||
resource_name = "default"
|
resource_name = "default"
|
||||||
length = 2.0
|
length = 2.0
|
||||||
@ -10,77 +38,26 @@ loop_mode = 1
|
|||||||
tracks/0/type = "value"
|
tracks/0/type = "value"
|
||||||
tracks/0/imported = false
|
tracks/0/imported = false
|
||||||
tracks/0/enabled = true
|
tracks/0/enabled = true
|
||||||
tracks/0/path = NodePath(".:position")
|
tracks/0/path = NodePath("Shadow:scale")
|
||||||
tracks/0/interp = 2
|
tracks/0/interp = 2
|
||||||
tracks/0/loop_wrap = true
|
tracks/0/loop_wrap = true
|
||||||
tracks/0/keys = {
|
tracks/0/keys = {
|
||||||
"times": PackedFloat32Array(0, 1, 2),
|
"times": PackedFloat32Array(0, 1, 2),
|
||||||
"transitions": PackedFloat32Array(1, 1, 1),
|
"transitions": PackedFloat32Array(1, 1, 1),
|
||||||
"update": 0,
|
"update": 0,
|
||||||
"values": [Vector2(0, 0), Vector2(0, -5), Vector2(0, 0)]
|
"values": [Vector2(0.875, 0.875), Vector2(0.7, 0.7), Vector2(0.875, 0.875)]
|
||||||
}
|
}
|
||||||
tracks/1/type = "value"
|
tracks/1/type = "value"
|
||||||
tracks/1/imported = false
|
tracks/1/imported = false
|
||||||
tracks/1/enabled = true
|
tracks/1/enabled = true
|
||||||
tracks/1/path = NodePath("Shadow:position")
|
tracks/1/path = NodePath("Icon:position")
|
||||||
tracks/1/interp = 2
|
tracks/1/interp = 2
|
||||||
tracks/1/loop_wrap = true
|
tracks/1/loop_wrap = true
|
||||||
tracks/1/keys = {
|
tracks/1/keys = {
|
||||||
"times": PackedFloat32Array(0, 1, 2),
|
"times": PackedFloat32Array(0, 1, 2.06667),
|
||||||
"transitions": PackedFloat32Array(1, 1, 1),
|
"transitions": PackedFloat32Array(1, 1, 1),
|
||||||
"update": 0,
|
"update": 0,
|
||||||
"values": [Vector2(0, 23), Vector2(0, 28), Vector2(0, 23)]
|
"values": [Vector2(0, 0), Vector2(0, -8), Vector2(0, 0)]
|
||||||
}
|
|
||||||
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"]
|
[sub_resource type="AnimationLibrary" id="AnimationLibrary_ng3e4"]
|
||||||
@ -89,8 +66,11 @@ _data = {
|
|||||||
&"default": SubResource("Animation_ng201")
|
&"default": SubResource("Animation_ng201")
|
||||||
}
|
}
|
||||||
|
|
||||||
[node name="ItemObjectSprite" type="Sprite2D"]
|
[node name="ItemObjectSprite" type="Node2D"]
|
||||||
texture = ExtResource("1_7u8ru")
|
script = ExtResource("1_wing4")
|
||||||
|
|
||||||
|
[node name="Icon" type="Sprite2D" parent="."]
|
||||||
|
texture = ExtResource("2_ng3e4")
|
||||||
|
|
||||||
[node name="Shadow" type="Sprite2D" parent="."]
|
[node name="Shadow" type="Sprite2D" parent="."]
|
||||||
modulate = Color(1, 1, 1, 0.227451)
|
modulate = Color(1, 1, 1, 0.227451)
|
||||||
|
|||||||
@ -2,15 +2,16 @@ extends Interactable
|
|||||||
class_name ItemObject
|
class_name ItemObject
|
||||||
|
|
||||||
const ITEM_AREA_WIDTH = 10
|
const ITEM_AREA_WIDTH = 10
|
||||||
|
const ITEM_SPRITE_SIZE = 40.
|
||||||
const SPRITE_SCENE : PackedScene = preload("res://entities/interactables/item_object/item_object_sprite.tscn")
|
const SPRITE_SCENE : PackedScene = preload("res://entities/interactables/item_object/item_object_sprite.tscn")
|
||||||
|
|
||||||
@export var item : Item :
|
@export var item : Item :
|
||||||
set(_item):
|
set(_item):
|
||||||
item = _item
|
item = _item
|
||||||
if sprite:
|
if object_sprite:
|
||||||
sprite.texture = item.icon
|
object_sprite.apply_texture_to_sprite(item.icon, ITEM_SPRITE_SIZE)
|
||||||
|
|
||||||
@onready var sprite : Sprite2D = generate_sprite()
|
@onready var object_sprite : ItemObjectSprite = generate_sprite()
|
||||||
|
|
||||||
func _init(_item = null):
|
func _init(_item = null):
|
||||||
if _item:
|
if _item:
|
||||||
@ -39,10 +40,13 @@ func pickup_animation(player : Player):
|
|||||||
queue_free()
|
queue_free()
|
||||||
)
|
)
|
||||||
|
|
||||||
func generate_sprite() -> Sprite2D:
|
func generate_sprite() -> ItemObjectSprite:
|
||||||
var s = SPRITE_SCENE.instantiate() as Sprite2D
|
var spriteNode = SPRITE_SCENE.instantiate() as ItemObjectSprite
|
||||||
add_child(s)
|
add_child(spriteNode)
|
||||||
|
|
||||||
s.texture = item.icon
|
spriteNode.apply_texture_to_sprite(
|
||||||
|
item.icon,
|
||||||
|
ITEM_SPRITE_SIZE
|
||||||
|
)
|
||||||
|
|
||||||
return s
|
return spriteNode
|
||||||
@ -0,0 +1,11 @@
|
|||||||
|
extends Node2D
|
||||||
|
class_name ItemObjectSprite
|
||||||
|
|
||||||
|
@onready var iconSprite = $Icon
|
||||||
|
|
||||||
|
func apply_texture_to_sprite(texture, item_sprite_size = 50.):
|
||||||
|
iconSprite.texture = texture
|
||||||
|
iconSprite.scale = Vector2(
|
||||||
|
1./(texture.get_width()/item_sprite_size),
|
||||||
|
1./(texture.get_height()/item_sprite_size)
|
||||||
|
)
|
||||||
@ -0,0 +1 @@
|
|||||||
|
uid://reliyx2pg7kf
|
||||||
BIN
entities/plants/assets/sprites/seeds/grille_seeds.png
Normal file
BIN
entities/plants/assets/sprites/seeds/grille_seeds.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 391 KiB |
34
entities/plants/assets/sprites/seeds/grille_seeds.png.import
Normal file
34
entities/plants/assets/sprites/seeds/grille_seeds.png.import
Normal file
@ -0,0 +1,34 @@
|
|||||||
|
[remap]
|
||||||
|
|
||||||
|
importer="texture"
|
||||||
|
type="CompressedTexture2D"
|
||||||
|
uid="uid://pltmnkqd5ut2"
|
||||||
|
path="res://.godot/imported/grille_seeds.png-5193c30dc41cd45a15f8418b446b498e.ctex"
|
||||||
|
metadata={
|
||||||
|
"vram_texture": false
|
||||||
|
}
|
||||||
|
|
||||||
|
[deps]
|
||||||
|
|
||||||
|
source_file="res://entities/plants/assets/sprites/seeds/grille_seeds.png"
|
||||||
|
dest_files=["res://.godot/imported/grille_seeds.png-5193c30dc41cd45a15f8418b446b498e.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
|
||||||
@ -1,20 +1,27 @@
|
|||||||
[gd_resource type="Resource" script_class="PlantType" load_steps=7 format=3 uid="uid://b04vho33bl52b"]
|
[gd_resource type="Resource" script_class="PlantType" load_steps=9 format=3 uid="uid://b04vho33bl52b"]
|
||||||
|
|
||||||
[ext_resource type="Texture2D" uid="uid://c7mp7tkkkk6o5" path="res://entities/plants/assets/sprites/default/growing.png" id="1_fp5j6"]
|
[ext_resource type="Texture2D" uid="uid://c7mp7tkkkk6o5" path="res://entities/plants/assets/sprites/default/growing.png" id="1_fp5j6"]
|
||||||
[ext_resource type="Script" path="res://entities/plants/scripts/plant_type.gd" id="1_moyj3"]
|
[ext_resource type="Script" uid="uid://jnye5pe1bgqw" path="res://entities/plants/scripts/plant_type.gd" id="1_moyj3"]
|
||||||
[ext_resource type="Script" path="res://entities/plants/scripts/plant_effects/decontaminate_terrain_effect.gd" id="2_cky1j"]
|
[ext_resource type="Script" path="res://entities/plants/scripts/plant_effects/decontaminate_terrain_effect.gd" id="2_cky1j"]
|
||||||
[ext_resource type="Texture2D" uid="uid://bupl1y0cfj21q" path="res://entities/plants/assets/sprites/default/mature.png" id="3_ffarr"]
|
[ext_resource type="Texture2D" uid="uid://bupl1y0cfj21q" path="res://entities/plants/assets/sprites/default/mature.png" id="3_ffarr"]
|
||||||
[ext_resource type="Texture2D" uid="uid://ba413oun7ry78" path="res://entities/plants/assets/sprites/default/planted.png" id="4_2s6re"]
|
[ext_resource type="Texture2D" uid="uid://ba413oun7ry78" path="res://entities/plants/assets/sprites/default/planted.png" id="4_2s6re"]
|
||||||
|
[ext_resource type="Texture2D" uid="uid://pltmnkqd5ut2" path="res://entities/plants/assets/sprites/seeds/grille_seeds.png" id="6_cky1j"]
|
||||||
|
|
||||||
[sub_resource type="Resource" id="Resource_q68uy"]
|
[sub_resource type="Resource" id="Resource_q68uy"]
|
||||||
script = ExtResource("2_cky1j")
|
script = ExtResource("2_cky1j")
|
||||||
impact_radius = 100
|
impact_radius = 100
|
||||||
metadata/_custom_type_script = "uid://cgscbuxe4dawb"
|
metadata/_custom_type_script = "uid://cgscbuxe4dawb"
|
||||||
|
|
||||||
|
[sub_resource type="AtlasTexture" id="AtlasTexture_ffarr"]
|
||||||
|
atlas = ExtResource("6_cky1j")
|
||||||
|
region = Rect2(1140, 345, 141, 128)
|
||||||
|
|
||||||
[resource]
|
[resource]
|
||||||
script = ExtResource("1_moyj3")
|
script = ExtResource("1_moyj3")
|
||||||
name = ""
|
name = "Chardi"
|
||||||
|
description = "This plant can grow without water, and reduce contamination around when it becomes mature."
|
||||||
growing_time = 2
|
growing_time = 2
|
||||||
|
seed_texture = SubResource("AtlasTexture_ffarr")
|
||||||
planted_texture = ExtResource("4_2s6re")
|
planted_texture = ExtResource("4_2s6re")
|
||||||
growing_texture = ExtResource("1_fp5j6")
|
growing_texture = ExtResource("1_fp5j6")
|
||||||
mature_texture = ExtResource("3_ffarr")
|
mature_texture = ExtResource("3_ffarr")
|
||||||
|
|||||||
@ -2,6 +2,7 @@ extends Resource
|
|||||||
class_name PlantType
|
class_name PlantType
|
||||||
|
|
||||||
@export var name : String
|
@export var name : String
|
||||||
|
@export_multiline var description : String
|
||||||
|
|
||||||
@export var growing_time : int
|
@export var growing_time : int
|
||||||
|
|
||||||
|
|||||||
@ -82,3 +82,4 @@ stream = SubResource("AudioStreamRandomizer_24ehl")
|
|||||||
|
|
||||||
[node name="AudioStreamPlayer_movement" type="AudioStreamPlayer" parent="Audio"]
|
[node name="AudioStreamPlayer_movement" type="AudioStreamPlayer" parent="Audio"]
|
||||||
stream = SubResource("AudioStreamRandomizer_bwdx1")
|
stream = SubResource("AudioStreamRandomizer_bwdx1")
|
||||||
|
volume_db = -20.0
|
||||||
|
|||||||
@ -6,8 +6,6 @@ signal player_updated(player: Player)
|
|||||||
var planet : Planet # mis à jour par la classe Planet
|
var planet : Planet # mis à jour par la classe Planet
|
||||||
@export var speed = 400
|
@export var speed = 400
|
||||||
|
|
||||||
@export var testPlantType : PlantType
|
|
||||||
|
|
||||||
@onready var inventory : Inventory = Inventory.new()
|
@onready var inventory : Inventory = Inventory.new()
|
||||||
|
|
||||||
var max_energy : int = 10
|
var max_energy : int = 10
|
||||||
@ -23,6 +21,12 @@ var closest_interactable : Interactable = null :
|
|||||||
closest_interactable = v
|
closest_interactable = v
|
||||||
if old != closest_interactable:
|
if old != closest_interactable:
|
||||||
player_updated.emit(self)
|
player_updated.emit(self)
|
||||||
|
var can_use_item : bool = false :
|
||||||
|
set(v):
|
||||||
|
var old = can_use_item
|
||||||
|
can_use_item = v
|
||||||
|
if old != can_use_item:
|
||||||
|
player_updated.emit(self)
|
||||||
var energy : int = max_energy :
|
var energy : int = max_energy :
|
||||||
set(v):
|
set(v):
|
||||||
energy = v
|
energy = v
|
||||||
@ -40,8 +44,9 @@ func get_input():
|
|||||||
var old_velocity=velocity
|
var old_velocity=velocity
|
||||||
calculate_direction()
|
calculate_direction()
|
||||||
|
|
||||||
if Input.is_action_just_pressed("action") and energy > 0:
|
can_use_item = inventory.lenght() != 0 and inventory.get_item().can_use(self)
|
||||||
action()
|
if Input.is_action_just_pressed("action"):
|
||||||
|
use_item()
|
||||||
if Input.is_action_just_pressed("interact") and closest_interactable:
|
if Input.is_action_just_pressed("interact") and closest_interactable:
|
||||||
closest_interactable.interact(self)
|
closest_interactable.interact(self)
|
||||||
if Input.is_action_just_pressed("drop") and inventory.lenght() > 0:
|
if Input.is_action_just_pressed("drop") and inventory.lenght() > 0:
|
||||||
@ -56,12 +61,17 @@ func calculate_direction():
|
|||||||
if input_direction.x:
|
if input_direction.x:
|
||||||
$Sprite.flip_h = (input_direction.x < 0)
|
$Sprite.flip_h = (input_direction.x < 0)
|
||||||
|
|
||||||
func action():
|
func try_use_item():
|
||||||
if planet:
|
if energy > 0 and can_use_item:
|
||||||
planet.plant(
|
use_item()
|
||||||
testPlantType,
|
|
||||||
global_position
|
func use_item():
|
||||||
)
|
var item = inventory.get_item()
|
||||||
|
var is_item_used = item.use(self)
|
||||||
|
if is_item_used:
|
||||||
|
energy -= 1
|
||||||
|
if item.is_one_time_use():
|
||||||
|
inventory.pop_item()
|
||||||
|
|
||||||
func pass_day():
|
func pass_day():
|
||||||
energy = max_energy
|
energy = max_energy
|
||||||
@ -94,4 +104,4 @@ func _on_root_gui_day_pass_finished():
|
|||||||
controlling_player = true
|
controlling_player = true
|
||||||
|
|
||||||
func _on_root_gui_game_click():
|
func _on_root_gui_game_click():
|
||||||
action()
|
try_use_item()
|
||||||
|
|||||||
@ -1,4 +1,4 @@
|
|||||||
[gd_scene load_steps=14 format=3 uid="uid://12nak7amd1uq"]
|
[gd_scene load_steps=16 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="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="Script" uid="uid://cqao7n800qy40" path="res://gui/scripts/root_gui.gd" id="1_udau0"]
|
||||||
@ -6,13 +6,20 @@
|
|||||||
[ext_resource type="Texture2D" uid="uid://dcgnamu7sb3ov" path="res://gui/player_info/assets/icons/bolt.svg" id="4_k4juk"]
|
[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="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://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="Texture2D" uid="uid://pltmnkqd5ut2" path="res://entities/plants/assets/sprites/seeds/grille_seeds.png" id="7_n4kem"]
|
||||||
[ext_resource type="FontFile" uid="uid://cpnsnrqhfkj3k" path="res://gui/ressources/fonts/spincycle_ot.otf" id="8_n4kem"]
|
[ext_resource type="FontFile" uid="uid://cpnsnrqhfkj3k" path="res://gui/ressources/fonts/spincycle_ot.otf" id="8_n4kem"]
|
||||||
|
|
||||||
|
[sub_resource type="AtlasTexture" id="AtlasTexture_ek73b"]
|
||||||
|
atlas = ExtResource("7_n4kem")
|
||||||
|
region = Rect2(76, 75, 124, 135)
|
||||||
|
|
||||||
[sub_resource type="LabelSettings" id="LabelSettings_ek73b"]
|
[sub_resource type="LabelSettings" id="LabelSettings_ek73b"]
|
||||||
font = ExtResource("8_n4kem")
|
font = ExtResource("8_n4kem")
|
||||||
font_size = 20
|
font_size = 20
|
||||||
|
|
||||||
|
[sub_resource type="LabelSettings" id="LabelSettings_n4kem"]
|
||||||
|
font_size = 12
|
||||||
|
|
||||||
[sub_resource type="Animation" id="Animation_iyvkh"]
|
[sub_resource type="Animation" id="Animation_iyvkh"]
|
||||||
length = 0.001
|
length = 0.001
|
||||||
tracks/0/type = "value"
|
tracks/0/type = "value"
|
||||||
@ -180,8 +187,9 @@ theme = ExtResource("2_nq5i2")
|
|||||||
unique_name_in_owner = true
|
unique_name_in_owner = true
|
||||||
custom_minimum_size = Vector2(0, 50)
|
custom_minimum_size = Vector2(0, 50)
|
||||||
layout_mode = 2
|
layout_mode = 2
|
||||||
texture = ExtResource("7_n4kem")
|
texture = SubResource("AtlasTexture_ek73b")
|
||||||
stretch_mode = 3
|
expand_mode = 1
|
||||||
|
stretch_mode = 5
|
||||||
|
|
||||||
[node name="ItemName" type="Label" parent="MarginContainer/ItemInfo/MarginContainer/VBoxContainer"]
|
[node name="ItemName" type="Label" parent="MarginContainer/ItemInfo/MarginContainer/VBoxContainer"]
|
||||||
unique_name_in_owner = true
|
unique_name_in_owner = true
|
||||||
@ -195,6 +203,7 @@ unique_name_in_owner = true
|
|||||||
layout_mode = 2
|
layout_mode = 2
|
||||||
size_flags_vertical = 3
|
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. "
|
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. "
|
||||||
|
label_settings = SubResource("LabelSettings_n4kem")
|
||||||
autowrap_mode = 3
|
autowrap_mode = 3
|
||||||
clip_text = true
|
clip_text = true
|
||||||
|
|
||||||
@ -205,6 +214,12 @@ size_flags_horizontal = 4
|
|||||||
size_flags_vertical = 8
|
size_flags_vertical = 8
|
||||||
theme = ExtResource("2_nq5i2")
|
theme = ExtResource("2_nq5i2")
|
||||||
|
|
||||||
|
[node name="Plant" type="Label" parent="MarginContainer/AvailableActions"]
|
||||||
|
visible = false
|
||||||
|
layout_mode = 2
|
||||||
|
text = "space/click - Plant Seed"
|
||||||
|
label_settings = ExtResource("4_ujg5r")
|
||||||
|
|
||||||
[node name="GetItem" type="Label" parent="MarginContainer/AvailableActions"]
|
[node name="GetItem" type="Label" parent="MarginContainer/AvailableActions"]
|
||||||
visible = false
|
visible = false
|
||||||
layout_mode = 2
|
layout_mode = 2
|
||||||
|
|||||||
@ -12,6 +12,9 @@ func _on_player_updated(player:Player):
|
|||||||
%AvailableActions/GetItem.visible = player.closest_interactable is ItemObject and player.inventory.lenght() == 0
|
%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/SwapItem.visible = player.closest_interactable is ItemObject and player.inventory.lenght() > 0
|
||||||
%AvailableActions/DropItem.visible = player.inventory.lenght() > 0
|
%AvailableActions/DropItem.visible = player.inventory.lenght() > 0
|
||||||
|
%AvailableActions/UseItem.visible = player.inventory.lenght() > 0 and player.can_use_item and not player.inventory.get_item() is SeedItem
|
||||||
|
%AvailableActions/Plant.visible = player.inventory.lenght() > 0 and player.can_use_item and player.inventory.get_item() is SeedItem
|
||||||
|
|
||||||
|
|
||||||
%ItemInfo.visible = player.inventory.lenght() > 0
|
%ItemInfo.visible = player.inventory.lenght() > 0
|
||||||
if player.inventory.lenght() > 0:
|
if player.inventory.lenght() > 0:
|
||||||
|
|||||||
23
root.tscn
23
root.tscn
@ -1,13 +1,27 @@
|
|||||||
[gd_scene load_steps=9 format=3 uid="uid://c5bruelvqbm1k"]
|
[gd_scene load_steps=13 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://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://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="PackedScene" uid="uid://bgvbgeq46wee2" path="res://entities/player/player.tscn" id="2_vvh5c"]
|
||||||
[ext_resource type="Resource" uid="uid://b04vho33bl52b" path="res://entities/plants/resources/plants/default.tres" id="3_jnlp7"]
|
[ext_resource type="Resource" uid="uid://b04vho33bl52b" 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://dj7gp3crtg2yt" path="res://entities/camera/camera.tscn" id="3_vvh5c"]
|
||||||
[ext_resource type="PackedScene" path="res://entities/interactables/item_object/item_object.tscn" id="4_vyht1"]
|
[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://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"]
|
[ext_resource type="Resource" uid="uid://dbja8xm7ehw1v" path="res://common/inventory/resources/items/water_can.tres" id="6_bf3um"]
|
||||||
|
[ext_resource type="Script" uid="uid://bypjcvlc15gsm" path="res://common/inventory/scripts/items/seed_item.gd" id="6_huihk"]
|
||||||
|
[ext_resource type="Texture2D" uid="uid://pltmnkqd5ut2" path="res://entities/plants/assets/sprites/seeds/grille_seeds.png" id="6_tw3kd"]
|
||||||
|
|
||||||
|
[sub_resource type="AtlasTexture" id="AtlasTexture_ffarr"]
|
||||||
|
atlas = ExtResource("6_tw3kd")
|
||||||
|
region = Rect2(1140, 345, 141, 128)
|
||||||
|
|
||||||
|
[sub_resource type="Resource" id="Resource_gd4vy"]
|
||||||
|
script = ExtResource("6_huihk")
|
||||||
|
plant_type = ExtResource("3_jnlp7")
|
||||||
|
name = "Chardi"
|
||||||
|
description = "This plant can grow without water, and reduce contamination around when it becomes mature."
|
||||||
|
icon = SubResource("AtlasTexture_ffarr")
|
||||||
|
metadata/_custom_type_script = "uid://bypjcvlc15gsm"
|
||||||
|
|
||||||
[node name="Root" type="Node2D"]
|
[node name="Root" type="Node2D"]
|
||||||
|
|
||||||
@ -19,12 +33,15 @@
|
|||||||
y_sort_enabled = true
|
y_sort_enabled = true
|
||||||
|
|
||||||
[node name="Player" parent="Entities" instance=ExtResource("2_vvh5c")]
|
[node name="Player" parent="Entities" instance=ExtResource("2_vvh5c")]
|
||||||
testPlantType = ExtResource("3_jnlp7")
|
|
||||||
|
|
||||||
[node name="Shovel" parent="Entities" instance=ExtResource("4_vyht1")]
|
[node name="Shovel" parent="Entities" instance=ExtResource("4_vyht1")]
|
||||||
position = Vector2(172, -31)
|
position = Vector2(172, -31)
|
||||||
item = ExtResource("5_bf3um")
|
item = ExtResource("5_bf3um")
|
||||||
|
|
||||||
|
[node name="Seed" parent="Entities" instance=ExtResource("4_vyht1")]
|
||||||
|
position = Vector2(24, -189)
|
||||||
|
item = SubResource("Resource_gd4vy")
|
||||||
|
|
||||||
[node name="WaterCan" parent="Entities" instance=ExtResource("4_vyht1")]
|
[node name="WaterCan" parent="Entities" instance=ExtResource("4_vyht1")]
|
||||||
position = Vector2(-250, -116)
|
position = Vector2(-250, -116)
|
||||||
item = ExtResource("6_bf3um")
|
item = ExtResource("6_bf3um")
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user