ajout d'une animation de recharge et réparation du crash au chargement de chunk
This commit is contained in:
58
gui/game/energy_info/energy_info.tscn
Normal file
58
gui/game/energy_info/energy_info.tscn
Normal file
@@ -0,0 +1,58 @@
|
||||
[gd_scene load_steps=6 format=3 uid="uid://brfsapvj2quxm"]
|
||||
|
||||
[ext_resource type="Script" uid="uid://0dhj8sdpil7q" path="res://gui/tools/control_animation_player.gd" id="1_g7kwx"]
|
||||
[ext_resource type="Script" uid="uid://b77b1yr81r462" path="res://gui/game/energy_info/scripts/energy_info.gd" id="1_h7p5h"]
|
||||
[ext_resource type="Theme" uid="uid://bgcmd213j6gk1" path="res://gui/ressources/hud.tres" id="2_h7p5h"]
|
||||
[ext_resource type="FontFile" uid="uid://qt80w6o01q5s" path="res://gui/ressources/fonts/TitanOne-Regular.ttf" id="3_c14dn"]
|
||||
[ext_resource type="Texture2D" uid="uid://dcgnamu7sb3ov" path="res://common/icons/bolt.svg" id="4_rqwov"]
|
||||
|
||||
[node name="EnergyInfo" type="HBoxContainer"]
|
||||
modulate = Color(1, 0, 0, 1)
|
||||
offset_right = 167.0
|
||||
offset_bottom = 75.0
|
||||
size_flags_horizontal = 2
|
||||
size_flags_vertical = 0
|
||||
theme_override_constants/separation = 0
|
||||
alignment = 1
|
||||
script = ExtResource("1_h7p5h")
|
||||
wanted_max_energy = 3
|
||||
|
||||
[node name="EnergyAnimationPlayer" type="Node" parent="."]
|
||||
unique_name_in_owner = true
|
||||
script = ExtResource("1_g7kwx")
|
||||
metadata/_custom_type_script = "uid://0dhj8sdpil7q"
|
||||
|
||||
[node name="MarginContainer" type="MarginContainer" parent="."]
|
||||
layout_mode = 2
|
||||
size_flags_horizontal = 0
|
||||
size_flags_vertical = 0
|
||||
theme_override_constants/margin_left = 0
|
||||
theme_override_constants/margin_top = -25
|
||||
theme_override_constants/margin_right = 0
|
||||
theme_override_constants/margin_bottom = -15
|
||||
|
||||
[node name="EnergyCount" type="RichTextLabel" parent="MarginContainer"]
|
||||
unique_name_in_owner = true
|
||||
layout_mode = 2
|
||||
theme = ExtResource("2_h7p5h")
|
||||
theme_override_fonts/normal_font = ExtResource("3_c14dn")
|
||||
theme_override_fonts/bold_font = ExtResource("3_c14dn")
|
||||
theme_override_fonts/bold_italics_font = ExtResource("3_c14dn")
|
||||
theme_override_fonts/italics_font = ExtResource("3_c14dn")
|
||||
theme_override_font_sizes/normal_font_size = 30
|
||||
theme_override_font_sizes/bold_font_size = 100
|
||||
bbcode_enabled = true
|
||||
text = "[b]0[/b] / 3"
|
||||
fit_content = true
|
||||
autowrap_mode = 0
|
||||
horizontal_alignment = 1
|
||||
vertical_alignment = 1
|
||||
|
||||
[node name="Icon" type="TextureRect" parent="."]
|
||||
custom_minimum_size = Vector2(50, 50)
|
||||
layout_mode = 2
|
||||
size_flags_horizontal = 4
|
||||
size_flags_vertical = 8
|
||||
texture = ExtResource("4_rqwov")
|
||||
expand_mode = 4
|
||||
stretch_mode = 5
|
||||
37
gui/game/energy_info/scripts/energy_info.gd
Normal file
37
gui/game/energy_info/scripts/energy_info.gd
Normal file
@@ -0,0 +1,37 @@
|
||||
@tool
|
||||
extends HBoxContainer
|
||||
class_name EnergyInfo
|
||||
|
||||
@export var wanted_energy = 0
|
||||
@export var wanted_max_energy = 0
|
||||
|
||||
var energy := 0
|
||||
var max_energy := 0
|
||||
|
||||
@export_tool_button("Update", "Callable") var update_action = func(): update(wanted_energy, wanted_max_energy)
|
||||
|
||||
func _ready():
|
||||
%EnergyAnimationPlayer.disappear()
|
||||
|
||||
func update(
|
||||
_energy : int,
|
||||
_max_energy : int,
|
||||
with_animation := true,
|
||||
):
|
||||
var changed = (energy != _energy or max_energy != _max_energy)
|
||||
if changed:
|
||||
print("Energy change with %d/%d" % [_energy, _max_energy])
|
||||
energy = _energy
|
||||
max_energy = _max_energy
|
||||
var energy_count_text = "[b]%d[/b] / %d" % [energy, max_energy]
|
||||
|
||||
if with_animation:
|
||||
%EnergyAnimationPlayer.bounce()
|
||||
%EnergyCount.text = energy_count_text
|
||||
modulate = Color.WHITE if energy > 0 else Color.RED
|
||||
|
||||
func appear():
|
||||
await %EnergyAnimationPlayer.appear()
|
||||
|
||||
func disappear():
|
||||
await %EnergyAnimationPlayer.disappear()
|
||||
1
gui/game/energy_info/scripts/energy_info.gd.uid
Normal file
1
gui/game/energy_info/scripts/energy_info.gd.uid
Normal file
@@ -0,0 +1 @@
|
||||
uid://b77b1yr81r462
|
||||
@@ -1,12 +1,10 @@
|
||||
[gd_scene load_steps=22 format=3 uid="uid://12nak7amd1uq"]
|
||||
[gd_scene load_steps=16 format=3 uid="uid://12nak7amd1uq"]
|
||||
|
||||
[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://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="Texture2D" uid="uid://dcgnamu7sb3ov" path="res://common/icons/bolt.svg" id="4_k4juk"]
|
||||
[ext_resource type="LabelSettings" uid="uid://dqwayi8yjwau2" path="res://gui/ressources/title_label_settings.tres" id="4_ujg5r"]
|
||||
[ext_resource type="FontFile" uid="uid://qt80w6o01q5s" path="res://gui/ressources/fonts/TitanOne-Regular.ttf" id="5_2wykm"]
|
||||
[ext_resource type="Script" uid="uid://0dhj8sdpil7q" path="res://gui/tools/control_animation_player.gd" id="6_id0t5"]
|
||||
[ext_resource type="Texture2D" uid="uid://bt3g5bmar0icf" path="res://common/icons/growth.svg" id="7_id0t5"]
|
||||
[ext_resource type="PackedScene" uid="uid://clicjf8ts51h8" path="res://gui/game/inventory_gui/inventory_gui.tscn" id="9_id0t5"]
|
||||
|
||||
@@ -19,71 +17,6 @@ gradient = SubResource("Gradient_2wykm")
|
||||
fill = 1
|
||||
fill_from = Vector2(0.5, 0.5)
|
||||
|
||||
[sub_resource type="Animation" id="Animation_iyvkh"]
|
||||
length = 0.001
|
||||
tracks/0/type = "value"
|
||||
tracks/0/imported = false
|
||||
tracks/0/enabled = true
|
||||
tracks/0/path = NodePath("PassDayFade:color")
|
||||
tracks/0/interp = 1
|
||||
tracks/0/loop_wrap = true
|
||||
tracks/0/keys = {
|
||||
"times": PackedFloat32Array(0),
|
||||
"transitions": PackedFloat32Array(1),
|
||||
"update": 0,
|
||||
"values": [Color(0.0627451, 0.0588235, 0.168627, 0)]
|
||||
}
|
||||
tracks/1/type = "value"
|
||||
tracks/1/imported = false
|
||||
tracks/1/enabled = true
|
||||
tracks/1/path = NodePath("Effect: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_id0t5"]
|
||||
resource_name = "not_permitted"
|
||||
length = 0.5
|
||||
tracks/0/type = "value"
|
||||
tracks/0/imported = false
|
||||
tracks/0/enabled = true
|
||||
tracks/0/path = NodePath("Effect:modulate")
|
||||
tracks/0/interp = 1
|
||||
tracks/0/loop_wrap = true
|
||||
tracks/0/keys = {
|
||||
"times": PackedFloat32Array(0, 0.1, 0.266667),
|
||||
"transitions": PackedFloat32Array(1, 1, 1),
|
||||
"update": 0,
|
||||
"values": [Color(0.866667, 0.152941, 0.337255, 0), Color(0.866667, 0.152941, 0.337255, 0.392157), Color(0.866667, 0.152941, 0.337255, 0)]
|
||||
}
|
||||
|
||||
[sub_resource type="Animation" id="Animation_ykapk"]
|
||||
resource_name = "pass_day"
|
||||
tracks/0/type = "value"
|
||||
tracks/0/imported = false
|
||||
tracks/0/enabled = true
|
||||
tracks/0/path = NodePath("PassDayFade:color")
|
||||
tracks/0/interp = 2
|
||||
tracks/0/loop_wrap = true
|
||||
tracks/0/keys = {
|
||||
"times": PackedFloat32Array(0, 0.4, 0.6, 1),
|
||||
"transitions": PackedFloat32Array(1, 1, 1, 1),
|
||||
"update": 0,
|
||||
"values": [Color(0.0627451, 0.0588235, 0.168627, 0), Color(0.0627451, 0.0588235, 0.168627, 1), Color(0.0627451, 0.0588235, 0.168627, 1), Color(0.0627451, 0.0588235, 0.168627, 0)]
|
||||
}
|
||||
|
||||
[sub_resource type="AnimationLibrary" id="AnimationLibrary_n4kem"]
|
||||
_data = {
|
||||
&"RESET": SubResource("Animation_iyvkh"),
|
||||
&"not_permitted": SubResource("Animation_id0t5"),
|
||||
&"pass_day": SubResource("Animation_ykapk")
|
||||
}
|
||||
|
||||
[sub_resource type="Animation" id="Animation_l3q4a"]
|
||||
length = 0.001
|
||||
tracks/0/type = "value"
|
||||
@@ -158,52 +91,9 @@ grow_vertical = 2
|
||||
mouse_filter = 2
|
||||
theme = ExtResource("2_nq5i2")
|
||||
|
||||
[node name="EnergyInfo" type="HBoxContainer" parent="MarginContainer"]
|
||||
[node name="EnergyInfo" parent="MarginContainer" instance=ExtResource("4_2wykm")]
|
||||
unique_name_in_owner = true
|
||||
layout_mode = 2
|
||||
size_flags_vertical = 0
|
||||
theme_override_constants/separation = 0
|
||||
metadata/_edit_use_anchors_ = true
|
||||
|
||||
[node name="EnergyAnimationPlayer" type="Node" parent="MarginContainer/EnergyInfo"]
|
||||
unique_name_in_owner = true
|
||||
script = ExtResource("6_id0t5")
|
||||
metadata/_custom_type_script = "uid://0dhj8sdpil7q"
|
||||
|
||||
[node name="MarginContainer" type="MarginContainer" parent="MarginContainer/EnergyInfo"]
|
||||
layout_mode = 2
|
||||
size_flags_horizontal = 0
|
||||
size_flags_vertical = 0
|
||||
theme_override_constants/margin_left = 0
|
||||
theme_override_constants/margin_top = -25
|
||||
theme_override_constants/margin_right = 0
|
||||
theme_override_constants/margin_bottom = -15
|
||||
|
||||
[node name="EnergyCount" type="RichTextLabel" parent="MarginContainer/EnergyInfo/MarginContainer"]
|
||||
unique_name_in_owner = true
|
||||
layout_mode = 2
|
||||
theme = ExtResource("2_nq5i2")
|
||||
theme_override_fonts/normal_font = ExtResource("5_2wykm")
|
||||
theme_override_fonts/bold_font = ExtResource("5_2wykm")
|
||||
theme_override_fonts/bold_italics_font = ExtResource("5_2wykm")
|
||||
theme_override_fonts/italics_font = ExtResource("5_2wykm")
|
||||
theme_override_font_sizes/normal_font_size = 30
|
||||
theme_override_font_sizes/bold_font_size = 100
|
||||
bbcode_enabled = true
|
||||
text = "[b]X[/b] / X"
|
||||
fit_content = true
|
||||
autowrap_mode = 0
|
||||
horizontal_alignment = 1
|
||||
vertical_alignment = 1
|
||||
|
||||
[node name="Icon" type="TextureRect" parent="MarginContainer/EnergyInfo"]
|
||||
custom_minimum_size = Vector2(50, 50)
|
||||
layout_mode = 2
|
||||
size_flags_horizontal = 4
|
||||
size_flags_vertical = 8
|
||||
texture = ExtResource("4_k4juk")
|
||||
expand_mode = 4
|
||||
stretch_mode = 5
|
||||
|
||||
[node name="VBoxContainer" type="VBoxContainer" parent="MarginContainer"]
|
||||
layout_mode = 2
|
||||
@@ -258,16 +148,6 @@ layout_mode = 2
|
||||
size_flags_horizontal = 4
|
||||
size_flags_vertical = 8
|
||||
|
||||
[node name="PassDayFade" type="ColorRect" parent="."]
|
||||
physics_interpolation_mode = 0
|
||||
anchors_preset = 15
|
||||
anchor_right = 1.0
|
||||
anchor_bottom = 1.0
|
||||
grow_horizontal = 2
|
||||
grow_vertical = 2
|
||||
mouse_filter = 2
|
||||
color = Color(0.0627451, 0.0588235, 0.168627, 0)
|
||||
|
||||
[node name="Effect" type="TextureRect" parent="."]
|
||||
modulate = Color(1, 1, 1, 0)
|
||||
anchors_preset = 15
|
||||
@@ -278,11 +158,6 @@ grow_vertical = 2
|
||||
mouse_filter = 2
|
||||
texture = SubResource("GradientTexture2D_id0t5")
|
||||
|
||||
[node name="PassDayAnimation" type="AnimationPlayer" parent="."]
|
||||
libraries = {
|
||||
&"": SubResource("AnimationLibrary_n4kem")
|
||||
}
|
||||
|
||||
[node name="EffectAnimation" type="AnimationPlayer" parent="."]
|
||||
root_node = NodePath("../Effect")
|
||||
libraries = {
|
||||
|
||||
50
gui/game/pass_day/pass_day.tscn
Normal file
50
gui/game/pass_day/pass_day.tscn
Normal file
@@ -0,0 +1,50 @@
|
||||
[gd_scene load_steps=6 format=3 uid="uid://yk78ubpu5ghq"]
|
||||
|
||||
[ext_resource type="Script" uid="uid://2qomrdxbvxqa" path="res://gui/game/pass_day/scripts/pass_day.gd" id="1_0pm4g"]
|
||||
[ext_resource type="Shader" uid="uid://cuni3ggtw2uuy" path="res://common/vfx/materials/shaders/blur.gdshader" id="1_v570a"]
|
||||
[ext_resource type="Script" uid="uid://i7glvbe8pdr8" path="res://gui/game/pass_day/scripts/pass_day_background.gd" id="2_bhfpo"]
|
||||
[ext_resource type="PackedScene" uid="uid://brfsapvj2quxm" path="res://gui/game/energy_info/energy_info.tscn" id="2_feyaf"]
|
||||
|
||||
[sub_resource type="ShaderMaterial" id="ShaderMaterial_27lg1"]
|
||||
shader = ExtResource("1_v570a")
|
||||
shader_parameter/strength = 0.1
|
||||
shader_parameter/mix_percentage = 0.0
|
||||
|
||||
[node name="PassDay" type="Control"]
|
||||
visible = false
|
||||
z_index = 100
|
||||
layout_mode = 3
|
||||
anchors_preset = 15
|
||||
anchor_right = 1.0
|
||||
anchor_bottom = 1.0
|
||||
grow_horizontal = 2
|
||||
grow_vertical = 2
|
||||
script = ExtResource("1_0pm4g")
|
||||
|
||||
[node name="Blur" type="ColorRect" parent="."]
|
||||
unique_name_in_owner = true
|
||||
physics_interpolation_mode = 0
|
||||
material = SubResource("ShaderMaterial_27lg1")
|
||||
layout_mode = 1
|
||||
anchors_preset = 15
|
||||
anchor_right = 1.0
|
||||
anchor_bottom = 1.0
|
||||
grow_horizontal = 2
|
||||
grow_vertical = 2
|
||||
mouse_filter = 2
|
||||
script = ExtResource("2_bhfpo")
|
||||
blur_strength = 0.1
|
||||
|
||||
[node name="EnergyPassDayInfo" parent="." instance=ExtResource("2_feyaf")]
|
||||
unique_name_in_owner = true
|
||||
modulate = Color(1, 1, 1, 0)
|
||||
layout_mode = 1
|
||||
anchors_preset = 14
|
||||
anchor_top = 0.5
|
||||
anchor_right = 1.0
|
||||
anchor_bottom = 0.5
|
||||
offset_top = -37.5
|
||||
offset_right = 0.0
|
||||
offset_bottom = 37.5
|
||||
grow_horizontal = 2
|
||||
grow_vertical = 2
|
||||
113
gui/game/pass_day/scripts/pass_day.gd
Normal file
113
gui/game/pass_day/scripts/pass_day.gd
Normal file
@@ -0,0 +1,113 @@
|
||||
@tool
|
||||
extends Control
|
||||
class_name PassDay
|
||||
|
||||
const BLUR_STRENGTH = 10
|
||||
const BLUR_MIX_PERCENTAGE = 0.8
|
||||
const TIME_BY_ENERGY = 0.7
|
||||
const TIME_MARGIN = 0.5
|
||||
|
||||
signal max_energy_reached()
|
||||
signal animation_appeared
|
||||
signal animation_disappeared
|
||||
|
||||
@export_tool_button("Pass Day", "Callable") var pass_day_action = pass_day_animation
|
||||
@export_tool_button("Appear", "Callable") var appear_action = appear
|
||||
@export var from_energy = 0
|
||||
@export var max_energy = 3
|
||||
var current_energy = 0
|
||||
|
||||
var time_since_recharging = 0.
|
||||
var recharging = false
|
||||
|
||||
var is_animation_appeared := false
|
||||
var is_animation_disappeared := false
|
||||
|
||||
func _ready():
|
||||
hide()
|
||||
setup_energy_values()
|
||||
|
||||
func _process(delta):
|
||||
if recharging:
|
||||
time_since_recharging += delta
|
||||
var new_current_energy = from_energy + roundi(time_since_recharging/TIME_BY_ENERGY)
|
||||
if new_current_energy > max_energy:
|
||||
max_energy_reached.emit()
|
||||
elif (new_current_energy != current_energy):
|
||||
%EnergyPassDayInfo.update(new_current_energy, max_energy, true)
|
||||
print("Call energy info with %d/%d" % [new_current_energy, max_energy])
|
||||
current_energy = new_current_energy
|
||||
|
||||
func setup_energy_values():
|
||||
if not Engine.is_editor_hint():
|
||||
from_energy = GameInfo.game_data.player_data.energy
|
||||
max_energy = GameInfo.game_data.player_data.max_energy
|
||||
current_energy = from_energy
|
||||
|
||||
func pass_day_animation():
|
||||
|
||||
setup_energy_values()
|
||||
|
||||
is_animation_appeared=false
|
||||
is_animation_disappeared=false
|
||||
|
||||
%EnergyPassDayInfo.update(from_energy, max_energy, false)
|
||||
print("Call energy info with %d/%d" % [from_energy, max_energy])
|
||||
|
||||
await appear()
|
||||
is_animation_appeared = true
|
||||
animation_appeared.emit()
|
||||
await get_tree().create_timer(TIME_MARGIN).timeout
|
||||
recharging = true
|
||||
time_since_recharging = 0.
|
||||
await max_energy_reached
|
||||
await get_tree().create_timer(TIME_MARGIN).timeout
|
||||
await disappear()
|
||||
is_animation_disappeared=true
|
||||
animation_disappeared.emit()
|
||||
recharging = false
|
||||
|
||||
func appear():
|
||||
show()
|
||||
add_tween(
|
||||
"blur_mix_percentage",
|
||||
%Blur,
|
||||
BLUR_MIX_PERCENTAGE,
|
||||
0.5
|
||||
)
|
||||
await add_tween(
|
||||
"blur_strength",
|
||||
%Blur,
|
||||
BLUR_STRENGTH,
|
||||
0.5
|
||||
).finished
|
||||
await %EnergyPassDayInfo.appear()
|
||||
|
||||
func disappear():
|
||||
await %EnergyPassDayInfo.disappear()
|
||||
add_tween(
|
||||
"blur_mix_percentage",
|
||||
%Blur,
|
||||
0.0,
|
||||
0.5
|
||||
)
|
||||
await add_tween(
|
||||
"blur_strength",
|
||||
%Blur,
|
||||
0.1,
|
||||
0.5
|
||||
).finished
|
||||
hide()
|
||||
|
||||
func add_tween(
|
||||
property : String,
|
||||
target: Node,
|
||||
value : Variant,
|
||||
seconds: float = 1.,
|
||||
transition_type: Tween.TransitionType = Tween.TransitionType.TRANS_LINEAR
|
||||
) -> Tween:
|
||||
var tween : Tween = get_tree().create_tween()
|
||||
tween.set_trans(transition_type)
|
||||
tween.tween_property(target, property, value, seconds)
|
||||
tween.set_pause_mode(Tween.TWEEN_PAUSE_PROCESS)
|
||||
return tween
|
||||
1
gui/game/pass_day/scripts/pass_day.gd.uid
Normal file
1
gui/game/pass_day/scripts/pass_day.gd.uid
Normal file
@@ -0,0 +1 @@
|
||||
uid://2qomrdxbvxqa
|
||||
21
gui/game/pass_day/scripts/pass_day_background.gd
Normal file
21
gui/game/pass_day/scripts/pass_day_background.gd
Normal file
@@ -0,0 +1,21 @@
|
||||
@tool
|
||||
extends ColorRect
|
||||
class_name PassDayBackground
|
||||
|
||||
@export var blur_strength := 0. :
|
||||
set(v):
|
||||
blur_strength = v
|
||||
if is_node_ready():
|
||||
update_shader_material_parameter()
|
||||
@export var blur_mix_percentage := 0. :
|
||||
set(v):
|
||||
blur_mix_percentage = v
|
||||
if is_node_ready():
|
||||
update_shader_material_parameter()
|
||||
|
||||
func _ready():
|
||||
update_shader_material_parameter()
|
||||
|
||||
func update_shader_material_parameter():
|
||||
material.set_shader_parameter("strength", blur_strength)
|
||||
material.set_shader_parameter("mix_percentage", blur_mix_percentage)
|
||||
1
gui/game/pass_day/scripts/pass_day_background.gd.uid
Normal file
1
gui/game/pass_day/scripts/pass_day_background.gd.uid
Normal file
@@ -0,0 +1 @@
|
||||
uid://i7glvbe8pdr8
|
||||
@@ -12,20 +12,16 @@ func _ready():
|
||||
planet_update(GameInfo.game_data.current_planet_data, false)
|
||||
player_update(GameInfo.game_data.player_data, false)
|
||||
inventory_update(GameInfo.game_data.player_data.inventory)
|
||||
|
||||
%EnergyInfo.update_minimum_size()
|
||||
|
||||
|
||||
func _on_player_updated(player_data : PlayerData):
|
||||
player_update(player_data)
|
||||
|
||||
func player_update(player_data : PlayerData, with_animation = true):
|
||||
var energy_count_text = "[b]%d[/b] / %d" % [player_data.energy, player_data.max_energy]
|
||||
|
||||
if energy_count_text != %EnergyCount.text and with_animation:
|
||||
%EnergyAnimationPlayer.bounce()
|
||||
%EnergyCount.text = energy_count_text
|
||||
%EnergyInfo.modulate = Color.WHITE if player_data.energy > 0 else Color.RED
|
||||
%EnergyInfo.update(
|
||||
player_data.energy,
|
||||
player_data.max_energy,
|
||||
with_animation
|
||||
)
|
||||
|
||||
func _on_inventory_updated(inventory : Inventory):
|
||||
inventory_update(inventory)
|
||||
@@ -97,11 +93,8 @@ func _on_player_action_tried_without_energy():
|
||||
func _on_player_upgraded():
|
||||
$EffectAnimation.play("upgrade")
|
||||
|
||||
func _on_planet_pass_day_started(planet):
|
||||
$PassDayAnimation.speed_scale = 1/(planet.PASS_DAY_ANIMATION_TIME)
|
||||
$PassDayAnimation.play("pass_day")
|
||||
await $PassDayAnimation.animation_finished
|
||||
$PassDayAnimation.speed_scale = 1
|
||||
func _on_planet_pass_day_started(_planet):
|
||||
%PassDay.pass_day_animation()
|
||||
|
||||
func _on_planet_pass_day_ended(planet:Planet):
|
||||
if planet.data.charges == 1:
|
||||
|
||||
@@ -125,28 +125,9 @@ class TakeSeedStep extends Step:
|
||||
|
||||
class PlantSeedStep extends Step:
|
||||
func generate_indicators(p: Player, planet : Planet) -> Array[InGameIndicator]:
|
||||
|
||||
var closest_decontamination = null
|
||||
var limit_distance = 1000
|
||||
|
||||
var actual_distance = 100
|
||||
var player_tile = Math.get_tile_from_pos(p.global_position)
|
||||
|
||||
while closest_decontamination == null and actual_distance < limit_distance:
|
||||
for x in range(actual_distance):
|
||||
for y in range(actual_distance):
|
||||
var coord = Vector2i(x,y) - Vector2i.ONE * floori(actual_distance/2.) + player_tile
|
||||
if planet.decontamination_layer.is_decontamined(coord):
|
||||
if closest_decontamination == null or player_tile.distance_to(coord) < player_tile.distance_to(closest_decontamination):
|
||||
closest_decontamination = coord
|
||||
|
||||
actual_distance += 100
|
||||
|
||||
if closest_decontamination:
|
||||
var indicator = generate_indicator(tr("PLANT_THE_SEED_IN_DECONTAMINED_ZONE"))
|
||||
indicator.follow_game_position(closest_decontamination * Planet.TILE_SIZE + Vector2i.ONE * floori(Planet.TILE_SIZE/2.))
|
||||
return [indicator]
|
||||
return []
|
||||
var indicator = generate_indicator(tr("PLANT_THE_SEED_IN_DECONTAMINED_ZONE"))
|
||||
indicator.follow_game_position(Planet.CHUNK_TILE_SIZE/2. * Planet.TILE_SIZE * Vector2.ONE)
|
||||
return [indicator]
|
||||
|
||||
func is_step_over(_p : Player, planet : Planet) -> bool:
|
||||
for entity in planet.entity_container.get_children():
|
||||
|
||||
@@ -10,22 +10,22 @@ const ZONE_DEACTIVATED_COLOR = Color.REBECCA_PURPLE
|
||||
const CARD_VISUALISATION_TIME = 0.5
|
||||
const CARD_UP_PADDING = 50
|
||||
|
||||
@export var default_cursor: Texture2D
|
||||
@export var default_cursor : Texture2D
|
||||
|
||||
var current_inspect: Node = null
|
||||
var 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
|
||||
var current_selected_item: Item = null
|
||||
var have_energy_to_use_item: bool = false
|
||||
var could_use_item: bool = false
|
||||
var can_use_item: bool = false
|
||||
var current_inspect : Node = null
|
||||
var 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
|
||||
var current_selected_item : Item = null
|
||||
var have_energy_to_use_item : bool = false
|
||||
var could_use_item : bool = false
|
||||
var can_use_item : bool = false
|
||||
|
||||
func _ready():
|
||||
Input.set_custom_mouse_cursor(default_cursor)
|
||||
%Action.visible = false
|
||||
%Action.visible = false
|
||||
|
||||
func _input(_event):
|
||||
if player:
|
||||
@@ -58,7 +58,7 @@ func _process(delta):
|
||||
and player.can_interact(current_inspect)
|
||||
)
|
||||
|
||||
current_selected_item = player.data.inventory.get_item()
|
||||
current_selected_item = player.data.inventory.get_item()
|
||||
|
||||
could_use_item = (
|
||||
current_selected_item
|
||||
@@ -145,11 +145,10 @@ func update_inspector():
|
||||
%ActionEnergyImage.visible = current_selected_item.energy_usage != 0
|
||||
else:
|
||||
%Action.visible = false
|
||||
|
||||
else:
|
||||
%Action.visible = false
|
||||
|
||||
func stop_inspect(node: Node):
|
||||
func stop_inspect(node : Node):
|
||||
if node.has_method("inspect"):
|
||||
node.inspect(false)
|
||||
if current_inspect == node:
|
||||
|
||||
@@ -9,7 +9,6 @@ var on_animation = false
|
||||
@onready var target : Control = get_parent()
|
||||
|
||||
var target_default_pos : Vector2
|
||||
var target_default_modulate = Color.WHITE
|
||||
|
||||
@export_tool_button("Test Shake", "Callable") var shake_action = shake
|
||||
@export_tool_button("Test Bounce", "Callable") var bounce_action = bounce
|
||||
@@ -42,8 +41,8 @@ func fade_in(
|
||||
target.visible = true
|
||||
|
||||
await add_tween(
|
||||
"modulate",
|
||||
target_default_modulate,
|
||||
"modulate:a",
|
||||
1.,
|
||||
duration,
|
||||
transition_type
|
||||
).finished
|
||||
@@ -58,8 +57,8 @@ func fade_out(
|
||||
target.visible = true
|
||||
|
||||
await add_tween(
|
||||
"modulate",
|
||||
Color.TRANSPARENT,
|
||||
"modulate:a",
|
||||
0.,
|
||||
duration,
|
||||
transition_type
|
||||
).finished
|
||||
@@ -74,8 +73,8 @@ func disappear(
|
||||
):
|
||||
start_anim()
|
||||
add_tween(
|
||||
"modulate",
|
||||
Color.TRANSPARENT,
|
||||
"modulate:a",
|
||||
0.,
|
||||
duration,
|
||||
transition_type
|
||||
)
|
||||
@@ -87,6 +86,7 @@ func disappear(
|
||||
transition_type
|
||||
).finished
|
||||
|
||||
target.visible = false
|
||||
target.position = target_default_pos
|
||||
end_anim()
|
||||
|
||||
@@ -96,11 +96,12 @@ func appear(
|
||||
transition_type: Tween.TransitionType = Tween.TransitionType.TRANS_LINEAR,
|
||||
):
|
||||
start_anim()
|
||||
target.modulate = Color.TRANSPARENT
|
||||
target.visible = true
|
||||
target.modulate.a = 0.
|
||||
|
||||
add_tween(
|
||||
"modulate",
|
||||
target_default_modulate,
|
||||
"modulate:a",
|
||||
1.,
|
||||
duration,
|
||||
transition_type
|
||||
).finished
|
||||
|
||||
Reference in New Issue
Block a user