* Modification de l'apparence de l'UI des dialogues * Changement de l'ordre de déblocage des mutations * Ajout d'une confirmation pour l'abandon * Ajout de la scène de fin avec la base Boréa, en tant que fin de démo * Modification des icône de durée de vie, temps de pousse, et de mort * Ajout d'un icône au dessus du joueur quand il n'a plus d'énergie * Amélioration des dialogues du jeu * Changement du modèle du téléphone * Ajout de cellule d'énergie et de cellule de talion trouvable sur la carte * Il est à nouveau possible de se recharger après la fin d'une région * Buff des mutations ancien sociale et solide * Modification de la mutation fertile (ne donne de gain de graine qu'à la maturation) * Ajout d'une récupération automatique des graines * Ajout de deux cartons de tutoriel ainsi qu'une option pour les revoir dans l'aide de jeu * Amélioration générale du tutoriel * Ajout d'un écran titre digne de ce nom * Lors de l'arrivée à destination, ne téléporte plus le joueur sur une map vide, mais directement dans les lieux de cinématique * Ajout graphique de plus de pattern de mousse et de roche * Le talion apparait maintenant sur toute la carte * La roche peut désormais apparaitre sur la zone de départ * Ajout dud modificateur de région Canyon * Equilibrage général * Fix de bugs en tout genre
174 lines
5.6 KiB
GDScript
174 lines
5.6 KiB
GDScript
extends CanvasLayer
|
|
class_name GameGui
|
|
|
|
const SCORE_ICON : Texture = preload("res://common/icons/growth.svg")
|
|
|
|
var score_by_plant : Dictionary[String, int] = {}
|
|
|
|
var score_mirror :
|
|
set(v):
|
|
score_mirror = v
|
|
score_update(true)
|
|
|
|
var objective_text : String = "" : set = set_objective_text
|
|
|
|
@onready var help : Help = %Help
|
|
|
|
func _ready():
|
|
GameInfo.game_data.current_region_data.updated.connect(_on_region_updated)
|
|
GameInfo.game_data.player_data.updated.connect(_on_player_updated)
|
|
|
|
show_progress_bar()
|
|
show_energy()
|
|
show_help()
|
|
|
|
state_update(GameInfo.game_data.current_region_data)
|
|
player_update(GameInfo.game_data.player_data, false)
|
|
%EnergyInfo.reset_size()
|
|
|
|
score_mirror = GameInfo.game_data.current_region_data.get_score()
|
|
for p : PlantData in GameInfo.game_data.current_region_data.plants:
|
|
score_by_plant[str(p.random_seed)] = p.get_score()
|
|
set_objective_text()
|
|
|
|
func _on_player_updated(player_data : PlayerData):
|
|
player_update(player_data)
|
|
|
|
func player_update(player_data : PlayerData, with_animation = true):
|
|
%EnergyInfo.update(
|
|
player_data.energy,
|
|
player_data.max_energy,
|
|
with_animation
|
|
)
|
|
if with_animation:
|
|
get_tree().create_tween().tween_property(
|
|
%NoEnergyVignette,
|
|
"modulate:a",
|
|
1. if player_data.energy == 0 else 0.,
|
|
0.3
|
|
)
|
|
else:
|
|
%NoEnergyVignette.modulate.a = 1. if player_data.energy == 0 else 0.
|
|
|
|
func _on_region_updated(region_data : RegionData):
|
|
await get_tree().create_timer(0.1).timeout
|
|
if score_mirror != region_data.get_score():
|
|
for p in region_data.plants:
|
|
var score = p.get_score()
|
|
if not str(p.random_seed) in score_by_plant:
|
|
score_by_plant[str(p.random_seed)] = 0
|
|
if score > score_by_plant[str(p.random_seed)]:
|
|
plant_changing_score(p, score - score_by_plant[str(p.random_seed)])
|
|
elif score < score_by_plant[str(p.random_seed)]:
|
|
score_mirror -= score_by_plant[str(p.random_seed)] - score
|
|
score_by_plant[str(p.random_seed)] = score
|
|
# Check for removed plants
|
|
for key in score_by_plant:
|
|
if region_data.plants.find_custom(
|
|
func (p): return str(p.random_seed) == key
|
|
) == -1:
|
|
score_mirror -= score_by_plant[key]
|
|
score_by_plant.erase(key)
|
|
|
|
state_update(region_data)
|
|
|
|
func score_update(with_animation = true):
|
|
var objective_progression : float
|
|
var objective = GameInfo.game_data.current_region_data.objective
|
|
if GameInfo.game_data.current_region_data.state == RegionData.State.SUCCEEDED:
|
|
objective_progression = 1.
|
|
%ObjectiveProgressBar.text = tr("FULL") + " %d" % [score_mirror]
|
|
else:
|
|
objective_progression = (float(score_mirror) / max(float(objective), 1))
|
|
%ObjectiveProgressBar.text = "%d/%d" % [score_mirror, objective]
|
|
|
|
if with_animation:
|
|
get_tree().create_tween().tween_property(
|
|
%ObjectiveProgressBar,
|
|
"progress",
|
|
objective_progression,
|
|
0.5,
|
|
)
|
|
else:
|
|
%ObjectiveProgressBar.set_progress(objective_progression)
|
|
|
|
func state_update(region_data : RegionData):
|
|
if region_data.state == RegionData.State.SUCCEEDED:
|
|
objective_text = "COLLECT_YOUR_SEEDS_AND_TAKE_OFF"
|
|
if GameInfo.game_data.current_run.story_step is TutorialStoryStep:
|
|
objective_text = "PASS_THE_MYSTERIOUS_DOOR"
|
|
elif region_data.state == RegionData.State.FAILED:
|
|
objective_text = "NO_RECHARGE_LEFT"
|
|
|
|
func plant_changing_score(plant_data: PlantData, amount : int):
|
|
if GameInfo.game_data.current_region_data.in_passing_day_animation:
|
|
await GameInfo.game_data.current_region_data.pass_day_ended
|
|
if amount <= 0:
|
|
score_mirror += amount
|
|
else :
|
|
for i in range(amount):
|
|
var camera = get_viewport().get_camera_2d()
|
|
var screen_size = get_viewport().get_visible_rect().size
|
|
|
|
spawn_score_particle(
|
|
plant_data.position - camera.global_position + screen_size / 2,
|
|
%ObjectiveProgressBar.global_position + %ObjectiveProgressBar.size / 2,
|
|
0.8
|
|
)
|
|
|
|
await get_tree().create_timer(0.5 / max(1.,i)).timeout
|
|
|
|
func spawn_score_particle(
|
|
from_position,
|
|
to_position,
|
|
duration
|
|
):
|
|
var sprite_particle = Sprite2D.new()
|
|
sprite_particle.texture = SCORE_ICON
|
|
%ScoreParticles.add_child(sprite_particle)
|
|
sprite_particle.position = from_position
|
|
|
|
var tween = get_tree().create_tween()
|
|
|
|
tween.set_trans(Tween.TransitionType.TRANS_SPRING)
|
|
|
|
tween.tween_property(
|
|
sprite_particle,
|
|
"position",
|
|
to_position,
|
|
duration
|
|
)
|
|
|
|
|
|
await tween.finished
|
|
score_mirror += 1
|
|
AudioManager.play_sfx("PlantPoint")
|
|
|
|
sprite_particle.queue_free()
|
|
|
|
|
|
func set_objective_text(v : String = objective_text):
|
|
print(v)
|
|
var old_v = objective_text
|
|
objective_text = v
|
|
if is_node_ready() and old_v != objective_text:
|
|
if (objective_text != "" and objective_text != %ObjectiveLabel.text):
|
|
%ObjectiveAnimationPlayer.play("bump")
|
|
AudioManager.play_sfx("Screen_interaction")
|
|
%ObjectiveLabel.text = v
|
|
|
|
func show_energy(shown = true):
|
|
%EnergyInfo.visible = shown
|
|
|
|
func show_progress_bar(shown = true):
|
|
%ObjectiveProgressBar.visible = shown
|
|
|
|
func show_help(shown = true):
|
|
%Help.visible = shown
|
|
|
|
func _on_player_action_tried_without_energy():
|
|
$AnimationPlayer.play("no_energy_left")
|
|
|
|
func _on_player_upgraded():
|
|
$EffectAnimation.play("upgrade")
|