ajout de la plant champ et suppression de la texture planted (ajout de la graine à la place) #55
@ -20,7 +20,12 @@ func is_one_time_use():
|
|||||||
return true
|
return true
|
||||||
|
|
||||||
func can_use(player : Player, zone : Area2D) -> bool:
|
func can_use(player : Player, zone : Area2D) -> bool:
|
||||||
return not player.planet.is_there_contamination(zone.global_position)
|
var is_there_a_plant_here = false
|
||||||
|
for area in zone.get_overlapping_areas() :
|
||||||
|
if area is Plant:
|
||||||
|
is_there_a_plant_here = true
|
||||||
|
|
||||||
|
return not is_there_a_plant_here and not player.planet.is_there_contamination(zone.global_position)
|
||||||
|
|
||||||
func use(player : Player, zone : Area2D) -> bool:
|
func use(player : Player, zone : Area2D) -> bool:
|
||||||
player.play_sfx("dig")
|
player.play_sfx("dig")
|
||||||
|
|||||||
BIN
entities/plants/assets/sprites/champ/growing.png
Normal file
|
After Width: | Height: | Size: 66 KiB |
@ -2,16 +2,16 @@
|
|||||||
|
|
||||||
importer="texture"
|
importer="texture"
|
||||||
type="CompressedTexture2D"
|
type="CompressedTexture2D"
|
||||||
uid="uid://cpx7bkrvttasr"
|
uid="uid://dmsls8siudy1u"
|
||||||
path="res://.godot/imported/planted.png-4bf3c8ff7d8aae08d7e3691f7e49cab2.ctex"
|
path="res://.godot/imported/growing.png-1974f3b5dd8b515f2458ee84afbec1aa.ctex"
|
||||||
metadata={
|
metadata={
|
||||||
"vram_texture": false
|
"vram_texture": false
|
||||||
}
|
}
|
||||||
|
|
||||||
[deps]
|
[deps]
|
||||||
|
|
||||||
source_file="res://entities/plants/assets/sprites/maias/planted.png"
|
source_file="res://entities/plants/assets/sprites/champ/growing.png"
|
||||||
dest_files=["res://.godot/imported/planted.png-4bf3c8ff7d8aae08d7e3691f7e49cab2.ctex"]
|
dest_files=["res://.godot/imported/growing.png-1974f3b5dd8b515f2458ee84afbec1aa.ctex"]
|
||||||
|
|
||||||
[params]
|
[params]
|
||||||
|
|
||||||
BIN
entities/plants/assets/sprites/champ/mature.png
Normal file
|
After Width: | Height: | Size: 138 KiB |
@ -2,16 +2,16 @@
|
|||||||
|
|
||||||
importer="texture"
|
importer="texture"
|
||||||
type="CompressedTexture2D"
|
type="CompressedTexture2D"
|
||||||
uid="uid://ba413oun7ry78"
|
uid="uid://crc4aop6ajiau"
|
||||||
path="res://.godot/imported/planted.png-2c23372e71d0997d310374f47bb48594.ctex"
|
path="res://.godot/imported/mature.png-44f597dc7980e7657c7418444db3823d.ctex"
|
||||||
metadata={
|
metadata={
|
||||||
"vram_texture": false
|
"vram_texture": false
|
||||||
}
|
}
|
||||||
|
|
||||||
[deps]
|
[deps]
|
||||||
|
|
||||||
source_file="res://entities/plants/assets/sprites/default/planted.png"
|
source_file="res://entities/plants/assets/sprites/champ/mature.png"
|
||||||
dest_files=["res://.godot/imported/planted.png-2c23372e71d0997d310374f47bb48594.ctex"]
|
dest_files=["res://.godot/imported/mature.png-44f597dc7980e7657c7418444db3823d.ctex"]
|
||||||
|
|
||||||
[params]
|
[params]
|
||||||
|
|
||||||
|
Before Width: | Height: | Size: 22 KiB After Width: | Height: | Size: 22 KiB |
@ -3,15 +3,15 @@
|
|||||||
importer="texture"
|
importer="texture"
|
||||||
type="CompressedTexture2D"
|
type="CompressedTexture2D"
|
||||||
uid="uid://c7mp7tkkkk6o5"
|
uid="uid://c7mp7tkkkk6o5"
|
||||||
path="res://.godot/imported/growing.png-3f6fb3171589f3a22ebfeda1a4575199.ctex"
|
path="res://.godot/imported/growing.png-c0d45a498c8bfc90776eb09d341d1579.ctex"
|
||||||
metadata={
|
metadata={
|
||||||
"vram_texture": false
|
"vram_texture": false
|
||||||
}
|
}
|
||||||
|
|
||||||
[deps]
|
[deps]
|
||||||
|
|
||||||
source_file="res://entities/plants/assets/sprites/default/growing.png"
|
source_file="res://entities/plants/assets/sprites/chardi/growing.png"
|
||||||
dest_files=["res://.godot/imported/growing.png-3f6fb3171589f3a22ebfeda1a4575199.ctex"]
|
dest_files=["res://.godot/imported/growing.png-c0d45a498c8bfc90776eb09d341d1579.ctex"]
|
||||||
|
|
||||||
[params]
|
[params]
|
||||||
|
|
||||||
|
Before Width: | Height: | Size: 149 KiB After Width: | Height: | Size: 149 KiB |
@ -3,15 +3,15 @@
|
|||||||
importer="texture"
|
importer="texture"
|
||||||
type="CompressedTexture2D"
|
type="CompressedTexture2D"
|
||||||
uid="uid://bupl1y0cfj21q"
|
uid="uid://bupl1y0cfj21q"
|
||||||
path="res://.godot/imported/mature.png-f8b2b72a84e90cfc6bf925d1d48f7f7e.ctex"
|
path="res://.godot/imported/mature.png-a98b30ab80fe074a42994ef9926caee8.ctex"
|
||||||
metadata={
|
metadata={
|
||||||
"vram_texture": false
|
"vram_texture": false
|
||||||
}
|
}
|
||||||
|
|
||||||
[deps]
|
[deps]
|
||||||
|
|
||||||
source_file="res://entities/plants/assets/sprites/default/mature.png"
|
source_file="res://entities/plants/assets/sprites/chardi/mature.png"
|
||||||
dest_files=["res://.godot/imported/mature.png-f8b2b72a84e90cfc6bf925d1d48f7f7e.ctex"]
|
dest_files=["res://.godot/imported/mature.png-a98b30ab80fe074a42994ef9926caee8.ctex"]
|
||||||
|
|
||||||
[params]
|
[params]
|
||||||
|
|
||||||
|
Before Width: | Height: | Size: 15 KiB |
|
Before Width: | Height: | Size: 16 KiB |
@ -1,14 +1,20 @@
|
|||||||
[gd_scene load_steps=7 format=3 uid="uid://2hrg6yjk0yt0"]
|
[gd_scene load_steps=10 format=3 uid="uid://2hrg6yjk0yt0"]
|
||||||
|
|
||||||
[ext_resource type="Script" uid="uid://bmjjpk4lvijws" path="res://entities/plants/scripts/plant_sprite.gd" id="1_pq8o7"]
|
[ext_resource type="Script" uid="uid://bmjjpk4lvijws" path="res://entities/plants/scripts/plant_sprite.gd" id="1_pq8o7"]
|
||||||
[ext_resource type="Texture2D" uid="uid://b3wom2xu26g43" path="res://entities/plants/assets/sprites/default_plant_glowing.png" id="2_hyinx"]
|
[ext_resource type="Texture2D" uid="uid://ba413oun7ry78" path="res://entities/plants/assets/sprites/chardi/planted.png" id="2_rbgiq"]
|
||||||
|
[ext_resource type="Texture2D" uid="uid://pltmnkqd5ut2" path="res://entities/plants/assets/sprites/seeds/grille_seeds.png" id="3_j6jm5"]
|
||||||
|
[ext_resource type="Texture2D" uid="uid://bu26h0iqutnky" path="res://entities/underground_loot/assets/sprites/underground_loot.svg" id="4_j6jm5"]
|
||||||
|
|
||||||
|
[sub_resource type="AtlasTexture" id="AtlasTexture_wyuub"]
|
||||||
|
atlas = ExtResource("3_j6jm5")
|
||||||
|
region = Rect2(76, 75, 124, 135)
|
||||||
|
|
||||||
[sub_resource type="Animation" id="Animation_wyuub"]
|
[sub_resource type="Animation" id="Animation_wyuub"]
|
||||||
length = 0.001
|
length = 0.001
|
||||||
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("Sprite2D:scale")
|
tracks/0/path = NodePath("Sprite:scale")
|
||||||
tracks/0/interp = 1
|
tracks/0/interp = 1
|
||||||
tracks/0/loop_wrap = true
|
tracks/0/loop_wrap = true
|
||||||
tracks/0/keys = {
|
tracks/0/keys = {
|
||||||
@ -20,7 +26,7 @@ tracks/0/keys = {
|
|||||||
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("Sprite2D:skew")
|
tracks/1/path = NodePath("Sprite:skew")
|
||||||
tracks/1/interp = 1
|
tracks/1/interp = 1
|
||||||
tracks/1/loop_wrap = true
|
tracks/1/loop_wrap = true
|
||||||
tracks/1/keys = {
|
tracks/1/keys = {
|
||||||
@ -32,7 +38,7 @@ tracks/1/keys = {
|
|||||||
tracks/2/type = "value"
|
tracks/2/type = "value"
|
||||||
tracks/2/imported = false
|
tracks/2/imported = false
|
||||||
tracks/2/enabled = true
|
tracks/2/enabled = true
|
||||||
tracks/2/path = NodePath("Sprite2D:modulate")
|
tracks/2/path = NodePath("Sprite:modulate")
|
||||||
tracks/2/interp = 1
|
tracks/2/interp = 1
|
||||||
tracks/2/loop_wrap = true
|
tracks/2/loop_wrap = true
|
||||||
tracks/2/keys = {
|
tracks/2/keys = {
|
||||||
@ -48,7 +54,7 @@ length = 0.5
|
|||||||
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("Sprite2D:scale")
|
tracks/0/path = NodePath("Sprite: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 = {
|
||||||
@ -64,7 +70,7 @@ length = 0.2
|
|||||||
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("Sprite2D:skew")
|
tracks/0/path = NodePath("Sprite:skew")
|
||||||
tracks/0/interp = 2
|
tracks/0/interp = 2
|
||||||
tracks/0/loop_wrap = true
|
tracks/0/loop_wrap = true
|
||||||
tracks/0/keys = {
|
tracks/0/keys = {
|
||||||
@ -76,7 +82,7 @@ tracks/0/keys = {
|
|||||||
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("Sprite2D:modulate")
|
tracks/1/path = NodePath("Sprite:modulate")
|
||||||
tracks/1/interp = 1
|
tracks/1/interp = 1
|
||||||
tracks/1/loop_wrap = true
|
tracks/1/loop_wrap = true
|
||||||
tracks/1/keys = {
|
tracks/1/keys = {
|
||||||
@ -96,9 +102,24 @@ _data = {
|
|||||||
[node name="PlantSprite" type="Node2D"]
|
[node name="PlantSprite" type="Node2D"]
|
||||||
script = ExtResource("1_pq8o7")
|
script = ExtResource("1_pq8o7")
|
||||||
|
|
||||||
[node name="Sprite2D" type="Sprite2D" parent="."]
|
[node name="Sprite" type="Sprite2D" parent="."]
|
||||||
|
unique_name_in_owner = true
|
||||||
scale = Vector2(0.15, 0.15)
|
scale = Vector2(0.15, 0.15)
|
||||||
texture = ExtResource("2_hyinx")
|
texture = ExtResource("2_rbgiq")
|
||||||
|
|
||||||
|
[node name="PlantedSeed" type="Sprite2D" parent="Sprite"]
|
||||||
|
unique_name_in_owner = true
|
||||||
|
scale = Vector2(1.5, 1.5)
|
||||||
|
texture = SubResource("AtlasTexture_wyuub")
|
||||||
|
region_enabled = true
|
||||||
|
region_rect = Rect2(0, -50, 124, 135)
|
||||||
|
region_filter_clip_enabled = true
|
||||||
|
|
||||||
|
[node name="Sprite2D" type="Sprite2D" parent="Sprite/PlantedSeed"]
|
||||||
|
modulate = Color(0.14902, 0.172549, 0.270588, 1)
|
||||||
|
position = Vector2(0, 62.2222)
|
||||||
|
scale = Vector2(0.426047, 0.430108)
|
||||||
|
texture = ExtResource("4_j6jm5")
|
||||||
|
|
||||||
[node name="AnimationPlayer" type="AnimationPlayer" parent="."]
|
[node name="AnimationPlayer" type="AnimationPlayer" parent="."]
|
||||||
libraries = {
|
libraries = {
|
||||||
|
|||||||
32
entities/plants/resources/plant_types/champ.tres
Normal file
@ -0,0 +1,32 @@
|
|||||||
|
[gd_resource type="Resource" script_class="PlantType" load_steps=9 format=3 uid="uid://cxrc5wchpqm18"]
|
||||||
|
|
||||||
|
[ext_resource type="Script" uid="uid://ceqx5va1ormau" path="res://entities/plants/scripts/plant_effects/produce_seeds.gd" id="1_cf34j"]
|
||||||
|
[ext_resource type="Script" uid="uid://jnye5pe1bgqw" path="res://entities/plants/scripts/plant_type.gd" id="1_ipcpv"]
|
||||||
|
[ext_resource type="Texture2D" uid="uid://dmsls8siudy1u" path="res://entities/plants/assets/sprites/champ/growing.png" id="2_l2hi3"]
|
||||||
|
[ext_resource type="Texture2D" uid="uid://crc4aop6ajiau" path="res://entities/plants/assets/sprites/champ/mature.png" id="3_y8qve"]
|
||||||
|
[ext_resource type="Texture2D" uid="uid://btkrinxvownj8" path="res://entities/plants/assets/sprites/champ/planted.png" id="4_w7pob"]
|
||||||
|
[ext_resource type="Texture2D" uid="uid://pltmnkqd5ut2" path="res://entities/plants/assets/sprites/seeds/grille_seeds.png" id="6_liopn"]
|
||||||
|
|
||||||
|
[sub_resource type="Resource" id="Resource_5hyy8"]
|
||||||
|
script = ExtResource("1_cf34j")
|
||||||
|
produce_types_path = Array[String](["uid://cxrc5wchpqm18", "uid://b04vho33bl52b", "uid://dsctivn1vrem2"])
|
||||||
|
produce_number = Array[int]([1, 2])
|
||||||
|
metadata/_custom_type_script = "uid://ceqx5va1ormau"
|
||||||
|
|
||||||
|
[sub_resource type="AtlasTexture" id="AtlasTexture_my6by"]
|
||||||
|
atlas = ExtResource("6_liopn")
|
||||||
|
region = Rect2(610, 315, 124, 180)
|
||||||
|
|
||||||
|
[resource]
|
||||||
|
script = ExtResource("1_ipcpv")
|
||||||
|
name = "Champ"
|
||||||
|
description = "When mature, produce seeds every day."
|
||||||
|
growing_time = 1
|
||||||
|
seed_texture = SubResource("AtlasTexture_my6by")
|
||||||
|
planted_texture = ExtResource("4_w7pob")
|
||||||
|
growing_texture = ExtResource("2_l2hi3")
|
||||||
|
mature_texture = ExtResource("3_y8qve")
|
||||||
|
cyclic_effect = SubResource("Resource_5hyy8")
|
||||||
|
harvest_types_path = Array[String](["uid://cxrc5wchpqm18"])
|
||||||
|
harvest_number = Array[int]([1, 2])
|
||||||
|
metadata/_custom_type_script = "uid://jnye5pe1bgqw"
|
||||||
@ -1,10 +1,10 @@
|
|||||||
[gd_resource type="Resource" script_class="PlantType" load_steps=9 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="Script" uid="uid://jnye5pe1bgqw" 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="Texture2D" uid="uid://c7mp7tkkkk6o5" path="res://entities/plants/assets/sprites/chardi/growing.png" id="1_prk5s"]
|
||||||
[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/chardi/mature.png" id="3_40c3e"]
|
||||||
[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/chardi/planted.png" id="4_ajihu"]
|
||||||
[ext_resource type="Texture2D" uid="uid://pltmnkqd5ut2" path="res://entities/plants/assets/sprites/seeds/grille_seeds.png" id="6_cky1j"]
|
[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"]
|
||||||
@ -22,9 +22,9 @@ name = "Chardi"
|
|||||||
description = "This plant remove a lot of contamination around when it becomes mature."
|
description = "This plant remove a lot of contamination around when it becomes mature."
|
||||||
growing_time = 1
|
growing_time = 1
|
||||||
seed_texture = SubResource("AtlasTexture_qt76e")
|
seed_texture = SubResource("AtlasTexture_qt76e")
|
||||||
planted_texture = ExtResource("4_2s6re")
|
planted_texture = ExtResource("4_ajihu")
|
||||||
growing_texture = ExtResource("1_fp5j6")
|
growing_texture = ExtResource("1_prk5s")
|
||||||
mature_texture = ExtResource("3_ffarr")
|
mature_texture = ExtResource("3_40c3e")
|
||||||
mature_effect = SubResource("Resource_q68uy")
|
mature_effect = SubResource("Resource_q68uy")
|
||||||
harvest_types_path = Array[String]([])
|
harvest_types_path = Array[String]([])
|
||||||
harvest_number = Array[int]([1, 2, 1])
|
harvest_number = Array[int]([1, 2, 1])
|
||||||
@ -19,7 +19,7 @@ region = Rect2(1697, 331, 125, 158)
|
|||||||
[resource]
|
[resource]
|
||||||
script = ExtResource("1_eqtut")
|
script = ExtResource("1_eqtut")
|
||||||
name = "Maias"
|
name = "Maias"
|
||||||
description = "This gorgeous flower produce a lot of seeds."
|
description = "This gorgeous flower produce a lot of seeds when harvested."
|
||||||
growing_time = 1
|
growing_time = 1
|
||||||
seed_texture = SubResource("AtlasTexture_sri3b")
|
seed_texture = SubResource("AtlasTexture_sri3b")
|
||||||
planted_texture = ExtResource("4_iqcy2")
|
planted_texture = ExtResource("4_iqcy2")
|
||||||
|
|||||||
@ -32,17 +32,14 @@ func inspector_info() -> Inspector.Info:
|
|||||||
return Inspector.Info.new(
|
return Inspector.Info.new(
|
||||||
pointer_text(),
|
pointer_text(),
|
||||||
plant_type.description,
|
plant_type.description,
|
||||||
get_state_texture(State.MATURE)
|
plant_type.mature_texture
|
||||||
)
|
)
|
||||||
|
|
||||||
func generate_sprite() -> PlantSprite:
|
func generate_sprite() -> PlantSprite:
|
||||||
var spriteObject : PlantSprite = SPRITE_SCENE.instantiate()
|
var spriteObject : PlantSprite = SPRITE_SCENE.instantiate()
|
||||||
|
|
||||||
add_child(spriteObject)
|
add_child(spriteObject)
|
||||||
spriteObject.apply_texture_to_sprite(
|
spriteObject.update_plant_sprite(self)
|
||||||
get_state_texture(state),
|
|
||||||
false
|
|
||||||
)
|
|
||||||
|
|
||||||
return spriteObject
|
return spriteObject
|
||||||
|
|
||||||
@ -61,6 +58,9 @@ func _pass_day():
|
|||||||
await get_tree().create_timer(randf_range(0., RANDOM_MAX_GROW_INTERVAL)).timeout
|
await get_tree().create_timer(randf_range(0., RANDOM_MAX_GROW_INTERVAL)).timeout
|
||||||
day += 1
|
day += 1
|
||||||
|
|
||||||
|
if state == State.MATURE and plant_type.cyclic_effect:
|
||||||
|
plant_type.cyclic_effect.effect(self)
|
||||||
|
|
||||||
func set_day(d):
|
func set_day(d):
|
||||||
day = d
|
day = d
|
||||||
if day == 0:
|
if day == 0:
|
||||||
@ -78,19 +78,7 @@ func change_state(_state: State):
|
|||||||
if state == State.MATURE and plant_type.mature_effect:
|
if state == State.MATURE and plant_type.mature_effect:
|
||||||
plant_type.mature_effect.effect(self)
|
plant_type.mature_effect.effect(self)
|
||||||
|
|
||||||
plant_sprite.apply_texture_to_sprite(
|
plant_sprite.update_plant_sprite(self, true)
|
||||||
get_state_texture(state)
|
|
||||||
)
|
|
||||||
|
|
||||||
func get_state_texture(s: State) -> Texture2D:
|
|
||||||
match s:
|
|
||||||
State.PLANTED:
|
|
||||||
return plant_type.planted_texture
|
|
||||||
State.GROWING:
|
|
||||||
return plant_type.growing_texture
|
|
||||||
State.MATURE:
|
|
||||||
return plant_type.mature_texture
|
|
||||||
return null
|
|
||||||
|
|
||||||
func harvest():
|
func harvest():
|
||||||
if state == State.MATURE:
|
if state == State.MATURE:
|
||||||
@ -99,8 +87,15 @@ func harvest():
|
|||||||
var seed_plant_type : PlantType = plant_type
|
var seed_plant_type : PlantType = plant_type
|
||||||
if len(plant_type.harvest_types_path):
|
if len(plant_type.harvest_types_path):
|
||||||
seed_plant_type = load(plant_type.harvest_types_path.pick_random())
|
seed_plant_type = load(plant_type.harvest_types_path.pick_random())
|
||||||
|
loot_seed(seed_plant_type)
|
||||||
|
|
||||||
|
plant_sprite.start_harvest_animation()
|
||||||
|
await plant_sprite.harvest_animation_finished
|
||||||
|
queue_free()
|
||||||
|
|
||||||
|
func loot_seed(type : PlantType):
|
||||||
var item_object = planet.drop_item(
|
var item_object = planet.drop_item(
|
||||||
Seed.new(seed_plant_type),
|
Seed.new(type),
|
||||||
global_position
|
global_position
|
||||||
)
|
)
|
||||||
var tween : Tween = get_tree().create_tween()
|
var tween : Tween = get_tree().create_tween()
|
||||||
@ -113,7 +108,3 @@ func harvest():
|
|||||||
),
|
),
|
||||||
0.2
|
0.2
|
||||||
)
|
)
|
||||||
|
|
||||||
plant_sprite.start_harvest_animation()
|
|
||||||
await plant_sprite.harvest_animation_finished
|
|
||||||
queue_free()
|
|
||||||
|
|||||||
11
entities/plants/scripts/plant_effects/produce_seeds.gd
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
extends PlantEffect
|
||||||
|
class_name ProduceSeedsEffect
|
||||||
|
|
||||||
|
@export_file var produce_types_path : Array[String] = []
|
||||||
|
@export var produce_number : Array[int] = [1]
|
||||||
|
|
||||||
|
func effect(plant):
|
||||||
|
for _i in range(produce_number.pick_random()):
|
||||||
|
if len(produce_types_path):
|
||||||
|
var seed_plant_type = load(produce_types_path.pick_random())
|
||||||
|
plant.loot_seed(seed_plant_type)
|
||||||
@ -0,0 +1 @@
|
|||||||
|
uid://ceqx5va1ormau
|
||||||
@ -1,16 +1,40 @@
|
|||||||
extends Node2D
|
extends Node2D
|
||||||
class_name PlantSprite
|
class_name PlantSprite
|
||||||
|
|
||||||
|
const PLANTED_SEED_CROP_WIDTH = 50
|
||||||
|
const PLANTED_SEED_POS_Y = -50
|
||||||
|
|
||||||
signal harvest_animation_finished
|
signal harvest_animation_finished
|
||||||
|
|
||||||
@onready var sprite = $Sprite2D
|
func update_plant_sprite(plant : Plant, with_animation = false):
|
||||||
|
|
||||||
func apply_texture_to_sprite(texture, with_animation = true):
|
|
||||||
if with_animation:
|
if with_animation:
|
||||||
$AnimationPlayer.play("bump")
|
$AnimationPlayer.play("bump")
|
||||||
await $AnimationPlayer.animation_finished
|
await $AnimationPlayer.animation_finished
|
||||||
sprite.texture = texture
|
|
||||||
sprite.flip_h = true if randi()%2 == 0 else false
|
%Sprite.flip_h = true if randi()%2 == 0 else false
|
||||||
|
|
||||||
|
%Sprite.texture = get_state_texture(plant.state, plant.plant_type)
|
||||||
|
|
||||||
|
%PlantedSeed.visible = plant.state == Plant.State.PLANTED
|
||||||
|
%PlantedSeed.texture = plant.plant_type.seed_texture
|
||||||
|
|
||||||
|
%PlantedSeed.region_rect = Rect2(
|
||||||
|
0,
|
||||||
|
PLANTED_SEED_POS_Y,
|
||||||
|
plant.plant_type.seed_texture.get_width(),
|
||||||
|
plant.plant_type.seed_texture.get_height() - PLANTED_SEED_CROP_WIDTH + -1 * PLANTED_SEED_POS_Y,
|
||||||
|
)
|
||||||
|
|
||||||
|
func get_state_texture(s: Plant.State, plant_type : PlantType) -> Texture2D:
|
||||||
|
match s:
|
||||||
|
Plant.State.PLANTED:
|
||||||
|
return null
|
||||||
|
Plant.State.GROWING:
|
||||||
|
return plant_type.growing_texture
|
||||||
|
Plant.State.MATURE:
|
||||||
|
return plant_type.mature_texture
|
||||||
|
return null
|
||||||
|
|
||||||
|
|
||||||
func start_harvest_animation():
|
func start_harvest_animation():
|
||||||
$AnimationPlayer.play("harvest")
|
$AnimationPlayer.play("harvest")
|
||||||
|
|||||||
@ -7,11 +7,11 @@ class_name PlantType
|
|||||||
@export var growing_time : int
|
@export var growing_time : int
|
||||||
|
|
||||||
@export var seed_texture : Texture
|
@export var seed_texture : Texture
|
||||||
@export var planted_texture : Texture
|
|
||||||
@export var growing_texture : Texture
|
@export var growing_texture : Texture
|
||||||
@export var mature_texture : Texture
|
@export var mature_texture : Texture
|
||||||
|
|
||||||
@export var mature_effect : PlantEffect
|
@export var mature_effect : PlantEffect
|
||||||
|
@export var cyclic_effect : PlantEffect
|
||||||
|
|
||||||
@export_file var harvest_types_path : Array[String] = []
|
@export_file var harvest_types_path : Array[String] = []
|
||||||
@export var harvest_number : Array[int] = [1,2]
|
@export var harvest_number : Array[int] = [1,2]
|
||||||
|
|||||||
21
game.tscn
@ -1,4 +1,4 @@
|
|||||||
[gd_scene load_steps=21 format=3 uid="uid://d28cp7a21kwou"]
|
[gd_scene load_steps=24 format=3 uid="uid://d28cp7a21kwou"]
|
||||||
|
|
||||||
[ext_resource type="PackedScene" uid="uid://12nak7amd1uq" path="res://gui/game/game_gui.tscn" id="1_iotsf"]
|
[ext_resource type="PackedScene" uid="uid://12nak7amd1uq" path="res://gui/game/game_gui.tscn" id="1_iotsf"]
|
||||||
[ext_resource type="PackedScene" uid="uid://csiacsndm62ll" path="res://gui/game/pause/pause.tscn" id="2_215e1"]
|
[ext_resource type="PackedScene" uid="uid://csiacsndm62ll" path="res://gui/game/pause/pause.tscn" id="2_215e1"]
|
||||||
@ -11,10 +11,11 @@
|
|||||||
[ext_resource type="Script" uid="uid://bq7admu4ahs5r" path="res://common/inventory/scripts/item.gd" id="7_rvswv"]
|
[ext_resource type="Script" uid="uid://bq7admu4ahs5r" path="res://common/inventory/scripts/item.gd" id="7_rvswv"]
|
||||||
[ext_resource type="PackedScene" uid="uid://d324mlmgls4fs" path="res://entities/interactables/machines/recharge_station/recharge_station.tscn" id="8_7sc4i"]
|
[ext_resource type="PackedScene" uid="uid://d324mlmgls4fs" path="res://entities/interactables/machines/recharge_station/recharge_station.tscn" id="8_7sc4i"]
|
||||||
[ext_resource type="Texture2D" uid="uid://pltmnkqd5ut2" path="res://entities/plants/assets/sprites/seeds/grille_seeds.png" id="8_boyg6"]
|
[ext_resource type="Texture2D" uid="uid://pltmnkqd5ut2" path="res://entities/plants/assets/sprites/seeds/grille_seeds.png" id="8_boyg6"]
|
||||||
[ext_resource type="Resource" uid="uid://b04vho33bl52b" path="res://entities/plants/resources/plant_types/default.tres" id="9_e36ub"]
|
[ext_resource type="Resource" uid="uid://b04vho33bl52b" path="res://entities/plants/resources/plant_types/chardi.tres" id="9_e36ub"]
|
||||||
[ext_resource type="Script" uid="uid://bypjcvlc15gsm" path="res://common/inventory/scripts/items/seed.gd" id="10_hb5m1"]
|
[ext_resource type="Script" uid="uid://bypjcvlc15gsm" path="res://common/inventory/scripts/items/seed.gd" id="10_hb5m1"]
|
||||||
[ext_resource type="Resource" uid="uid://dsctivn1vrem2" path="res://entities/plants/resources/plant_types/maias.tres" id="11_x5p1p"]
|
[ext_resource type="Resource" uid="uid://dsctivn1vrem2" path="res://entities/plants/resources/plant_types/maias.tres" id="11_x5p1p"]
|
||||||
[ext_resource type="PackedScene" uid="uid://dj7gp3crtg2yt" path="res://entities/camera/camera.tscn" id="12_qhcbd"]
|
[ext_resource type="PackedScene" uid="uid://dj7gp3crtg2yt" path="res://entities/camera/camera.tscn" id="12_qhcbd"]
|
||||||
|
[ext_resource type="Resource" uid="uid://cxrc5wchpqm18" path="res://entities/plants/resources/plant_types/champ.tres" id="15_80cx4"]
|
||||||
|
|
||||||
[sub_resource type="AtlasTexture" id="AtlasTexture_qt76e"]
|
[sub_resource type="AtlasTexture" id="AtlasTexture_qt76e"]
|
||||||
atlas = ExtResource("8_boyg6")
|
atlas = ExtResource("8_boyg6")
|
||||||
@ -54,6 +55,20 @@ use_zone_radius = 5
|
|||||||
use_energy = 1
|
use_energy = 1
|
||||||
metadata/_custom_type_script = "uid://bypjcvlc15gsm"
|
metadata/_custom_type_script = "uid://bypjcvlc15gsm"
|
||||||
|
|
||||||
|
[sub_resource type="AtlasTexture" id="AtlasTexture_my6by"]
|
||||||
|
atlas = ExtResource("8_boyg6")
|
||||||
|
region = Rect2(610, 315, 124, 180)
|
||||||
|
|
||||||
|
[sub_resource type="Resource" id="Resource_rvswv"]
|
||||||
|
script = ExtResource("10_hb5m1")
|
||||||
|
plant_type = ExtResource("15_80cx4")
|
||||||
|
name = "Champ"
|
||||||
|
description = "When mature, produce a seed every day"
|
||||||
|
icon = SubResource("AtlasTexture_my6by")
|
||||||
|
use_zone_radius = 5
|
||||||
|
use_energy = 1
|
||||||
|
metadata/_custom_type_script = "uid://bypjcvlc15gsm"
|
||||||
|
|
||||||
[node name="Game" type="Node2D"]
|
[node name="Game" type="Node2D"]
|
||||||
|
|
||||||
[node name="CanvasLayer" type="CanvasLayer" parent="."]
|
[node name="CanvasLayer" type="CanvasLayer" parent="."]
|
||||||
@ -90,7 +105,7 @@ metadata/_custom_type_script = "uid://dedg615xudpoq"
|
|||||||
position = Vector2(-1, -217)
|
position = Vector2(-1, -217)
|
||||||
|
|
||||||
[node name="Planet" parent="." node_paths=PackedStringArray("import_entities_from_node") instance=ExtResource("6_e8heu")]
|
[node name="Planet" parent="." node_paths=PackedStringArray("import_entities_from_node") instance=ExtResource("6_e8heu")]
|
||||||
loot_items = Array[ExtResource("7_rvswv")]([SubResource("Resource_7sc4i"), SubResource("Resource_80cx4"), SubResource("Resource_e8heu")])
|
loot_items = Array[ExtResource("7_rvswv")]([SubResource("Resource_7sc4i"), SubResource("Resource_80cx4"), SubResource("Resource_e8heu"), SubResource("Resource_rvswv")])
|
||||||
import_entities_from_node = NodePath("../Entities")
|
import_entities_from_node = NodePath("../Entities")
|
||||||
|
|
||||||
[node name="Camera" parent="." node_paths=PackedStringArray("following") instance=ExtResource("12_qhcbd")]
|
[node name="Camera" parent="." node_paths=PackedStringArray("following") instance=ExtResource("12_qhcbd")]
|
||||||
|
|||||||