Ajout des mutations Sauveteuse, Adaptative et résistante, ajout des crédits du jeu et d'un splash screen (+ un peu de debug)
This commit is contained in:
@@ -11,7 +11,9 @@ func update():
|
||||
else Color.RED )
|
||||
%EnergyText.text = str(region.data.charges)
|
||||
if not region.data.pass_day_ended.is_connected(update):
|
||||
region.data.pass_day_ended.connect(update)
|
||||
region.data.pass_day_ended.connect(
|
||||
func (_data): update()
|
||||
)
|
||||
|
||||
func can_interact(_p : Player) -> bool:
|
||||
return (
|
||||
|
||||
@@ -131,11 +131,9 @@ func harvest():
|
||||
if do_produce_seeds:
|
||||
for i in range(data.get_seed_number()):
|
||||
await produce_seed()
|
||||
|
||||
if data.get_state() == PlantData.State.MATURE:
|
||||
for m in data.mutations:
|
||||
m._start_harvested_effect(self)
|
||||
|
||||
harvested = true
|
||||
|
||||
plant_sprite.start_harvest_animation()
|
||||
|
||||
@@ -17,6 +17,7 @@ enum State {PLANTED, GROWING, MATURE, DEAD}
|
||||
|
||||
var decontamination_area_factor = 0.
|
||||
var nearby_plants : Array[PlantData]
|
||||
var region_data : RegionData
|
||||
|
||||
func _init(
|
||||
_position: Vector2 = Vector2.ZERO,
|
||||
@@ -149,7 +150,14 @@ func get_score_buff() -> int:
|
||||
buff = m.mutate_score_buff(self, buff)
|
||||
|
||||
return buff
|
||||
|
||||
func get_mutation_probability_boost() -> float:
|
||||
var boost = 0
|
||||
|
||||
for m in mutations:
|
||||
boost = m.mutate_mutation_probability_boost(self, boost)
|
||||
|
||||
return boost
|
||||
|
||||
func disappear():
|
||||
disappeared.emit(self )
|
||||
|
||||
@@ -18,6 +18,9 @@ func get_icon() -> Texture:
|
||||
func get_base_rarity() -> int:
|
||||
return 0
|
||||
|
||||
func get_max_rarity() -> int:
|
||||
return MAX_RARITY
|
||||
|
||||
@abstract func get_mutation_id() -> String
|
||||
|
||||
func get_mutation_name() -> String:
|
||||
@@ -31,6 +34,9 @@ func mutate_plant_data(_plant_data: PlantData):
|
||||
func nullify_score(_plant_data: PlantData) -> bool:
|
||||
return false
|
||||
|
||||
func allow_planting_on_decontamined_terrain(_seed : Seed) -> bool:
|
||||
return false
|
||||
|
||||
func mutate_score(_plant_data: PlantData, score: int) -> int:
|
||||
return score
|
||||
|
||||
@@ -61,6 +67,9 @@ func mutate_seed_buff(_plant_data: PlantData, seed_buff : int) -> int:
|
||||
func mutate_score_buff(_plant_data: PlantData, score_buff : int) -> int:
|
||||
return score_buff
|
||||
|
||||
func mutate_mutation_probability_boost(_plant_data: PlantData, mutation_probability_boost : int) -> float:
|
||||
return mutation_probability_boost
|
||||
|
||||
func _start_planted_effect(_plant: Plant):
|
||||
pass
|
||||
|
||||
@@ -83,7 +92,7 @@ func get_rarity() -> int:
|
||||
return get_base_rarity() + level - 1
|
||||
|
||||
func is_max_level() -> bool:
|
||||
return get_base_rarity() + level < MAX_RARITY
|
||||
return get_base_rarity() + level < get_max_rarity()
|
||||
|
||||
func card_info() -> CardInfo:
|
||||
var info = CardInfo.new(
|
||||
|
||||
@@ -0,0 +1,19 @@
|
||||
extends PlantMutation
|
||||
class_name AdaptiveMutation
|
||||
|
||||
func get_icon() -> Texture:
|
||||
return preload("res://common/icons/dna.svg")
|
||||
|
||||
func get_mutation_id() -> String:
|
||||
return "ADAPTIVE"
|
||||
|
||||
func get_base_rarity() -> int:
|
||||
return 0
|
||||
|
||||
func get_mutation_description() -> String:
|
||||
return tr("ADAPTIVE_EFFECT_TEXT").format({
|
||||
"mutation_probability_boost": get_mutation_probability_boost(),
|
||||
})
|
||||
|
||||
func get_mutation_probability_boost()->float:
|
||||
return level * 0.05
|
||||
@@ -0,0 +1 @@
|
||||
uid://blwkliqwgqs32
|
||||
@@ -21,5 +21,5 @@ func mutate_score_multiplier(plant_data: PlantData, multiplier: float) -> float:
|
||||
return multiplier + get_score_multiplier()
|
||||
return multiplier
|
||||
|
||||
func get_score_multiplier()->int:
|
||||
return level
|
||||
func get_score_multiplier()->float:
|
||||
return 0.5 * level
|
||||
|
||||
@@ -0,0 +1,20 @@
|
||||
extends PlantMutation
|
||||
class_name ResistantMutation
|
||||
|
||||
func get_icon() -> Texture:
|
||||
return preload("res://common/icons/radioactive.svg")
|
||||
|
||||
func get_mutation_id() -> String:
|
||||
return "RESISTANT"
|
||||
|
||||
func get_base_rarity() -> int:
|
||||
return 0
|
||||
|
||||
func get_mutation_description() -> String:
|
||||
return tr("RESISTANT_EFFECT_TEXT")
|
||||
|
||||
func is_max_level() -> bool:
|
||||
return true
|
||||
|
||||
func allow_planting_on_decontamined_terrain(_seed : Seed) -> bool:
|
||||
return true
|
||||
@@ -0,0 +1 @@
|
||||
uid://dfuknjnoo1fp8
|
||||
@@ -0,0 +1,25 @@
|
||||
extends PlantMutation
|
||||
class_name SaviorMutation
|
||||
|
||||
func get_icon() -> Texture:
|
||||
return preload("res://common/icons/lifebuoy.svg")
|
||||
|
||||
func get_mutation_id() -> String:
|
||||
return "SAVIOR"
|
||||
|
||||
func get_base_rarity() -> int:
|
||||
return 0
|
||||
|
||||
func get_mutation_description() -> String:
|
||||
return tr("SAVIOR_EFFECT_TEXT").format({
|
||||
"score_icon": Text.bbcode_icon(Plant.SCORE_ICON),
|
||||
"score_multiplier": get_score_multiplier() + 1,
|
||||
})
|
||||
|
||||
func mutate_score_multiplier(plant_data: PlantData, multiplier: float) -> float:
|
||||
if plant_data.region_data and plant_data.region_data.charges == 0:
|
||||
return multiplier + get_score_multiplier()
|
||||
return multiplier
|
||||
|
||||
func get_score_multiplier()->float:
|
||||
return 0.5 * level
|
||||
@@ -0,0 +1 @@
|
||||
uid://dn1qruq8wu8y7
|
||||
@@ -5,7 +5,7 @@ func get_icon() -> Texture:
|
||||
return preload("res://common/icons/sparkles.svg")
|
||||
|
||||
func get_base_rarity() -> int:
|
||||
return 0
|
||||
return 1
|
||||
|
||||
func is_max_level() -> bool:
|
||||
return true
|
||||
|
||||
@@ -19,7 +19,10 @@ func _init(
|
||||
|
||||
static func generate_from_parent(plant_data : PlantData, nearby_plants : Array[PlantData] = []) -> Seed:
|
||||
var mutations : Array[PlantMutation] = plant_data.mutations
|
||||
var mutation_probability = GameInfo.game_data.current_run.plant_info.get_mutation_probability()
|
||||
var mutation_probability = (
|
||||
GameInfo.game_data.current_run.plant_info.get_mutation_probability()
|
||||
+ plant_data.get_mutation_probability_boost()
|
||||
)
|
||||
|
||||
var nearby_mutations : Array[PlantMutation] = []
|
||||
for pd in nearby_plants:
|
||||
@@ -107,9 +110,15 @@ func can_use(player : Player, zone : Player.ActionZone) -> bool:
|
||||
zone.get_global_position(),
|
||||
)] as Array[Vector2i]
|
||||
|
||||
var is_decontaminated = player.region.is_coords_decontaminated(plant_tiles)
|
||||
|
||||
for m in plant_mutations:
|
||||
if m.allow_planting_on_decontamined_terrain(self):
|
||||
is_decontaminated = true
|
||||
|
||||
return (
|
||||
not is_there_a_plant_here
|
||||
and player.region.is_coords_decontaminated(plant_tiles)
|
||||
and is_decontaminated
|
||||
and not player.region.is_coords_rocky(plant_tiles)
|
||||
)
|
||||
|
||||
@@ -178,11 +187,12 @@ static func generate_first_mutations(rarity := 0) -> Array[PlantMutation]:
|
||||
if rarity < 0:
|
||||
return []
|
||||
|
||||
var possible_mutation : PlantMutation = GameInfo.game_data.progression_data.get_available_mutations().filter(
|
||||
var possible_mutations : Array[PlantMutation] = GameInfo.game_data.progression_data.get_available_mutations().filter(
|
||||
func (m : PlantMutation): return m.get_base_rarity() <= rarity
|
||||
).pick_random()
|
||||
)
|
||||
|
||||
if possible_mutation:
|
||||
if len(possible_mutations):
|
||||
var possible_mutation = possible_mutations.pick_random()
|
||||
possible_mutation = possible_mutation.duplicate_deep()
|
||||
|
||||
var level_to_add = rarity - possible_mutation.get_base_rarity()
|
||||
@@ -197,9 +207,11 @@ static func mutate_mutations(mutations : Array[PlantMutation], nearby_mutations
|
||||
var mutation_possibility : Array[MutationPossibility] = []
|
||||
|
||||
var evolvable_mutations : Array[PlantMutation] = mutations.filter(
|
||||
func (m : PlantMutation): return not m.is_max_level()
|
||||
func (m : PlantMutation):
|
||||
return not m.is_max_level()
|
||||
)
|
||||
|
||||
|
||||
if (
|
||||
len(mutations) < GameInfo.game_data.current_run.plant_info.get_mutation_max_number()
|
||||
):
|
||||
@@ -208,9 +220,12 @@ static func mutate_mutations(mutations : Array[PlantMutation], nearby_mutations
|
||||
if len(evolvable_mutations) > 0:
|
||||
mutation_possibility.append(UpgradeMutation.new())
|
||||
|
||||
var chosen_mutation_possibility = mutation_possibility.pick_random()
|
||||
|
||||
return chosen_mutation_possibility.mutate(mutations,nearby_mutations)
|
||||
if len(mutation_possibility) > 0:
|
||||
var chosen_mutation_possibility = mutation_possibility.pick_random()
|
||||
return chosen_mutation_possibility.mutate(mutations,nearby_mutations)
|
||||
else:
|
||||
print_debug("No mutation possility available")
|
||||
return mutations
|
||||
|
||||
class MutationPossibility:
|
||||
func mutate(_mutations : Array[PlantMutation], _nearby_mutations : Array[PlantMutation])-> Array[PlantMutation]:
|
||||
@@ -229,13 +244,16 @@ class AddMutation extends MutationPossibility:
|
||||
return mutations.find_custom(func(m2: PlantMutation): return m2.id == m.id) == -1
|
||||
)
|
||||
|
||||
var nearby_impacted_possible_new_mutations : Array[PlantMutation] = []
|
||||
|
||||
for m1 in possible_new_mutations:
|
||||
nearby_impacted_possible_new_mutations.append(m1)
|
||||
for m2 in nearby_mutations:
|
||||
if m1.id == m2.id:
|
||||
possible_new_mutations.append(m1) # Double les chances d'avoir la mutation si elle est présente dans les voisins
|
||||
nearby_impacted_possible_new_mutations.append(m1) # Double les chances d'avoir la mutation si elle est présente dans les voisins
|
||||
|
||||
if len(possible_new_mutations):
|
||||
new_mutations.append(possible_new_mutations.pick_random())
|
||||
if len(nearby_impacted_possible_new_mutations):
|
||||
new_mutations.append(nearby_impacted_possible_new_mutations.pick_random())
|
||||
|
||||
return new_mutations
|
||||
|
||||
@@ -250,7 +268,7 @@ class UpgradeMutation extends MutationPossibility:
|
||||
|
||||
for i in range(len(mutations)):
|
||||
var m = mutations[i]
|
||||
if m.get_rarity() < PlantMutation.MAX_RARITY:
|
||||
if not m.is_max_level():
|
||||
evolvable_mutations_id.append(i)
|
||||
|
||||
if len(evolvable_mutations_id):
|
||||
|
||||
@@ -115,9 +115,6 @@ func _process(delta):
|
||||
elif velocity != Vector2.ZERO and %MovementAudioStreamPlayer.playing == false:
|
||||
%MovementAudioStreamPlayer.play()
|
||||
|
||||
# print("-----")
|
||||
# print(elapsed_time)
|
||||
# print(last_just_dropped_item_objects_updated)
|
||||
if elapsed_time > last_just_dropped_item_objects_updated + JUST_DROPPED_ITEM_UPDATE_INTERVAL:
|
||||
update_just_dropped_item_objects()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user