ajout du déblocage/évolutions des plantes (#89) et fix divers
This commit is contained in:
140
gui/game/quota_reward/quota_reward.tscn
Normal file
140
gui/game/quota_reward/quota_reward.tscn
Normal 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")
|
||||
}
|
||||
@@ -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")
|
||||
@@ -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()
|
||||
|
||||
@@ -0,0 +1 @@
|
||||
uid://bhhhw2ywxmmba
|
||||
@@ -0,0 +1,8 @@
|
||||
extends Resource
|
||||
class_name QuotaRewardChoiceInfo
|
||||
|
||||
@export var title : String = ""
|
||||
|
||||
@export var text : String = ""
|
||||
|
||||
@export var card_info : CardInfo = null
|
||||
@@ -0,0 +1 @@
|
||||
uid://bist0wp4nrswp
|
||||
122
gui/game/quota_reward/scripts/quota_reward.gd
Normal file
122
gui/game/quota_reward/scripts/quota_reward.gd
Normal 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()
|
||||
1
gui/game/quota_reward/scripts/quota_reward.gd.uid
Normal file
1
gui/game/quota_reward/scripts/quota_reward.gd.uid
Normal file
@@ -0,0 +1 @@
|
||||
uid://12kjdou2kp5y
|
||||
Reference in New Issue
Block a user