CONTENT
This commit is contained in:
@@ -15,18 +15,20 @@ signal died
|
||||
|
||||
const NEED_CHECK_PERIOD := 0.5
|
||||
const SAPLING_LIFETIME_MULT := 2.0 # this multiplies the time to grow to tell the time it can stay as a sapling
|
||||
const OFFSET_REPRODUCTION_PERCT_DIST := 0.5
|
||||
const OFFSET_REPRODUCTION_PERCT_DIST := 0.1
|
||||
|
||||
var parameter: PlantType
|
||||
var state := PlantState.SAPLING
|
||||
var sapling_time_left: float
|
||||
var can_grow := true
|
||||
var n_offsprings_left: int
|
||||
|
||||
func init(plant_parameter: PlantType):
|
||||
parameter = plant_parameter
|
||||
sapling_count_down.start(SAPLING_LIFETIME_MULT * parameter.growing_time)
|
||||
sprite_node.sprite_frames = parameter.sprite_frames
|
||||
need_checker.start(NEED_CHECK_PERIOD)
|
||||
n_offsprings_left = parameter.offspring_per_lifetime
|
||||
|
||||
|
||||
func _on_need_checker_timeout() -> void:
|
||||
@@ -96,7 +98,7 @@ func grow():
|
||||
GameTerrain.Stats.PRESENCE,
|
||||
parameter.presence_prod)
|
||||
|
||||
reproduction.start(parameter.dying_time / (parameter.offspring_per_lifetime + 1) + 0.1)
|
||||
reproduction.start(parameter.dying_time / (n_offsprings_left + 1))
|
||||
|
||||
grown.emit()
|
||||
sprite_node.play("GROWN")
|
||||
@@ -160,3 +162,7 @@ func _on_reproduction_timeout() -> void:
|
||||
self.get_parent().add_child(offspring)
|
||||
offspring.init(parameter)
|
||||
offspring.plant(plant_pos)
|
||||
n_offsprings_left -= 1
|
||||
reproduction.start(parameter.dying_time / (n_offsprings_left + 1))
|
||||
if n_offsprings_left == 0:
|
||||
reproduction.stop()
|
||||
|
||||
@@ -54,6 +54,8 @@ func _unhandled_input(_event: InputEvent) -> void:
|
||||
var next_plant := plants[seed_queue.back()]
|
||||
robot_seed.texture = next_plant.seed_sprite
|
||||
robot.go_to(mouse_pos)
|
||||
if Input.is_action_just_pressed("discard_seed") :
|
||||
take_next_seed()
|
||||
|
||||
|
||||
func _on_robot_planted() -> void:
|
||||
|
||||
Reference in New Issue
Block a user