ajout du déblocage/évolutions des plantes (#89) et fix divers

This commit is contained in:
2025-11-07 13:26:04 +01:00
parent 11ae967845
commit ed675ed532
54 changed files with 901 additions and 483 deletions

View File

@@ -1,4 +1,4 @@
[gd_scene load_steps=20 format=3 uid="uid://753270jjxmfg"]
[gd_scene load_steps=26 format=3 uid="uid://753270jjxmfg"]
[ext_resource type="Theme" uid="uid://bgcmd213j6gk1" path="res://gui/ressources/default_theme.tres" id="1_m317d"]
[ext_resource type="Script" uid="uid://b7f10wuounfan" path="res://gui/game/card/scripts/card.gd" id="2_kpm7h"]
@@ -26,6 +26,30 @@ title_icon = ExtResource("6_7wc8v")
text = "Text"
metadata/_custom_type_script = "uid://dgbh38j13g5kn"
[sub_resource type="Resource" id="Resource_kpm7h"]
script = ExtResource("5_7wc8v")
metadata/_custom_type_script = "uid://dgbh38j13g5kn"
[sub_resource type="Resource" id="Resource_7wc8v"]
script = ExtResource("5_7wc8v")
metadata/_custom_type_script = "uid://dgbh38j13g5kn"
[sub_resource type="Resource" id="Resource_pmldi"]
script = ExtResource("5_7wc8v")
metadata/_custom_type_script = "uid://dgbh38j13g5kn"
[sub_resource type="Resource" id="Resource_gibok"]
script = ExtResource("5_7wc8v")
metadata/_custom_type_script = "uid://dgbh38j13g5kn"
[sub_resource type="Resource" id="Resource_vnqhg"]
script = ExtResource("5_7wc8v")
metadata/_custom_type_script = "uid://dgbh38j13g5kn"
[sub_resource type="Resource" id="Resource_on5kv"]
script = ExtResource("5_7wc8v")
metadata/_custom_type_script = "uid://dgbh38j13g5kn"
[sub_resource type="Resource" id="Resource_plgbn"]
script = ExtResource("3_7wc8v")
title = "Hello"
@@ -33,7 +57,7 @@ type_icon = ExtResource("6_7wc8v")
texture = ExtResource("7_mwhj8")
important_stat_text = "10"
important_stat_icon = ExtResource("3_kpm7h")
sections = Array[ExtResource("5_7wc8v")]([SubResource("Resource_mwhj8")])
sections = Array[ExtResource("5_7wc8v")]([SubResource("Resource_mwhj8"), SubResource("Resource_kpm7h"), SubResource("Resource_7wc8v"), SubResource("Resource_pmldi"), SubResource("Resource_gibok"), SubResource("Resource_vnqhg"), SubResource("Resource_on5kv"), null])
metadata/_custom_type_script = "uid://dj2pv1hiwjfv0"
[sub_resource type="StyleBoxFlat" id="StyleBoxFlat_vnqhg"]

View File

@@ -1,13 +1,14 @@
[gd_scene load_steps=15 format=3 uid="uid://3ss8pvhsackj"]
[gd_scene load_steps=22 format=3 uid="uid://3ss8pvhsackj"]
[ext_resource type="PackedScene" uid="uid://753270jjxmfg" path="res://gui/game/card/card.tscn" id="1_we78f"]
[ext_resource type="Shader" uid="uid://bqjwmomh851lc" path="res://common/vfx/materials/shaders/skew.gdshader" id="1_x54se"]
[ext_resource type="Script" uid="uid://dj5pld5ragrjp" path="res://gui/game/card/scripts/card_visualiser.gd" id="2_ntbk8"]
[ext_resource type="Script" uid="uid://dj2pv1hiwjfv0" path="res://gui/game/card/scripts/card_info.gd" id="3_5yk1o"]
[ext_resource type="Texture2D" uid="uid://bd6qddv5ihkjr" path="res://common/icons/bucket.svg" id="3_r0jrf"]
[ext_resource type="Script" uid="uid://dgbh38j13g5kn" path="res://gui/game/card/scripts/card_section_info.gd" id="4_7xkgc"]
[ext_resource type="Script" uid="uid://b4tkium34c831" path="res://gui/game/card/scripts/card_stat_info.gd" id="5_1et8x"]
[ext_resource type="Texture2D" uid="uid://bt3g5bmar0icf" path="res://common/icons/growth.svg" id="6_7xkgc"]
[ext_resource type="Texture2D" uid="uid://bsvxhafoxwmw0" path="res://common/icons/cube-3d-sphere.svg" id="7_1et8x"]
[ext_resource type="Texture2D" uid="uid://df0y0s666ui4h" path="res://icon.png" id="7_6vah0"]
[sub_resource type="ShaderMaterial" id="ShaderMaterial_r0jrf"]
shader = ExtResource("1_x54se")
@@ -17,13 +18,41 @@ shader_parameter/y_rot = -6e-45
shader_parameter/x_rot = -6e-45
shader_parameter/inset = 0.0
[sub_resource type="ViewportTexture" id="ViewportTexture_5yk1o"]
viewport_path = NodePath("SubViewport")
[sub_resource type="Resource" id="Resource_r0jrf"]
script = ExtResource("4_7xkgc")
metadata/_custom_type_script = "uid://dgbh38j13g5kn"
[sub_resource type="Resource" id="Resource_6vah0"]
script = ExtResource("4_7xkgc")
metadata/_custom_type_script = "uid://dgbh38j13g5kn"
[sub_resource type="Resource" id="Resource_jjqcm"]
script = ExtResource("4_7xkgc")
metadata/_custom_type_script = "uid://dgbh38j13g5kn"
[sub_resource type="Resource" id="Resource_lj1tr"]
script = ExtResource("4_7xkgc")
metadata/_custom_type_script = "uid://dgbh38j13g5kn"
[sub_resource type="Resource" id="Resource_vabmf"]
script = ExtResource("4_7xkgc")
metadata/_custom_type_script = "uid://dgbh38j13g5kn"
[sub_resource type="Resource" id="Resource_1vjtn"]
script = ExtResource("4_7xkgc")
metadata/_custom_type_script = "uid://dgbh38j13g5kn"
[sub_resource type="Resource" id="Resource_l3vvu"]
script = ExtResource("4_7xkgc")
metadata/_custom_type_script = "uid://dgbh38j13g5kn"
[sub_resource type="Resource" id="Resource_bw03i"]
script = ExtResource("3_5yk1o")
title = "Hello"
texture = ExtResource("6_7xkgc")
texture = ExtResource("7_6vah0")
important_stat_text = "6"
important_stat_icon = ExtResource("3_r0jrf")
sections = Array[ExtResource("4_7xkgc")]([SubResource("Resource_r0jrf"), SubResource("Resource_6vah0"), SubResource("Resource_jjqcm"), SubResource("Resource_lj1tr"), SubResource("Resource_vabmf"), SubResource("Resource_1vjtn"), SubResource("Resource_l3vvu")])
metadata/_custom_type_script = "uid://dj2pv1hiwjfv0"
[sub_resource type="Animation" id="Animation_1et8x"]
@@ -39,31 +68,38 @@ _data = {
&"appear": SubResource("Animation_7xkgc")
}
[node name="CardVisualiser" type="TextureRect"]
[node name="CardVisualiser" type="SubViewportContainer"]
material = SubResource("ShaderMaterial_r0jrf")
offset_left = -24.0
offset_right = 276.0
offset_bottom = 110.0
anchors_preset = 8
anchor_left = 0.5
anchor_top = 0.5
anchor_right = 0.5
anchor_bottom = 0.5
offset_left = -246.0
offset_top = -134.0
offset_right = 54.0
offset_bottom = -24.0
grow_horizontal = 2
grow_vertical = 2
scale = Vector2(1.0000002, 1.0000002)
size_flags_horizontal = 0
size_flags_vertical = 4
mouse_filter = 2
texture = SubResource("ViewportTexture_5yk1o")
stretch_mode = 4
script = ExtResource("2_ntbk8")
small_mode = true
card_info = SubResource("Resource_r0jrf")
card_info = SubResource("Resource_bw03i")
[node name="SubViewport" type="SubViewport" parent="."]
unique_name_in_owner = true
transparent_bg = true
handle_input_locally = false
size = Vector2i(300, 110)
size_2d_override_stretch = true
render_target_update_mode = 4
[node name="CardContainer" type="MarginContainer" parent="SubViewport"]
unique_name_in_owner = true
clip_contents = true
offset_right = 350.0
offset_right = 300.0
offset_bottom = 110.0
size_flags_horizontal = 0
theme_override_constants/margin_left = 25
theme_override_constants/margin_top = 25
theme_override_constants/margin_right = 25
@@ -73,10 +109,11 @@ theme_override_constants/margin_bottom = 25
unique_name_in_owner = true
self_modulate = Color(1, 1, 1, 0)
layout_mode = 2
size_flags_horizontal = 4
mouse_filter = 2
small_mode = true
down_arrow = true
info = SubResource("Resource_r0jrf")
info = SubResource("Resource_bw03i")
[node name="AnimationPlayer" type="AnimationPlayer" parent="."]
unique_name_in_owner = true

View File

@@ -1,27 +1,55 @@
@tool
extends TextureRect
extends SubViewportContainer
class_name CardVisualiser
signal clicked(c: CardVisualiser)
const MAX_ROT = 15
const ZOOM_SCALE = 1.0
const ZOOM_SCALE = 1.2
var wanted_rot : Vector2 = Vector2.ZERO
var real_rot : Vector2 = Vector2.ZERO
var wanted_scale : Vector2 = Vector2.ONE
var is_ready = false
@export var small_mode : bool = false :
@export var card_width : int = 250 :
set(v):
card_width = v
if is_ready :
update()
@export var small_mode : bool = true :
set(v):
var old = small_mode
small_mode = v
if is_ready : update()
if is_ready and old != small_mode :
update()
@export var interactive_small_mode : bool = true
@export var interactive_zoom : bool = false
@export var down_arrow : bool = true :
set(v):
var old = down_arrow
down_arrow = v
if is_ready and old != down_arrow :
update()
@export var card_info : CardInfo = null :
set(v):
var old = card_info
card_info = v
if is_ready : update()
if is_ready and old != card_info:
update()
@export_tool_button("Update", "Callable") var update_action = update
var updated_on_last_frame = false
func _input(event):
if event.is_action_pressed("action") and is_mouse_over():
clicked.emit(self)
func _ready():
material = material.duplicate()
update()
@@ -32,17 +60,21 @@ func _process(_d):
if is_mouse_over():
wanted_rot = center_relative_mouse_position * MAX_ROT
small_mode = false
if interactive_small_mode: small_mode = false
if interactive_zoom: scale = scale.lerp(Vector2.ONE * ZOOM_SCALE, 0.2)
else:
wanted_rot = Vector2.ZERO
small_mode = true
if interactive_small_mode: small_mode = true
if interactive_zoom: scale = scale.lerp(Vector2.ONE, 0.2)
real_rot = real_rot.lerp(wanted_rot, 0.1)
material.set_shader_parameter("y_rot", - real_rot.x)
material.set_shader_parameter("x_rot", real_rot.y)
%SubViewport.size.y = %CardContainer.size.y
%Card.custom_minimum_size.x = card_width
%CardContainer.size.y = 0
%SubViewport.size = %CardContainer.size
size = %SubViewport.size
@@ -55,8 +87,10 @@ func is_mouse_over() -> bool:
)
func update():
if card_info:
%Card.info = card_info
%Card.small_mode = small_mode
%Card.down_arrow = down_arrow
%Card.update()
updated_on_last_frame = true

View File

@@ -0,0 +1,140 @@
[gd_scene load_steps=10 format=3 uid="uid://doxm7uab8i3tq"]
[ext_resource type="Script" uid="uid://12kjdou2kp5y" path="res://gui/game/quota_reward/scripts/quota_reward.gd" id="1_gye62"]
[ext_resource type="Shader" uid="uid://cuni3ggtw2uuy" path="res://gui/game/pause/resources/blur.gdshader" id="2_6ibex"]
[ext_resource type="Theme" uid="uid://bgcmd213j6gk1" path="res://gui/ressources/default_theme.tres" id="3_x2kx4"]
[ext_resource type="LabelSettings" uid="uid://dqwayi8yjwau2" path="res://gui/ressources/title_label_settings.tres" id="4_trw0e"]
[sub_resource type="ShaderMaterial" id="ShaderMaterial_gy0la"]
shader = ExtResource("2_6ibex")
shader_parameter/strength = 3.3
shader_parameter/mix_percentage = 0.3
[sub_resource type="Theme" id="Theme_7fpy7"]
[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("RewardChoiceContainer:modulate")
tracks/0/interp = 1
tracks/0/loop_wrap = true
tracks/0/keys = {
"times": PackedFloat32Array(0),
"transitions": PackedFloat32Array(1),
"update": 0,
"values": [Color(1, 1, 1, 0)]
}
tracks/1/type = "value"
tracks/1/imported = false
tracks/1/enabled = true
tracks/1/path = NodePath("RewardChoiceContainer:visible")
tracks/1/interp = 1
tracks/1/loop_wrap = true
tracks/1/keys = {
"times": PackedFloat32Array(0),
"transitions": PackedFloat32Array(1),
"update": 1,
"values": [true]
}
[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("RewardChoiceContainer:modulate")
tracks/0/interp = 1
tracks/0/loop_wrap = true
tracks/0/keys = {
"times": PackedFloat32Array(0.033333335, 0.3),
"transitions": PackedFloat32Array(1, 1),
"update": 0,
"values": [Color(1, 1, 1, 0), Color(1, 1, 1, 1)]
}
tracks/1/type = "value"
tracks/1/imported = false
tracks/1/enabled = true
tracks/1/path = NodePath("RewardChoiceContainer:visible")
tracks/1/interp = 1
tracks/1/loop_wrap = true
tracks/1/keys = {
"times": PackedFloat32Array(0, 0.033333335),
"transitions": PackedFloat32Array(1, 1),
"update": 1,
"values": [false, true]
}
[sub_resource type="AnimationLibrary" id="AnimationLibrary_7fpy7"]
_data = {
&"RESET": SubResource("Animation_8323k"),
&"show": SubResource("Animation_4f1tl")
}
[node name="RewardChoice" type="CanvasLayer"]
process_mode = 3
script = ExtResource("1_gye62")
[node name="RewardChoiceContainer" type="Control" parent="."]
unique_name_in_owner = true
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
[node name="ColorRect" type="ColorRect" parent="RewardChoiceContainer"]
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="RewardChoiceContainer"]
layout_mode = 1
anchors_preset = 15
anchor_right = 1.0
anchor_bottom = 1.0
grow_horizontal = 2
grow_vertical = 2
theme = ExtResource("3_x2kx4")
theme_override_constants/margin_left = 30
theme_override_constants/margin_top = 30
theme_override_constants/margin_right = 30
theme_override_constants/margin_bottom = 30
[node name="VSplitContainer" type="VBoxContainer" parent="RewardChoiceContainer/Choice"]
layout_mode = 2
theme = ExtResource("3_x2kx4")
alignment = 1
[node name="Label" type="Label" parent="RewardChoiceContainer/Choice/VSplitContainer"]
layout_mode = 2
theme = SubResource("Theme_7fpy7")
text = "Choose a reward"
label_settings = ExtResource("4_trw0e")
horizontal_alignment = 1
[node name="Label2" type="Label" parent="RewardChoiceContainer/Choice/VSplitContainer"]
layout_mode = 2
theme = ExtResource("3_x2kx4")
text = "Discover new plants or evolve discovered ones"
horizontal_alignment = 1
[node name="ChoicesContainer" type="HBoxContainer" parent="RewardChoiceContainer/Choice/VSplitContainer"]
unique_name_in_owner = true
layout_mode = 2
theme = ExtResource("3_x2kx4")
[node name="AnimationPlayer" type="AnimationPlayer" parent="."]
unique_name_in_owner = true
libraries = {
&"": SubResource("AnimationLibrary_7fpy7")
}

View File

@@ -0,0 +1,96 @@
[gd_scene load_steps=20 format=3 uid="uid://caupeuds0holj"]
[ext_resource type="Script" uid="uid://bhhhw2ywxmmba" path="res://gui/game/quota_reward/quota_reward_choice/scripts/quota_reward_choice.gd" id="1_5arw8"]
[ext_resource type="LabelSettings" uid="uid://dqwayi8yjwau2" path="res://gui/ressources/title_label_settings.tres" id="1_pjvy1"]
[ext_resource type="Script" uid="uid://dj2pv1hiwjfv0" path="res://gui/game/card/scripts/card_info.gd" id="2_0lvi7"]
[ext_resource type="PackedScene" uid="uid://3ss8pvhsackj" path="res://gui/game/card/card_visualiser.tscn" id="2_5arw8"]
[ext_resource type="Script" uid="uid://bist0wp4nrswp" path="res://gui/game/quota_reward/quota_reward_choice/scripts/quota_reward_choice_info.gd" id="2_hirys"]
[ext_resource type="Shader" uid="uid://bqjwmomh851lc" path="res://common/vfx/materials/shaders/skew.gdshader" id="3_07hub"]
[ext_resource type="Script" uid="uid://dgbh38j13g5kn" path="res://gui/game/card/scripts/card_section_info.gd" id="3_llc24"]
[ext_resource type="Texture2D" uid="uid://0hbdgalf04e" path="res://common/icons/wood.svg" id="4_llc24"]
[ext_resource type="Script" uid="uid://b4tkium34c831" path="res://gui/game/card/scripts/card_stat_info.gd" id="4_tsfju"]
[ext_resource type="Texture2D" uid="uid://bsvxhafoxwmw0" path="res://common/icons/cube-3d-sphere.svg" id="5_nnvhv"]
[sub_resource type="Resource" id="Resource_tsfju"]
script = ExtResource("3_llc24")
title_colored = true
title_text = "Hello"
title_icon = ExtResource("4_llc24")
text = "This is text"
metadata/_custom_type_script = "uid://dgbh38j13g5kn"
[sub_resource type="Resource" id="Resource_llc24"]
script = ExtResource("3_llc24")
metadata/_custom_type_script = "uid://dgbh38j13g5kn"
[sub_resource type="Resource" id="Resource_nnvhv"]
script = ExtResource("3_llc24")
metadata/_custom_type_script = "uid://dgbh38j13g5kn"
[sub_resource type="Resource" id="Resource_rnvv6"]
script = ExtResource("3_llc24")
metadata/_custom_type_script = "uid://dgbh38j13g5kn"
[sub_resource type="Resource" id="Resource_0or1o"]
script = ExtResource("3_llc24")
metadata/_custom_type_script = "uid://dgbh38j13g5kn"
[sub_resource type="Resource" id="Resource_46ofu"]
script = ExtResource("3_llc24")
metadata/_custom_type_script = "uid://dgbh38j13g5kn"
[sub_resource type="Resource" id="Resource_3bvi2"]
script = ExtResource("2_0lvi7")
title = "Reward"
sections = Array[ExtResource("3_llc24")]([SubResource("Resource_tsfju"), SubResource("Resource_llc24"), SubResource("Resource_nnvhv"), SubResource("Resource_rnvv6"), SubResource("Resource_0or1o"), SubResource("Resource_46ofu")])
metadata/_custom_type_script = "uid://dj2pv1hiwjfv0"
[sub_resource type="Resource" id="Resource_apks8"]
script = ExtResource("2_hirys")
title = "One Reward"
text = "Je m"
card_info = SubResource("Resource_3bvi2")
metadata/_custom_type_script = "uid://bist0wp4nrswp"
[sub_resource type="ShaderMaterial" id="ShaderMaterial_llc24"]
shader = ExtResource("3_07hub")
shader_parameter/fov = 90.0
shader_parameter/cull_back = true
shader_parameter/y_rot = -6e-45
shader_parameter/x_rot = -6e-45
shader_parameter/inset = 0.0
[node name="QuotaRewardChoice" type="VBoxContainer"]
size_flags_horizontal = 3
size_flags_vertical = 3
mouse_filter = 0
alignment = 1
script = ExtResource("1_5arw8")
info = SubResource("Resource_apks8")
[node name="QuotaRewardTitle" type="Label" parent="."]
unique_name_in_owner = true
layout_mode = 2
text = "One Reward"
label_settings = ExtResource("1_pjvy1")
horizontal_alignment = 1
[node name="QuotaRewardText" type="RichTextLabel" parent="."]
unique_name_in_owner = true
layout_mode = 2
bbcode_enabled = true
text = "Je m"
fit_content = true
horizontal_alignment = 1
[node name="QuotaRewardCenterContainer" type="CenterContainer" parent="."]
layout_mode = 2
[node name="QuotaRewardCard" parent="QuotaRewardCenterContainer" instance=ExtResource("2_5arw8")]
unique_name_in_owner = true
material = SubResource("ShaderMaterial_llc24")
layout_mode = 2
small_mode = false
interactive_small_mode = false
down_arrow = false
card_info = SubResource("Resource_3bvi2")

View File

@@ -0,0 +1,30 @@
@tool
extends VBoxContainer
class_name QuotaRewardChoice
signal card_clicked(c : VBoxContainer)
var is_ready = false
@export var info : QuotaRewardChoiceInfo = null :
set(v):
info = v
if is_ready : update()
@export_tool_button("Update", "Callable") var update_action = update
func _ready():
update()
%QuotaRewardCard.clicked.connect(
func (_c : CardVisualiser):
card_clicked.emit(self)
)
is_ready = true
func update():
if info:
%QuotaRewardTitle.text = info.title
%QuotaRewardText.text = info.text
%QuotaRewardCard.card_info = info.card_info
%QuotaRewardCard.update()

View File

@@ -0,0 +1 @@
uid://bhhhw2ywxmmba

View File

@@ -0,0 +1,8 @@
extends Resource
class_name QuotaRewardChoiceInfo
@export var title : String = ""
@export var text : String = ""
@export var card_info : CardInfo = null

View File

@@ -0,0 +1 @@
uid://bist0wp4nrswp

View File

@@ -0,0 +1,122 @@
@tool
extends CanvasLayer
class_name QuotaReward
const REWARD_CHOICE_SCENE : PackedScene = preload("res://gui/game/quota_reward/quota_reward_choice/quota_reward_choice.tscn")
signal reward_chosen
var showing_rewards: bool = false
var rewards : Array[QuotaReward.RewardData] = []
func _ready():
%RewardChoiceContainer.visible = false
func show_rewards():
showing_rewards = true
%AnimationPlayer.play("show")
func hide_rewards():
showing_rewards = false
%AnimationPlayer.play_backwards("show")
func generate_rewards(nb : int = 3):
var new_rewards : Array[QuotaReward.RewardData] = []
var max_retry = 20
while len(new_rewards) < nb or max_retry < 0:
max_retry -= 1
var new_reward = (
generate_discover_plant_reward()
if len(GameInfo.game_data.unlocked_plant_types) == 0 or randi() % 2 == 0
else generate_evolution_plant_reward()
)
if new_rewards.find_custom(func(r): return r.reward_info().title == new_reward.reward_info().title) == -1:
new_rewards.append(new_reward)
else :
max_retry -= 1
rewards = new_rewards
func generate_rewards_choices():
for c in %ChoicesContainer.get_children():
c.queue_free()
for r in rewards:
var reward_choice : QuotaRewardChoice = REWARD_CHOICE_SCENE.instantiate() as QuotaRewardChoice
reward_choice.info = r.reward_info()
reward_choice.card_clicked.connect(
func (_c):
if showing_rewards: choose_reward(r)
)
%ChoicesContainer.add_child(reward_choice)
func generate_discover_plant_reward() -> RewardData:
return DiscoverPlantReward.new(
GameInfo.game_data.get_locked_plant_types().pick_random()
)
func generate_evolution_plant_reward() -> RewardData:
return EvolvePlantReward.new(
GameInfo.game_data.unlocked_plant_types.pick_random().get_available_evolution().pick_random()
)
func choose_reward(r : RewardData):
r.reward()
reward_chosen.emit()
hide_rewards()
func trigger_reward():
generate_rewards()
generate_rewards_choices()
show_rewards()
class RewardData:
func reward_info() -> QuotaRewardChoiceInfo:
return null
func reward():
pass
class DiscoverPlantReward extends RewardData:
var new_plant_type : PlantType
func _init(_new_plant_type):
new_plant_type = _new_plant_type
func reward_info() -> QuotaRewardChoiceInfo:
var info = QuotaRewardChoiceInfo.new()
info.title = "Discover %s" % new_plant_type.name
info.text = "%s seeds can now be found" % new_plant_type.name
info.card_info = new_plant_type.card_info()
return info
func reward():
GameInfo.game_data.unlock_plant_type(new_plant_type)
class EvolvePlantReward extends RewardData:
var plant_evolution : PlantType.Evolution
func _init(_plant_evolution):
plant_evolution = _plant_evolution
func reward_info() -> QuotaRewardChoiceInfo:
var info = QuotaRewardChoiceInfo.new()
info.title = "Evolve %s" % plant_evolution.plant_type.name
info.text = plant_evolution.get_description()
var preview_evolved_plant = plant_evolution.plant_type.duplicate_deep()
plant_evolution.evolve(preview_evolved_plant)
info.card_info = preview_evolved_plant.card_info()
return info
func reward():
plant_evolution.evolve()

View File

@@ -1,177 +0,0 @@
[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_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="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="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"]

View File

@@ -1,39 +0,0 @@
extends Control
var planet: Planet
var item1: Item
var item2: Item
func show_rewards():
get_tree().paused = true
%AnimationPlayer.play("show")
get_tree().paused = true
func hide_rewards():
get_tree().paused = false
%AnimationPlayer.play_backwards("show")
get_tree().paused = false
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()

View File

@@ -1,7 +1,7 @@
extends Control
class_name GameGui
signal pause_asked
@export var quota_reward : QuotaReward
func _ready():
GameInfo.game_data.current_planet_data.updated.connect(_on_planet_updated)
@@ -9,12 +9,14 @@ func _ready():
GameInfo.game_data.player_data.updated.connect(_on_player_updated)
GameInfo.game_data.player_data.inventory.updated.connect(_on_inventory_updated)
if not GameInfo.game_data.current_planet_data.is_quota_announced:
announce_quota(GameInfo.game_data.current_planet_data)
GameInfo.game_data.current_planet_data.is_quota_announced = true
planet_update(GameInfo.game_data.current_planet_data)
player_update(GameInfo.game_data.player_data)
inventory_update(GameInfo.game_data.player_data.inventory)
if not GameInfo.game_data.current_planet_data.is_quota_announced:
await quota_reward.reward_chosen
announce_quota(GameInfo.game_data.current_planet_data)
GameInfo.game_data.current_planet_data.is_quota_announced = true
func _on_player_updated(player_data : PlayerData):
@@ -73,8 +75,9 @@ func update_no_energy_left_info(energy):
func _on_planet_new_quota_started(planet_data : PlanetData):
announce_quota(planet_data)
planet_update(planet_data)
await quota_reward.reward_chosen
announce_quota(planet_data)
planet_data.is_quota_announced = true

View File

@@ -1,7 +1,5 @@
extends Node
signal inspected_changed(info : Inspector.Info)
const DEFAULT_ACTION_COLOR = Color.WHITE
const ENERGY_ACTION_COLOR = Color("ffff2b")
const NO_ENERGY_ACTION_COLOR = Color.RED
@@ -9,12 +7,13 @@ const ZONE_OPACITY = 0.4
const ZONE_ACTIVATED_COLOR = Color.TURQUOISE
const ZONE_DEACTIVATED_COLOR = Color.REBECCA_PURPLE
const CARD_VISUALISATION_TIME = 1.0
const CARD_VISUALISATION_TIME = 0.5
@export var default_cursor : Texture2D
var current_inspect : Node = null
var inspected : Node = null
var last_inspected : Node = null
var inspected_card_info : CardInfo = null
var time_last_inspected : float = 0.
var player : Player # renseigné par Player
var can_interact : bool = false
@@ -38,7 +37,7 @@ func _input(_event):
if Input.is_action_just_pressed("action"):
if can_interact:
var interactable = inspected as Interactable
var interactable = current_inspect as Interactable
player.try_interact(interactable)
elif can_use_item:
player.try_use_item(
@@ -47,14 +46,15 @@ func _input(_event):
)
func _process(delta):
time_last_inspected += delta
if current_inspect != inspected:
time_last_inspected += delta
%Inspector.position = get_viewport().get_mouse_position()
if player:
can_interact = (
inspected
and inspected is Interactable
and player.can_interact(inspected)
current_inspect
and current_inspect is Interactable
and player.can_interact(current_inspect)
)
current_selected_item = player.data.inventory.get_item()
@@ -84,39 +84,42 @@ func _process(delta):
update_inspector()
func inspect(node : Node):
if inspected and inspected != node and inspected.has_method("inspect"):
inspected.inspect(false)
if current_inspect and current_inspect != node and current_inspect.has_method("inspect"):
current_inspect.inspect(false)
current_inspect = node
inspected = node
last_inspected = node
if inspected is InspectableEntity:
inspected_card_info = inspected.card_info()
time_last_inspected = 0
if inspected.has_method("inspect"):
inspected.inspect(true)
if current_inspect.has_method("inspect"):
current_inspect.inspect(true)
update_inspector()
func update_card():
if not last_inspected or time_last_inspected > CARD_VISUALISATION_TIME:
if not inspected or time_last_inspected > CARD_VISUALISATION_TIME:
%CardVisualiser.hide()
elif last_inspected != null and last_inspected is InspectableEntity:
%CardVisualiser.card_info = last_inspected.card_info()
elif inspected != null and inspected is InspectableEntity:
if inspected_card_info != %CardVisualiser.card_info:
%CardVisualiser.card_info = inspected_card_info
%CardVisualiser.show()
var camera = get_viewport().get_camera_2d()
var screen_size = get_viewport().get_visible_rect().size
%CardPosition.position = last_inspected.global_position - camera.global_position + screen_size / 2
%CardPosition.position = inspected.global_position - camera.global_position + screen_size / 2
if %CardVisualiser.is_mouse_over():
time_last_inspected = 0.
func update_inspector():
if player:
if can_interact and inspected and inspected is Interactable:
if can_interact and current_inspect and current_inspect is Interactable:
%Action.visible = true
%ActionText.text = inspected.interact_text()
%Action.modulate = DEFAULT_ACTION_COLOR if inspected.interaction_cost(player) == 0 else ENERGY_ACTION_COLOR
%ActionEnergyImage.visible = inspected.interaction_cost(player) != 0
%ActionText.text = current_inspect.interact_text()
%Action.modulate = DEFAULT_ACTION_COLOR if current_inspect.interaction_cost(player) == 0 else ENERGY_ACTION_COLOR
%ActionEnergyImage.visible = current_inspect.interaction_cost(player) != 0
elif current_selected_item and current_selected_item.use_text() != "":
%Action.visible = true
%ActionText.text = current_selected_item.use_text() + (" (no energy left)" if not have_energy_to_use_item else "")
@@ -134,6 +137,6 @@ func update_inspector():
func stop_inspect(node : Node):
if node.has_method("inspect"):
node.inspect(false)
if inspected == node:
inspected = null
if current_inspect == node:
current_inspect = null
update_inspector()