ajout de la porte et équilibrage des mutations
This commit is contained in:
@@ -3,6 +3,7 @@ class_name PlantData
|
||||
|
||||
signal updated(p: PlantData)
|
||||
signal disappeared(p: PlantData)
|
||||
signal nearby_plant_updated()
|
||||
|
||||
enum State {PLANTED, GROWING, MATURE, DEAD}
|
||||
|
||||
@@ -20,6 +21,8 @@ enum State {PLANTED, GROWING, MATURE, DEAD}
|
||||
|
||||
# var texture_builder: TextureBuilder = preload("res://entities/plants/scripts/texture_builder/texture_builder.tres")
|
||||
|
||||
var nearby_plants : Array[PlantData]
|
||||
|
||||
func _init(
|
||||
_position: Vector2 = Vector2.ZERO,
|
||||
_archetype: PlantArchetype = PlantArchetype.get_random(),
|
||||
@@ -57,7 +60,10 @@ func get_lifetime() -> int:
|
||||
|
||||
for m in mutations:
|
||||
lifetime = m.mutate_lifetime(self , lifetime)
|
||||
|
||||
|
||||
for pd in nearby_plants:
|
||||
lifetime += pd.get_lifetime_buff()
|
||||
|
||||
return lifetime
|
||||
|
||||
func get_growing_time() -> int:
|
||||
@@ -84,16 +90,22 @@ func get_state() -> State:
|
||||
return State.DEAD
|
||||
elif day == 0:
|
||||
return State.PLANTED
|
||||
elif day < archetype.growing_time:
|
||||
elif day < get_growing_time():
|
||||
return State.GROWING
|
||||
return State.MATURE
|
||||
|
||||
func is_mature() -> bool:
|
||||
return get_state() == State.MATURE
|
||||
|
||||
func get_seed_number(state = get_state()):
|
||||
var seed_number = archetype.seed_number if (state == State.MATURE or state == State.DEAD) else 0
|
||||
|
||||
for m in mutations:
|
||||
seed_number = m.mutate_seed_number(self , seed_number)
|
||||
|
||||
for pd in nearby_plants:
|
||||
seed_number += pd.get_seed_buff()
|
||||
|
||||
return seed_number
|
||||
|
||||
func get_seed_random_loose():
|
||||
@@ -109,5 +121,21 @@ func get_random_seed_income():
|
||||
0
|
||||
)
|
||||
|
||||
func get_lifetime_buff() -> int:
|
||||
var buff = 0
|
||||
|
||||
for m in mutations:
|
||||
buff += m.mutate_lifetime_buff(self)
|
||||
|
||||
return buff
|
||||
|
||||
func get_seed_buff() -> int:
|
||||
var buff = 0
|
||||
|
||||
for m in mutations:
|
||||
buff += m.mutate_seed_buff(self)
|
||||
|
||||
return buff
|
||||
|
||||
func disappear():
|
||||
disappeared.emit(self )
|
||||
|
||||
Reference in New Issue
Block a user