ajout d'une alerte de réussite/échec
This commit is contained in:
213
gui/game/alert/alert.tscn
Normal file
213
gui/game/alert/alert.tscn
Normal file
@@ -0,0 +1,213 @@
|
||||
[gd_scene format=3 uid="uid://edxmvtvtipwq"]
|
||||
|
||||
[ext_resource type="Theme" uid="uid://bgcmd213j6gk1" path="res://gui/ressources/hud.tres" id="1_bmajk"]
|
||||
[ext_resource type="LabelSettings" uid="uid://dqwayi8yjwau2" path="res://gui/ressources/title_label_settings.tres" id="2_jqcc2"]
|
||||
[ext_resource type="Script" uid="uid://b8hth7y8sjfy4" path="res://gui/game/alert/scripts/alert.gd" id="2_tr7ge"]
|
||||
|
||||
[sub_resource type="Gradient" id="Gradient_id0t5"]
|
||||
interpolation_mode = 1
|
||||
offsets = PackedFloat32Array(0, 0.115169, 0.41573, 0.620786, 0.924157)
|
||||
colors = PackedColorArray(1, 1, 1, 1, 1, 1, 1, 0, 1, 1, 1, 1, 1, 1, 1, 0, 1, 1, 1, 1)
|
||||
|
||||
[sub_resource type="GradientTexture2D" id="GradientTexture2D_j7f85"]
|
||||
gradient = SubResource("Gradient_id0t5")
|
||||
fill_to = Vector2(1, 1)
|
||||
repeat = 1
|
||||
|
||||
[sub_resource type="Animation" id="Animation_jqcc2"]
|
||||
length = 0.001
|
||||
tracks/0/type = "value"
|
||||
tracks/0/imported = false
|
||||
tracks/0/enabled = true
|
||||
tracks/0/path = NodePath("NoRechargeLeftBaneer:custom_minimum_size")
|
||||
tracks/0/interp = 1
|
||||
tracks/0/loop_wrap = true
|
||||
tracks/0/keys = {
|
||||
"times": PackedFloat32Array(0),
|
||||
"transitions": PackedFloat32Array(1),
|
||||
"update": 0,
|
||||
"values": [Vector2(0, 0)]
|
||||
}
|
||||
tracks/1/type = "value"
|
||||
tracks/1/imported = false
|
||||
tracks/1/enabled = true
|
||||
tracks/1/path = NodePath("MarginContainer/Label:modulate")
|
||||
tracks/1/interp = 1
|
||||
tracks/1/loop_wrap = true
|
||||
tracks/1/keys = {
|
||||
"times": PackedFloat32Array(0),
|
||||
"transitions": PackedFloat32Array(1),
|
||||
"update": 0,
|
||||
"values": [Color(1, 1, 1, 0)]
|
||||
}
|
||||
tracks/2/type = "value"
|
||||
tracks/2/imported = false
|
||||
tracks/2/enabled = true
|
||||
tracks/2/path = NodePath(".:visible")
|
||||
tracks/2/interp = 1
|
||||
tracks/2/loop_wrap = true
|
||||
tracks/2/keys = {
|
||||
"times": PackedFloat32Array(0),
|
||||
"transitions": PackedFloat32Array(1),
|
||||
"update": 1,
|
||||
"values": [false]
|
||||
}
|
||||
|
||||
[sub_resource type="Animation" id="Animation_bmajk"]
|
||||
resource_name = "appear"
|
||||
length = 0.5
|
||||
tracks/0/type = "value"
|
||||
tracks/0/imported = false
|
||||
tracks/0/enabled = true
|
||||
tracks/0/path = NodePath(".:visible")
|
||||
tracks/0/interp = 1
|
||||
tracks/0/loop_wrap = true
|
||||
tracks/0/keys = {
|
||||
"times": PackedFloat32Array(0, 0.06666667),
|
||||
"transitions": PackedFloat32Array(1, 1),
|
||||
"update": 1,
|
||||
"values": [false, true]
|
||||
}
|
||||
tracks/1/type = "value"
|
||||
tracks/1/imported = false
|
||||
tracks/1/enabled = true
|
||||
tracks/1/path = NodePath("MarginContainer/Label:modulate")
|
||||
tracks/1/interp = 1
|
||||
tracks/1/loop_wrap = true
|
||||
tracks/1/keys = {
|
||||
"times": PackedFloat32Array(0.06666667, 0.5),
|
||||
"transitions": PackedFloat32Array(1, 1),
|
||||
"update": 0,
|
||||
"values": [Color(1, 1, 1, 0), Color(1, 1, 1, 1)]
|
||||
}
|
||||
tracks/2/type = "value"
|
||||
tracks/2/imported = false
|
||||
tracks/2/enabled = true
|
||||
tracks/2/path = NodePath("NoRechargeLeftBaneer:custom_minimum_size")
|
||||
tracks/2/interp = 1
|
||||
tracks/2/loop_wrap = true
|
||||
tracks/2/keys = {
|
||||
"times": PackedFloat32Array(0.06666667, 0.5),
|
||||
"transitions": PackedFloat32Array(1, 1),
|
||||
"update": 0,
|
||||
"values": [Vector2(0, 0), Vector2(0, 50)]
|
||||
}
|
||||
|
||||
[sub_resource type="Animation" id="Animation_tr7ge"]
|
||||
resource_name = "hidden"
|
||||
length = 0.001
|
||||
tracks/0/type = "value"
|
||||
tracks/0/imported = false
|
||||
tracks/0/enabled = true
|
||||
tracks/0/path = NodePath("NoRechargeLeftBaneer:custom_minimum_size")
|
||||
tracks/0/interp = 1
|
||||
tracks/0/loop_wrap = true
|
||||
tracks/0/keys = {
|
||||
"times": PackedFloat32Array(0),
|
||||
"transitions": PackedFloat32Array(1),
|
||||
"update": 0,
|
||||
"values": [Vector2(0, 0)]
|
||||
}
|
||||
tracks/1/type = "value"
|
||||
tracks/1/imported = false
|
||||
tracks/1/enabled = true
|
||||
tracks/1/path = NodePath("MarginContainer/Label:modulate")
|
||||
tracks/1/interp = 1
|
||||
tracks/1/loop_wrap = true
|
||||
tracks/1/keys = {
|
||||
"times": PackedFloat32Array(0),
|
||||
"transitions": PackedFloat32Array(1),
|
||||
"update": 0,
|
||||
"values": [Color(1, 1, 1, 0)]
|
||||
}
|
||||
tracks/2/type = "value"
|
||||
tracks/2/imported = false
|
||||
tracks/2/enabled = true
|
||||
tracks/2/path = NodePath(".:visible")
|
||||
tracks/2/interp = 1
|
||||
tracks/2/loop_wrap = true
|
||||
tracks/2/keys = {
|
||||
"times": PackedFloat32Array(0),
|
||||
"transitions": PackedFloat32Array(1),
|
||||
"update": 1,
|
||||
"values": [false]
|
||||
}
|
||||
|
||||
[sub_resource type="Animation" id="Animation_ekkvw"]
|
||||
resource_name = "shown"
|
||||
length = 0.001
|
||||
tracks/0/type = "value"
|
||||
tracks/0/imported = false
|
||||
tracks/0/enabled = true
|
||||
tracks/0/path = NodePath("NoRechargeLeftBaneer:custom_minimum_size")
|
||||
tracks/0/interp = 1
|
||||
tracks/0/loop_wrap = true
|
||||
tracks/0/keys = {
|
||||
"times": PackedFloat32Array(0),
|
||||
"transitions": PackedFloat32Array(1),
|
||||
"update": 0,
|
||||
"values": [Vector2(0, 50)]
|
||||
}
|
||||
tracks/1/type = "value"
|
||||
tracks/1/imported = false
|
||||
tracks/1/enabled = true
|
||||
tracks/1/path = NodePath("MarginContainer/Label:modulate")
|
||||
tracks/1/interp = 1
|
||||
tracks/1/loop_wrap = true
|
||||
tracks/1/keys = {
|
||||
"times": PackedFloat32Array(0),
|
||||
"transitions": PackedFloat32Array(1),
|
||||
"update": 0,
|
||||
"values": [Color(1, 1, 1, 1)]
|
||||
}
|
||||
tracks/2/type = "value"
|
||||
tracks/2/imported = false
|
||||
tracks/2/enabled = true
|
||||
tracks/2/path = NodePath(".:visible")
|
||||
tracks/2/interp = 1
|
||||
tracks/2/loop_wrap = true
|
||||
tracks/2/keys = {
|
||||
"times": PackedFloat32Array(0),
|
||||
"transitions": PackedFloat32Array(1),
|
||||
"update": 1,
|
||||
"values": [true]
|
||||
}
|
||||
|
||||
[sub_resource type="AnimationLibrary" id="AnimationLibrary_jqcc2"]
|
||||
_data = {
|
||||
&"RESET": SubResource("Animation_jqcc2"),
|
||||
&"appear": SubResource("Animation_bmajk"),
|
||||
&"hidden": SubResource("Animation_tr7ge"),
|
||||
&"shown": SubResource("Animation_ekkvw")
|
||||
}
|
||||
|
||||
[node name="Alert" type="VBoxContainer" unique_id=496897031]
|
||||
visible = false
|
||||
anchors_preset = 10
|
||||
anchor_right = 1.0
|
||||
grow_horizontal = 2
|
||||
theme = ExtResource("1_bmajk")
|
||||
theme_override_constants/separation = 0
|
||||
script = ExtResource("2_tr7ge")
|
||||
text = "Hello"
|
||||
|
||||
[node name="NoRechargeLeftBaneer" type="TextureRect" parent="." unique_id=23924313]
|
||||
layout_mode = 2
|
||||
texture = SubResource("GradientTexture2D_j7f85")
|
||||
expand_mode = 1
|
||||
stretch_mode = 1
|
||||
|
||||
[node name="MarginContainer" type="MarginContainer" parent="." unique_id=813474581]
|
||||
layout_mode = 2
|
||||
|
||||
[node name="Label" type="Label" parent="MarginContainer" unique_id=1564390461]
|
||||
unique_name_in_owner = true
|
||||
modulate = Color(1, 1, 1, 0)
|
||||
layout_mode = 2
|
||||
text = "Hello"
|
||||
label_settings = ExtResource("2_jqcc2")
|
||||
horizontal_alignment = 2
|
||||
|
||||
[node name="AppearAnimationPlayer" type="AnimationPlayer" parent="." unique_id=1593798240]
|
||||
unique_name_in_owner = true
|
||||
libraries/ = SubResource("AnimationLibrary_jqcc2")
|
||||
25
gui/game/alert/scripts/alert.gd
Normal file
25
gui/game/alert/scripts/alert.gd
Normal file
@@ -0,0 +1,25 @@
|
||||
@tool
|
||||
extends VBoxContainer
|
||||
class_name Alert
|
||||
|
||||
@export var text = "" :
|
||||
set(t):
|
||||
text = t
|
||||
if is_node_ready():
|
||||
%Label.text = t
|
||||
|
||||
func appear(
|
||||
with_anim : bool = not visible
|
||||
):
|
||||
if with_anim :
|
||||
%AppearAnimationPlayer.play("appear")
|
||||
else:
|
||||
%AppearAnimationPlayer.play("shown")
|
||||
|
||||
func disappear(
|
||||
with_anim : bool = visible
|
||||
):
|
||||
if with_anim :
|
||||
%AppearAnimationPlayer.play_backwards("appear")
|
||||
else:
|
||||
%AppearAnimationPlayer.play("hidden")
|
||||
1
gui/game/alert/scripts/alert.gd.uid
Normal file
1
gui/game/alert/scripts/alert.gd.uid
Normal file
@@ -0,0 +1 @@
|
||||
uid://b8hth7y8sjfy4
|
||||
@@ -2,6 +2,7 @@
|
||||
|
||||
[ext_resource type="Script" uid="uid://cqao7n800qy40" path="res://gui/game/scripts/game_gui.gd" id="1_udau0"]
|
||||
[ext_resource type="Theme" uid="uid://bgcmd213j6gk1" path="res://gui/ressources/hud.tres" id="2_nq5i2"]
|
||||
[ext_resource type="PackedScene" uid="uid://edxmvtvtipwq" path="res://gui/game/alert/alert.tscn" id="2_ykapk"]
|
||||
[ext_resource type="PackedScene" uid="uid://brfsapvj2quxm" path="res://gui/game/energy_info/energy_info.tscn" id="4_2wykm"]
|
||||
[ext_resource type="PackedScene" uid="uid://fnv0qhkh40mv" path="res://gui/game/announce/announce.tscn" id="4_h6540"]
|
||||
[ext_resource type="FontFile" uid="uid://qt80w6o01q5s" path="res://gui/ressources/fonts/TitanOne-Regular.ttf" id="6_2wykm"]
|
||||
@@ -11,116 +12,16 @@
|
||||
[ext_resource type="Texture2D" uid="uid://b43thuq8piv18" path="res://common/icons/skull.svg" id="7_dr1y2"]
|
||||
[ext_resource type="PackedScene" uid="uid://clicjf8ts51h8" path="res://gui/game/inventory_gui/inventory_gui.tscn" id="9_id0t5"]
|
||||
|
||||
[sub_resource type="Gradient" id="Gradient_id0t5"]
|
||||
interpolation_mode = 1
|
||||
offsets = PackedFloat32Array(0, 0.115169, 0.41573, 0.620786, 0.924157)
|
||||
colors = PackedColorArray(1, 1, 1, 1, 1, 1, 1, 0, 1, 1, 1, 1, 1, 1, 1, 0, 1, 1, 1, 1)
|
||||
|
||||
[sub_resource type="GradientTexture2D" id="GradientTexture2D_j7f85"]
|
||||
gradient = SubResource("Gradient_id0t5")
|
||||
fill_to = Vector2(1, 1)
|
||||
repeat = 1
|
||||
|
||||
[sub_resource type="LabelSettings" id="LabelSettings_id0t5"]
|
||||
font = ExtResource("6_2wykm")
|
||||
font_size = 40
|
||||
|
||||
[sub_resource type="Animation" id="Animation_2wykm"]
|
||||
resource_name = "NoRechargeAppear"
|
||||
length = 0.5
|
||||
tracks/0/type = "value"
|
||||
tracks/0/imported = false
|
||||
tracks/0/enabled = true
|
||||
tracks/0/path = NodePath("MarginContainer/GiveUpButton:visible")
|
||||
tracks/0/interp = 1
|
||||
tracks/0/loop_wrap = true
|
||||
tracks/0/keys = {
|
||||
"times": PackedFloat32Array(0, 0.03333333),
|
||||
"transitions": PackedFloat32Array(1, 1),
|
||||
"update": 1,
|
||||
"values": [false, true]
|
||||
}
|
||||
tracks/1/type = "value"
|
||||
tracks/1/imported = false
|
||||
tracks/1/enabled = true
|
||||
tracks/1/path = NodePath("MarginContainer/GiveUpButton:modulate")
|
||||
tracks/1/interp = 1
|
||||
tracks/1/loop_wrap = true
|
||||
tracks/1/keys = {
|
||||
"times": PackedFloat32Array(0, 0.5),
|
||||
"transitions": PackedFloat32Array(1, 1),
|
||||
"update": 0,
|
||||
"values": [Color(1, 1, 1, 0), Color(1, 1, 1, 1)]
|
||||
}
|
||||
tracks/2/type = "value"
|
||||
tracks/2/imported = false
|
||||
tracks/2/enabled = true
|
||||
tracks/2/path = NodePath("NoRechargeLeftBaneer:custom_minimum_size")
|
||||
tracks/2/interp = 1
|
||||
tracks/2/loop_wrap = true
|
||||
tracks/2/keys = {
|
||||
"times": PackedFloat32Array(0, 0.5),
|
||||
"transitions": PackedFloat32Array(1, 1),
|
||||
"update": 0,
|
||||
"values": [Vector2(0, 0), Vector2(0, 50)]
|
||||
}
|
||||
|
||||
[sub_resource type="Animation" id="Animation_id0t5"]
|
||||
length = 0.001
|
||||
tracks/0/type = "value"
|
||||
tracks/0/imported = false
|
||||
tracks/0/enabled = true
|
||||
tracks/0/path = NodePath("MarginContainer/GiveUpButton:visible")
|
||||
tracks/0/interp = 1
|
||||
tracks/0/loop_wrap = true
|
||||
tracks/0/keys = {
|
||||
"times": PackedFloat32Array(0),
|
||||
"transitions": PackedFloat32Array(1),
|
||||
"update": 1,
|
||||
"values": [false]
|
||||
}
|
||||
tracks/1/type = "value"
|
||||
tracks/1/imported = false
|
||||
tracks/1/enabled = true
|
||||
tracks/1/path = NodePath("MarginContainer/GiveUpButton:modulate")
|
||||
tracks/1/interp = 1
|
||||
tracks/1/loop_wrap = true
|
||||
tracks/1/keys = {
|
||||
"times": PackedFloat32Array(0),
|
||||
"transitions": PackedFloat32Array(1),
|
||||
"update": 0,
|
||||
"values": [Color(1, 1, 1, 1)]
|
||||
}
|
||||
tracks/2/type = "value"
|
||||
tracks/2/imported = false
|
||||
tracks/2/enabled = true
|
||||
tracks/2/path = NodePath("NoRechargeLeftBaneer:custom_minimum_size")
|
||||
tracks/2/interp = 1
|
||||
tracks/2/loop_wrap = true
|
||||
tracks/2/keys = {
|
||||
"times": PackedFloat32Array(0),
|
||||
"transitions": PackedFloat32Array(1),
|
||||
"update": 0,
|
||||
"values": [Vector2(0, 0)]
|
||||
}
|
||||
|
||||
[sub_resource type="AnimationLibrary" id="AnimationLibrary_ykapk"]
|
||||
_data = {
|
||||
&"NoRechargeAppear": SubResource("Animation_2wykm"),
|
||||
&"RESET": SubResource("Animation_id0t5")
|
||||
}
|
||||
|
||||
[node name="GameGui" type="CanvasLayer" unique_id=274698556]
|
||||
script = ExtResource("1_udau0")
|
||||
|
||||
[node name="NoRechargeLeftBaneer" type="TextureRect" parent="." unique_id=827897082]
|
||||
self_modulate = Color(1, 0.6509804, 0.09019608, 1)
|
||||
anchors_preset = 10
|
||||
anchor_right = 1.0
|
||||
grow_horizontal = 2
|
||||
texture = SubResource("GradientTexture2D_j7f85")
|
||||
expand_mode = 1
|
||||
stretch_mode = 1
|
||||
[node name="Alert" parent="." unique_id=496897031 instance=ExtResource("2_ykapk")]
|
||||
unique_name_in_owner = true
|
||||
modulate = Color(1, 0, 0.43137252, 1)
|
||||
|
||||
[node name="ScoreParticles" type="Control" parent="." unique_id=842190807]
|
||||
unique_name_in_owner = true
|
||||
@@ -192,13 +93,8 @@ size_flags_vertical = 8
|
||||
|
||||
[node name="GiveUpButton" type="Button" parent="MarginContainer" unique_id=1128310884]
|
||||
unique_name_in_owner = true
|
||||
visible = false
|
||||
layout_mode = 2
|
||||
size_flags_horizontal = 8
|
||||
size_flags_vertical = 8
|
||||
text = "GIVE_UP"
|
||||
icon = ExtResource("7_dr1y2")
|
||||
|
||||
[node name="NoRechargeAnimationPlayer" type="AnimationPlayer" parent="." unique_id=969107428]
|
||||
unique_name_in_owner = true
|
||||
libraries/ = SubResource("AnimationLibrary_ykapk")
|
||||
|
||||
@@ -20,6 +20,7 @@ func _ready():
|
||||
%SimplePlantPointScore.visible = "tutorial" in GameInfo.game_data.current_region_data.flags
|
||||
|
||||
charge_update(GameInfo.game_data.current_region_data)
|
||||
state_update(GameInfo.game_data.current_region_data)
|
||||
player_update(GameInfo.game_data.player_data, false)
|
||||
%EnergyInfo.reset_size()
|
||||
%GiveUpButton.pressed.connect(_on_give_up_pressed)
|
||||
@@ -59,6 +60,7 @@ func _on_region_updated(region_data : RegionData):
|
||||
score_by_plant.erase(key)
|
||||
|
||||
charge_update(region_data)
|
||||
state_update(region_data)
|
||||
|
||||
func _on_give_up_pressed():
|
||||
GameInfo.game_data.give_up()
|
||||
@@ -66,12 +68,6 @@ func _on_give_up_pressed():
|
||||
|
||||
func charge_update(region_data : RegionData):
|
||||
%RechargesLeftLabel.text = tr("%d_CHARGE_LEFT") % (region_data.charges)
|
||||
if region_data.charges == 0 and region_data.state != RegionData.State.SUCCEEDED:
|
||||
if not %GiveUpButton.visible:
|
||||
%NoRechargeAnimationPlayer.play("NoRechargeAppear")
|
||||
else :
|
||||
if %GiveUpButton.visible:
|
||||
%NoRechargeAnimationPlayer.play_backward("NoRechargeAppear")
|
||||
|
||||
func score_update(with_animation = true):
|
||||
var objective_progression : float
|
||||
@@ -98,6 +94,23 @@ func score_update(with_animation = true):
|
||||
else :
|
||||
%SimplePlantPointScoreLabel.text = tr("%d_PLANT_POINT") % score_mirror
|
||||
|
||||
func state_update(region_data : RegionData):
|
||||
if region_data.state == RegionData.State.SUCCEEDED:
|
||||
print("C'est gagné !!")
|
||||
%Alert.text = "SHIP_IS_READY_TO_TAKE_OFF"
|
||||
if "tutorial" in region_data.flags:
|
||||
%Alert.text = "TUTORIAL_FINISHED"
|
||||
%Alert.modulate = Color("25C147")
|
||||
%Alert.appear()
|
||||
elif region_data.state == RegionData.State.FAILED:
|
||||
%Alert.text = "NO_RECHARGE_LEFT"
|
||||
%Alert.modulate = Color("FF006E")
|
||||
%Alert.appear()
|
||||
else:
|
||||
%Alert.disappear()
|
||||
print(region_data.state == RegionData.State.FAILED)
|
||||
%GiveUpButton.visible = region_data.state == RegionData.State.FAILED
|
||||
|
||||
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
|
||||
|
||||
@@ -107,9 +107,10 @@ func _process(_d):
|
||||
|
||||
func finish_tutorial():
|
||||
GameInfo.game_data.tutorial_done = true
|
||||
region.data.state = RegionData.State.SUCCEEDED
|
||||
region.data.update()
|
||||
succeded.emit()
|
||||
|
||||
|
||||
class Step:
|
||||
|
||||
var text : String : get = get_text
|
||||
|
||||
Reference in New Issue
Block a user