ajout de la plant champ et suppression de la texture planted (ajout de la graine à la place) #55
This commit is contained in:
@@ -32,17 +32,14 @@ func inspector_info() -> Inspector.Info:
|
||||
return Inspector.Info.new(
|
||||
pointer_text(),
|
||||
plant_type.description,
|
||||
get_state_texture(State.MATURE)
|
||||
plant_type.mature_texture
|
||||
)
|
||||
|
||||
func generate_sprite() -> PlantSprite:
|
||||
var spriteObject : PlantSprite = SPRITE_SCENE.instantiate()
|
||||
|
||||
add_child(spriteObject)
|
||||
spriteObject.apply_texture_to_sprite(
|
||||
get_state_texture(state),
|
||||
false
|
||||
)
|
||||
spriteObject.update_plant_sprite(self)
|
||||
|
||||
return spriteObject
|
||||
|
||||
@@ -61,6 +58,9 @@ func _pass_day():
|
||||
await get_tree().create_timer(randf_range(0., RANDOM_MAX_GROW_INTERVAL)).timeout
|
||||
day += 1
|
||||
|
||||
if state == State.MATURE and plant_type.cyclic_effect:
|
||||
plant_type.cyclic_effect.effect(self)
|
||||
|
||||
func set_day(d):
|
||||
day = d
|
||||
if day == 0:
|
||||
@@ -78,19 +78,7 @@ func change_state(_state: State):
|
||||
if state == State.MATURE and plant_type.mature_effect:
|
||||
plant_type.mature_effect.effect(self)
|
||||
|
||||
plant_sprite.apply_texture_to_sprite(
|
||||
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
|
||||
plant_sprite.update_plant_sprite(self, true)
|
||||
|
||||
func harvest():
|
||||
if state == State.MATURE:
|
||||
@@ -99,21 +87,24 @@ func harvest():
|
||||
var seed_plant_type : PlantType = plant_type
|
||||
if len(plant_type.harvest_types_path):
|
||||
seed_plant_type = load(plant_type.harvest_types_path.pick_random())
|
||||
var item_object = planet.drop_item(
|
||||
Seed.new(seed_plant_type),
|
||||
global_position
|
||||
)
|
||||
var tween : Tween = get_tree().create_tween()
|
||||
tween.tween_property(
|
||||
item_object,
|
||||
"position",
|
||||
Vector2(
|
||||
item_object.position.x + randi()%HARVESTED_SEED_POSITION_RANGE,
|
||||
item_object.position.y + randi()%HARVESTED_SEED_POSITION_RANGE
|
||||
),
|
||||
0.2
|
||||
)
|
||||
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(
|
||||
Seed.new(type),
|
||||
global_position
|
||||
)
|
||||
var tween : Tween = get_tree().create_tween()
|
||||
tween.tween_property(
|
||||
item_object,
|
||||
"position",
|
||||
Vector2(
|
||||
item_object.position.x + randi()%HARVESTED_SEED_POSITION_RANGE,
|
||||
item_object.position.y + randi()%HARVESTED_SEED_POSITION_RANGE
|
||||
),
|
||||
0.2
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user