refactor du code et ajouts des quotas, avec des récompense entre chaque quota #68
This commit is contained in:
177
gui/game/reward_choice/reward_choice.tscn
Normal file
177
gui/game/reward_choice/reward_choice.tscn
Normal file
@@ -0,0 +1,177 @@
|
||||
[gd_scene load_steps=11 format=3 uid="uid://doxm7uab8i3tq"]
|
||||
|
||||
[ext_resource type="Script" uid="uid://12kjdou2kp5y" path="res://gui/game/reward_choice/scripts/reward_choice.gd" id="1_4f1tl"]
|
||||
[ext_resource type="Shader" uid="uid://cuni3ggtw2uuy" path="res://gui/game/pause/resources/blur.gdshader" id="1_iykpa"]
|
||||
[ext_resource type="Theme" uid="uid://bgcmd213j6gk1" path="res://gui/ressources/default_theme.tres" id="2_c278i"]
|
||||
[ext_resource type="FontFile" uid="uid://cpnsnrqhfkj3k" path="res://gui/ressources/fonts/spincycle_ot.otf" id="3_5sqh2"]
|
||||
[ext_resource type="Texture2D" uid="uid://0xg54agef5gh" path="res://common/icons/package.svg" id="4_qmlcw"]
|
||||
|
||||
[sub_resource type="ShaderMaterial" id="ShaderMaterial_gy0la"]
|
||||
shader = ExtResource("1_iykpa")
|
||||
shader_parameter/strength = 3.3
|
||||
shader_parameter/mix_percentage = 0.3
|
||||
|
||||
[sub_resource type="LabelSettings" id="LabelSettings_4f1tl"]
|
||||
font = ExtResource("3_5sqh2")
|
||||
font_size = 50
|
||||
|
||||
[sub_resource type="Animation" id="Animation_4f1tl"]
|
||||
resource_name = "show"
|
||||
length = 0.3
|
||||
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.0333333),
|
||||
"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(".:modulate")
|
||||
tracks/1/interp = 2
|
||||
tracks/1/loop_wrap = true
|
||||
tracks/1/keys = {
|
||||
"times": PackedFloat32Array(0.0333333, 0.3),
|
||||
"transitions": PackedFloat32Array(1, 1),
|
||||
"update": 0,
|
||||
"values": [Color(1, 1, 1, 0), Color(1, 1, 1, 1)]
|
||||
}
|
||||
|
||||
[sub_resource type="Animation" id="Animation_8323k"]
|
||||
length = 0.001
|
||||
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),
|
||||
"transitions": PackedFloat32Array(1),
|
||||
"update": 1,
|
||||
"values": [false]
|
||||
}
|
||||
tracks/1/type = "value"
|
||||
tracks/1/imported = false
|
||||
tracks/1/enabled = true
|
||||
tracks/1/path = NodePath(".: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)]
|
||||
}
|
||||
|
||||
[sub_resource type="AnimationLibrary" id="AnimationLibrary_7fpy7"]
|
||||
_data = {
|
||||
&"RESET": SubResource("Animation_8323k"),
|
||||
&"show": SubResource("Animation_4f1tl")
|
||||
}
|
||||
|
||||
[node name="RewardChoice" type="Control"]
|
||||
process_mode = 3
|
||||
visible = false
|
||||
modulate = Color(1, 1, 1, 0)
|
||||
layout_mode = 3
|
||||
anchors_preset = 15
|
||||
anchor_right = 1.0
|
||||
anchor_bottom = 1.0
|
||||
grow_horizontal = 2
|
||||
grow_vertical = 2
|
||||
script = ExtResource("1_4f1tl")
|
||||
|
||||
[node name="ColorRect" type="ColorRect" parent="."]
|
||||
material = SubResource("ShaderMaterial_gy0la")
|
||||
layout_mode = 1
|
||||
anchors_preset = 15
|
||||
anchor_right = 1.0
|
||||
anchor_bottom = 1.0
|
||||
grow_horizontal = 2
|
||||
grow_vertical = 2
|
||||
color = Color(0.0352941, 0.0196078, 0.12549, 0.705882)
|
||||
|
||||
[node name="Choice" type="MarginContainer" parent="."]
|
||||
layout_mode = 1
|
||||
anchors_preset = 15
|
||||
anchor_right = 1.0
|
||||
anchor_bottom = 1.0
|
||||
grow_horizontal = 2
|
||||
grow_vertical = 2
|
||||
theme = ExtResource("2_c278i")
|
||||
|
||||
[node name="VSplitContainer" type="VBoxContainer" parent="Choice"]
|
||||
layout_mode = 2
|
||||
theme = ExtResource("2_c278i")
|
||||
alignment = 1
|
||||
|
||||
[node name="Label" type="Label" parent="Choice/VSplitContainer"]
|
||||
layout_mode = 2
|
||||
text = "You reached the quota !"
|
||||
label_settings = SubResource("LabelSettings_4f1tl")
|
||||
horizontal_alignment = 1
|
||||
|
||||
[node name="Label2" type="Label" parent="Choice/VSplitContainer"]
|
||||
layout_mode = 2
|
||||
text = "Choose a reward"
|
||||
horizontal_alignment = 1
|
||||
|
||||
[node name="GridContainer" type="GridContainer" parent="Choice/VSplitContainer"]
|
||||
layout_mode = 2
|
||||
theme = ExtResource("2_c278i")
|
||||
columns = 2
|
||||
|
||||
[node name="Reward1" type="VBoxContainer" parent="Choice/VSplitContainer/GridContainer"]
|
||||
layout_mode = 2
|
||||
size_flags_horizontal = 3
|
||||
size_flags_vertical = 3
|
||||
|
||||
[node name="Reward1Button" type="Button" parent="Choice/VSplitContainer/GridContainer/Reward1"]
|
||||
unique_name_in_owner = true
|
||||
process_mode = 3
|
||||
layout_mode = 2
|
||||
size_flags_horizontal = 3
|
||||
size_flags_vertical = 3
|
||||
text = "Compost"
|
||||
icon = ExtResource("4_qmlcw")
|
||||
|
||||
[node name="Reward1Desc" type="Label" parent="Choice/VSplitContainer/GridContainer/Reward1"]
|
||||
unique_name_in_owner = true
|
||||
layout_mode = 2
|
||||
text = "The Compost can do so mush things.... But it's a little gross !"
|
||||
horizontal_alignment = 1
|
||||
|
||||
[node name="Reward2" type="VBoxContainer" parent="Choice/VSplitContainer/GridContainer"]
|
||||
layout_mode = 2
|
||||
size_flags_horizontal = 3
|
||||
size_flags_vertical = 3
|
||||
|
||||
[node name="Reward2Button" type="Button" parent="Choice/VSplitContainer/GridContainer/Reward2"]
|
||||
unique_name_in_owner = true
|
||||
layout_mode = 2
|
||||
size_flags_horizontal = 3
|
||||
size_flags_vertical = 3
|
||||
text = "Compost"
|
||||
icon = ExtResource("4_qmlcw")
|
||||
|
||||
[node name="Reward2Desc" type="Label" parent="Choice/VSplitContainer/GridContainer/Reward2"]
|
||||
unique_name_in_owner = true
|
||||
layout_mode = 2
|
||||
text = "The Compost can do so mush things.... But it's a little gross !"
|
||||
horizontal_alignment = 1
|
||||
|
||||
[node name="AnimationPlayer" type="AnimationPlayer" parent="."]
|
||||
unique_name_in_owner = true
|
||||
libraries = {
|
||||
&"": SubResource("AnimationLibrary_7fpy7")
|
||||
}
|
||||
|
||||
[connection signal="pressed" from="Choice/VSplitContainer/GridContainer/Reward1/Reward1Button" to="." method="_on_reward_1_button_pressed"]
|
||||
[connection signal="pressed" from="Choice/VSplitContainer/GridContainer/Reward2/Reward2Button" to="." method="_on_reward_2_button_pressed"]
|
||||
37
gui/game/reward_choice/scripts/reward_choice.gd
Normal file
37
gui/game/reward_choice/scripts/reward_choice.gd
Normal file
@@ -0,0 +1,37 @@
|
||||
extends Control
|
||||
|
||||
var planet: Planet
|
||||
var item1: Item
|
||||
var item2: Item
|
||||
|
||||
func show_rewards():
|
||||
get_tree().paused = true
|
||||
%AnimationPlayer.play("show")
|
||||
|
||||
func hide_rewards():
|
||||
get_tree().paused = false
|
||||
%AnimationPlayer.play_backwards("show")
|
||||
|
||||
func _on_planet_quota_reward_asked(_planet:Planet, _item1:Item, _item2:Item):
|
||||
planet = _planet
|
||||
item1 = _item1
|
||||
item2 = _item2
|
||||
|
||||
%Reward1Button.text = item1.name
|
||||
%Reward1Button.icon = item1.icon
|
||||
%Reward1Desc.text = item1.description
|
||||
|
||||
%Reward2Button.text = item2.name
|
||||
%Reward2Button.icon = item2.icon
|
||||
%Reward2Desc.text = item2.description
|
||||
show_rewards()
|
||||
|
||||
func _on_reward_1_button_pressed():
|
||||
if planet:
|
||||
planet.choose_quota_reward(item1)
|
||||
hide_rewards()
|
||||
|
||||
func _on_reward_2_button_pressed():
|
||||
if planet:
|
||||
planet.choose_quota_reward(item2)
|
||||
hide_rewards()
|
||||
1
gui/game/reward_choice/scripts/reward_choice.gd.uid
Normal file
1
gui/game/reward_choice/scripts/reward_choice.gd.uid
Normal file
@@ -0,0 +1 @@
|
||||
uid://12kjdou2kp5y
|
||||
Reference in New Issue
Block a user