ChooseYourSeeds menu
This commit is contained in:
parent
91d85199a7
commit
c9dd4cf175
23 changed files with 471 additions and 95 deletions
7
assets/sprites/gui/ChooseYourSeeds/FrameField.tres
Normal file
7
assets/sprites/gui/ChooseYourSeeds/FrameField.tres
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
[gd_resource type="AtlasTexture" load_steps=2 format=3 uid="uid://dycdvvgmgmfu6"]
|
||||
|
||||
[ext_resource type="Texture2D" uid="uid://dvldjlg0nr355" path="res://assets/sprites/atlases/atlas1.png" id="1_es82j"]
|
||||
|
||||
[resource]
|
||||
atlas = ExtResource("1_es82j")
|
||||
region = Rect2(115, 300, 65, 65)
|
||||
7
assets/sprites/gui/ChooseYourSeeds/Grabber.tres
Normal file
7
assets/sprites/gui/ChooseYourSeeds/Grabber.tres
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
[gd_resource type="AtlasTexture" load_steps=2 format=3 uid="uid://b5skdm3q7tkh3"]
|
||||
|
||||
[ext_resource type="Texture2D" uid="uid://dvldjlg0nr355" path="res://assets/sprites/atlases/atlas1.png" id="1_bv8ko"]
|
||||
|
||||
[resource]
|
||||
atlas = ExtResource("1_bv8ko")
|
||||
region = Rect2(113, 414, 15, 32)
|
||||
7
assets/sprites/gui/ChooseYourSeeds/InnerPanel.tres
Normal file
7
assets/sprites/gui/ChooseYourSeeds/InnerPanel.tres
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
[gd_resource type="AtlasTexture" load_steps=2 format=3 uid="uid://bj5fouwjk3kum"]
|
||||
|
||||
[ext_resource type="Texture2D" uid="uid://dvldjlg0nr355" path="res://assets/sprites/atlases/atlas1.png" id="1_vi2yj"]
|
||||
|
||||
[resource]
|
||||
atlas = ExtResource("1_vi2yj")
|
||||
region = Rect2(113, 402, 14, 12)
|
||||
7
assets/sprites/gui/ChooseYourSeeds/LevelRun.tres
Normal file
7
assets/sprites/gui/ChooseYourSeeds/LevelRun.tres
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
[gd_resource type="AtlasTexture" load_steps=2 format=3 uid="uid://rpnw5lxm3ksb"]
|
||||
|
||||
[ext_resource type="Texture2D" uid="uid://dvldjlg0nr355" path="res://assets/sprites/atlases/atlas1.png" id="1_wytrb"]
|
||||
|
||||
[resource]
|
||||
atlas = ExtResource("1_wytrb")
|
||||
region = Rect2(87, 382, 41, 20)
|
||||
7
assets/sprites/gui/ChooseYourSeeds/Panel.tres
Normal file
7
assets/sprites/gui/ChooseYourSeeds/Panel.tres
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
[gd_resource type="AtlasTexture" load_steps=2 format=3 uid="uid://ci1a150qo2op2"]
|
||||
|
||||
[ext_resource type="Texture2D" uid="uid://dvldjlg0nr355" path="res://assets/sprites/atlases/atlas1.png" id="1_ugykr"]
|
||||
|
||||
[resource]
|
||||
atlas = ExtResource("1_ugykr")
|
||||
region = Rect2(87, 402, 26, 27)
|
||||
7
assets/sprites/gui/ChooseYourSeeds/PlantFrame.tres
Normal file
7
assets/sprites/gui/ChooseYourSeeds/PlantFrame.tres
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
[gd_resource type="AtlasTexture" load_steps=2 format=3 uid="uid://dr8a0rx42o3qy"]
|
||||
|
||||
[ext_resource type="Texture2D" uid="uid://dvldjlg0nr355" path="res://assets/sprites/atlases/atlas1.png" id="1_44qhk"]
|
||||
|
||||
[resource]
|
||||
atlas = ExtResource("1_44qhk")
|
||||
region = Rect2(38, 300, 77, 77)
|
||||
7
assets/sprites/gui/ChooseYourSeeds/Slider.tres
Normal file
7
assets/sprites/gui/ChooseYourSeeds/Slider.tres
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
[gd_resource type="AtlasTexture" load_steps=2 format=3 uid="uid://cv255d4s0qopj"]
|
||||
|
||||
[ext_resource type="Texture2D" uid="uid://dvldjlg0nr355" path="res://assets/sprites/atlases/atlas1.png" id="1_auh61"]
|
||||
|
||||
[resource]
|
||||
atlas = ExtResource("1_auh61")
|
||||
region = Rect2(129, 401, 13, 13)
|
||||
|
|
@ -3,11 +3,11 @@
|
|||
[ext_resource type="Script" path="res://scripts/components/level/RuntimeLevelData.cs" id="1_i3bf5"]
|
||||
[ext_resource type="Texture2D" uid="uid://b0tb2hjum40aw" path="res://assets/sprites/summertime_saga.png" id="2_vmxhy"]
|
||||
[ext_resource type="PackedScene" uid="uid://cg8713v6c5w15" path="res://scenes/pools.tscn" id="3_jv7x4"]
|
||||
[ext_resource type="PackedScene" uid="uid://dpxxjfd5lv5sv" path="res://scenes/gui/choose_your_seeds.tscn" id="5_5e78h"]
|
||||
[ext_resource type="PackedScene" uid="uid://devn21c7luf45" path="res://scenes/level components/field_controller.tscn" id="5_lwpg6"]
|
||||
[ext_resource type="PackedScene" uid="uid://cfnmspei3k4p7" path="res://scenes/gui/runtime_gui.tscn" id="6_0baou"]
|
||||
[ext_resource type="PackedScene" uid="uid://bpekho7leatr5" path="res://scenes/sun.tscn" id="6_ay12k"]
|
||||
[ext_resource type="Script" path="res://scripts/components/level/SunSpawner.cs" id="6_lkguy"]
|
||||
[ext_resource type="PackedScene" uid="uid://co11v3w8hbwgf" path="res://scenes/entities/Zombies/zombie.tscn" id="8_uxcm5"]
|
||||
|
||||
[node name="debug_lvl" type="Node2D"]
|
||||
|
||||
|
|
@ -32,6 +32,8 @@ layer = 10
|
|||
[node name="RuntimeGUI" parent="GuiLayer" instance=ExtResource("6_0baou")]
|
||||
metadata/_edit_lock_ = true
|
||||
|
||||
[node name="ChooseYourSeeds" parent="GuiLayer" instance=ExtResource("5_5e78h")]
|
||||
|
||||
[node name="Overlay" type="CanvasLayer" parent="."]
|
||||
layer = 6
|
||||
follow_viewport_enabled = true
|
||||
|
|
@ -46,8 +48,4 @@ SunScene = ExtResource("6_ay12k")
|
|||
wait_time = 5.0
|
||||
autostart = true
|
||||
|
||||
[node name="Zombie" parent="." instance=ExtResource("8_uxcm5")]
|
||||
position = Vector2(730, 190)
|
||||
_line = 2
|
||||
|
||||
[connection signal="timeout" from="SunSpawner/Timer" to="SunSpawner" method="Spawn"]
|
||||
|
|
|
|||
158
scenes/gui/choose_your_seeds.tscn
Normal file
158
scenes/gui/choose_your_seeds.tscn
Normal file
|
|
@ -0,0 +1,158 @@
|
|||
[gd_scene load_steps=12 format=3 uid="uid://dpxxjfd5lv5sv"]
|
||||
|
||||
[ext_resource type="Theme" uid="uid://e8n88g31w7x7" path="res://resources/themes/ChooseYourSeeds.tres" id="1_bfo8i"]
|
||||
[ext_resource type="Texture2D" uid="uid://dr8a0rx42o3qy" path="res://assets/sprites/gui/ChooseYourSeeds/PlantFrame.tres" id="2_so2bw"]
|
||||
[ext_resource type="Texture2D" uid="uid://dycdvvgmgmfu6" path="res://assets/sprites/gui/ChooseYourSeeds/FrameField.tres" id="3_rn5vx"]
|
||||
[ext_resource type="Script" path="res://scripts/components/gui/choose_your_seeds/GridLoader.cs" id="4_i7sou"]
|
||||
[ext_resource type="PackedScene" uid="uid://10b1egek6upx" path="res://scenes/gui/level_run_button.tscn" id="5_n80ic"]
|
||||
[ext_resource type="Script" path="res://scripts/components/gui/choose_your_seeds/LevelRunButton.cs" id="7_k6b6g"]
|
||||
|
||||
[sub_resource type="Animation" id="Animation_0rps3"]
|
||||
resource_name = "Hide"
|
||||
length = 0.75
|
||||
step = 0.1
|
||||
tracks/0/type = "bezier"
|
||||
tracks/0/imported = false
|
||||
tracks/0/enabled = true
|
||||
tracks/0/path = NodePath("..:position:y")
|
||||
tracks/0/interp = 1
|
||||
tracks/0/loop_wrap = true
|
||||
tracks/0/keys = {
|
||||
"handle_modes": PackedInt32Array(0, 0),
|
||||
"points": PackedFloat32Array(64, -0.25, 0, 0.5, 7.5, 402, -0.55, -95.5, 0.25, 0),
|
||||
"times": PackedFloat32Array(0, 0.75)
|
||||
}
|
||||
|
||||
[sub_resource type="Animation" id="Animation_omiwq"]
|
||||
resource_name = "Show"
|
||||
length = 1.5
|
||||
step = 0.25
|
||||
tracks/0/type = "bezier"
|
||||
tracks/0/imported = false
|
||||
tracks/0/enabled = true
|
||||
tracks/0/path = NodePath("..:position:y")
|
||||
tracks/0/interp = 1
|
||||
tracks/0/loop_wrap = true
|
||||
tracks/0/keys = {
|
||||
"handle_modes": PackedInt32Array(0, 0, 0),
|
||||
"points": PackedFloat32Array(402, -0.25, 0, 1, -336.5, 64, -1, 338.5, 0, 66.5, 64, -0.0571204, 1, 0.19288, 1.5),
|
||||
"times": PackedFloat32Array(0, 1, 1.5)
|
||||
}
|
||||
|
||||
[sub_resource type="Animation" id="Animation_8he0w"]
|
||||
length = 0.001
|
||||
tracks/0/type = "bezier"
|
||||
tracks/0/imported = false
|
||||
tracks/0/enabled = true
|
||||
tracks/0/path = NodePath("..:position:y")
|
||||
tracks/0/interp = 1
|
||||
tracks/0/loop_wrap = true
|
||||
tracks/0/keys = {
|
||||
"handle_modes": PackedInt32Array(0),
|
||||
"points": PackedFloat32Array(402, -0.25, 0, 0.25, 0),
|
||||
"times": PackedFloat32Array(0)
|
||||
}
|
||||
|
||||
[sub_resource type="AnimationLibrary" id="AnimationLibrary_tguwa"]
|
||||
_data = {
|
||||
"Hide": SubResource("Animation_0rps3"),
|
||||
"RESET": SubResource("Animation_8he0w"),
|
||||
"Show": SubResource("Animation_omiwq")
|
||||
}
|
||||
|
||||
[sub_resource type="ViewportTexture" id="ViewportTexture_rmoaa"]
|
||||
viewport_path = NodePath("Panel/MarginContainer/VBoxContainer/HBoxContainer/Frame/SubViewport")
|
||||
|
||||
[node name="ChooseYourSeeds" type="Control"]
|
||||
process_mode = 3
|
||||
layout_mode = 3
|
||||
anchors_preset = 15
|
||||
anchor_right = 1.0
|
||||
anchor_bottom = 1.0
|
||||
grow_horizontal = 2
|
||||
grow_vertical = 2
|
||||
mouse_filter = 2
|
||||
theme = ExtResource("1_bfo8i")
|
||||
|
||||
[node name="AnimationPlayer" type="AnimationPlayer" parent="."]
|
||||
root_node = NodePath("../Panel/LevelRunButton")
|
||||
libraries = {
|
||||
"": SubResource("AnimationLibrary_tguwa")
|
||||
}
|
||||
autoplay = "Show"
|
||||
|
||||
[node name="Panel" type="Panel" parent="."]
|
||||
layout_mode = 1
|
||||
anchors_preset = -1
|
||||
anchor_top = 2.005
|
||||
anchor_right = 0.6
|
||||
anchor_bottom = 2.845
|
||||
offset_top = -400.0
|
||||
offset_bottom = -400.0
|
||||
grow_vertical = 2
|
||||
metadata/_edit_use_anchors_ = true
|
||||
|
||||
[node name="MarginContainer" type="MarginContainer" parent="Panel"]
|
||||
layout_mode = 1
|
||||
anchors_preset = 15
|
||||
anchor_right = 1.0
|
||||
anchor_bottom = 1.0
|
||||
grow_horizontal = 2
|
||||
grow_vertical = 2
|
||||
theme_override_constants/margin_left = 8
|
||||
theme_override_constants/margin_top = 6
|
||||
theme_override_constants/margin_right = 8
|
||||
theme_override_constants/margin_bottom = 6
|
||||
|
||||
[node name="VBoxContainer" type="VBoxContainer" parent="Panel/MarginContainer"]
|
||||
layout_mode = 2
|
||||
|
||||
[node name="HBoxContainer" type="HBoxContainer" parent="Panel/MarginContainer/VBoxContainer"]
|
||||
layout_mode = 2
|
||||
|
||||
[node name="Frame" type="TextureRect" parent="Panel/MarginContainer/VBoxContainer/HBoxContainer"]
|
||||
layout_mode = 2
|
||||
texture = ExtResource("2_so2bw")
|
||||
|
||||
[node name="SubViewport" type="SubViewport" parent="Panel/MarginContainer/VBoxContainer/HBoxContainer/Frame"]
|
||||
canvas_item_default_texture_filter = 0
|
||||
size = Vector2i(65, 65)
|
||||
|
||||
[node name="FrameField" type="Sprite2D" parent="Panel/MarginContainer/VBoxContainer/HBoxContainer/Frame/SubViewport"]
|
||||
texture = ExtResource("3_rn5vx")
|
||||
|
||||
[node name="Camera2D" type="Camera2D" parent="Panel/MarginContainer/VBoxContainer/HBoxContainer/Frame/SubViewport"]
|
||||
|
||||
[node name="Render" type="TextureRect" parent="Panel/MarginContainer/VBoxContainer/HBoxContainer/Frame"]
|
||||
show_behind_parent = true
|
||||
layout_mode = 1
|
||||
anchors_preset = 15
|
||||
anchor_right = 1.0
|
||||
anchor_bottom = 1.0
|
||||
grow_horizontal = 2
|
||||
grow_vertical = 2
|
||||
texture = SubResource("ViewportTexture_rmoaa")
|
||||
|
||||
[node name="PanelContainer" type="PanelContainer" parent="Panel/MarginContainer/VBoxContainer/HBoxContainer"]
|
||||
layout_mode = 2
|
||||
size_flags_horizontal = 3
|
||||
|
||||
[node name="ScrollContainer" type="ScrollContainer" parent="Panel/MarginContainer/VBoxContainer"]
|
||||
layout_mode = 2
|
||||
size_flags_vertical = 3
|
||||
horizontal_scroll_mode = 0
|
||||
|
||||
[node name="GridContainer" type="GridContainer" parent="Panel/MarginContainer/VBoxContainer/ScrollContainer"]
|
||||
layout_mode = 2
|
||||
columns = 7
|
||||
script = ExtResource("4_i7sou")
|
||||
|
||||
[node name="LevelRunButton" parent="Panel" node_paths=PackedStringArray("_player") instance=ExtResource("5_n80ic")]
|
||||
layout_mode = 1
|
||||
anchor_left = 1.0
|
||||
anchor_right = 1.181
|
||||
anchor_bottom = 0.131
|
||||
offset_right = -16.16
|
||||
offset_bottom = -16.016
|
||||
script = ExtResource("7_k6b6g")
|
||||
_player = NodePath("../../AnimationPlayer")
|
||||
14
scenes/gui/level_run_button.tscn
Normal file
14
scenes/gui/level_run_button.tscn
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
[gd_scene load_steps=3 format=3 uid="uid://10b1egek6upx"]
|
||||
|
||||
[ext_resource type="Theme" uid="uid://b8l285cjcgeyi" path="res://resources/themes/GameStyle.tres" id="1_05u5f"]
|
||||
[ext_resource type="Texture2D" uid="uid://rpnw5lxm3ksb" path="res://assets/sprites/gui/ChooseYourSeeds/LevelRun.tres" id="1_qftep"]
|
||||
|
||||
[node name="LevelRunButton" type="Button"]
|
||||
anchors_preset = -1
|
||||
anchor_right = 0.108333
|
||||
anchor_bottom = 0.11
|
||||
offset_right = -57.0
|
||||
offset_bottom = -36.0
|
||||
theme = ExtResource("1_05u5f")
|
||||
icon = ExtResource("1_qftep")
|
||||
metadata/_edit_use_anchors_ = true
|
||||
|
|
@ -1,35 +1,32 @@
|
|||
[gd_scene load_steps=10 format=3 uid="uid://c8qru1yhnbbkl"]
|
||||
[gd_scene load_steps=10 format=3 uid="uid://e7vutg71l6f2"]
|
||||
|
||||
[ext_resource type="Texture2D" uid="uid://cabpf23ndlvx0" path="res://assets/sprites/gui/Selection.tres" id="2_5mpv8"]
|
||||
[ext_resource type="Texture2D" uid="uid://cxlr34yh0bqch" path="res://assets/sprites/gui/DisabledEmptyCard.png" id="2_odd6g"]
|
||||
[ext_resource type="Script" path="res://scripts/components/gui/PlantSlot.cs" id="3_eer7n"]
|
||||
[ext_resource type="Shader" path="res://assets/shaders/gui_masking.gdshader" id="4_bryew"]
|
||||
[ext_resource type="Texture2D" uid="uid://dxyf557m4mq1p" path="res://assets/sprites/gui/EmptyPlantCard.png" id="5_2k0xq"]
|
||||
[ext_resource type="Texture2D" uid="uid://c1afy0ga6h1ic" path="res://assets/sprites/white_box.png" id="5_7xerl"]
|
||||
[ext_resource type="Script" path="res://scripts/components/gui/VeilResizer.cs" id="5_d6igb"]
|
||||
[ext_resource type="Texture2D" uid="uid://dxyf557m4mq1p" path="res://assets/sprites/gui/EmptyPlantCard.png" id="1_77bw1"]
|
||||
[ext_resource type="Texture2D" uid="uid://cxlr34yh0bqch" path="res://assets/sprites/gui/DisabledEmptyCard.png" id="2_2gojx"]
|
||||
[ext_resource type="Texture2D" uid="uid://cabpf23ndlvx0" path="res://assets/sprites/gui/Selection.tres" id="3_q0tvq"]
|
||||
[ext_resource type="Script" path="res://scripts/components/gui/seedpackets/Seedpacket.cs" id="4_c6epd"]
|
||||
[ext_resource type="Shader" path="res://assets/shaders/gui_masking.gdshader" id="5_s5861"]
|
||||
[ext_resource type="Texture2D" uid="uid://c1afy0ga6h1ic" path="res://assets/sprites/white_box.png" id="6_lp42h"]
|
||||
[ext_resource type="Script" path="res://scripts/components/gui/VeilResizer.cs" id="7_tv07f"]
|
||||
|
||||
[sub_resource type="LabelSettings" id="LabelSettings_js4li"]
|
||||
font_size = 13
|
||||
font_color = Color(0, 0, 0, 1)
|
||||
|
||||
[sub_resource type="ShaderMaterial" id="ShaderMaterial_qxf0q"]
|
||||
shader = ExtResource("4_bryew")
|
||||
shader_parameter/mask = ExtResource("5_2k0xq")
|
||||
shader = ExtResource("5_s5861")
|
||||
shader_parameter/mask = ExtResource("1_77bw1")
|
||||
|
||||
[node name="PlantSlot" type="TextureButton" node_paths=PackedStringArray("_cost", "_icon", "_timer")]
|
||||
[node name="Seedpacket" type="TextureButton"]
|
||||
anchors_preset = -1
|
||||
anchor_right = 0.137
|
||||
anchor_bottom = 0.28
|
||||
offset_right = -0.200005
|
||||
mouse_default_cursor_shape = 2
|
||||
texture_normal = ExtResource("5_2k0xq")
|
||||
texture_disabled = ExtResource("2_odd6g")
|
||||
texture_focused = ExtResource("2_5mpv8")
|
||||
texture_normal = ExtResource("1_77bw1")
|
||||
texture_disabled = ExtResource("2_2gojx")
|
||||
texture_focused = ExtResource("3_q0tvq")
|
||||
stretch_mode = 0
|
||||
script = ExtResource("3_eer7n")
|
||||
_cost = NodePath("Cost")
|
||||
_icon = NodePath("PlantPreviewContainer/Preview")
|
||||
_timer = NodePath("RechargeTimer")
|
||||
script = ExtResource("4_c6epd")
|
||||
metadata/_edit_use_anchors_ = true
|
||||
|
||||
[node name="Cost" type="Label" parent="."]
|
||||
|
|
@ -92,14 +89,12 @@ max_value = 1.0
|
|||
step = 0.001
|
||||
fill_mode = 3
|
||||
nine_patch_stretch = true
|
||||
texture_progress = ExtResource("5_7xerl")
|
||||
texture_progress = ExtResource("6_lp42h")
|
||||
tint_progress = Color(0, 0, 0, 0.843137)
|
||||
script = ExtResource("5_d6igb")
|
||||
script = ExtResource("7_tv07f")
|
||||
_referenceTimer = NodePath("../RechargeTimer")
|
||||
|
||||
[node name="RechargeTimer" type="Timer" parent="."]
|
||||
one_shot = true
|
||||
|
||||
[connection signal="focus_exited" from="." to="." method="OnFocusExited"]
|
||||
[connection signal="pressed" from="." to="." method="OnPressed"]
|
||||
[connection signal="timeout" from="RechargeTimer" to="." method="Timeout"]
|
||||
[connection signal="focus_exited" from="." to="." method="OnUnfocused"]
|
||||
16
scripts/components/LevelGUIElements.cs
Normal file
16
scripts/components/LevelGUIElements.cs
Normal file
|
|
@ -0,0 +1,16 @@
|
|||
using Godot;
|
||||
using System;
|
||||
|
||||
public partial class LevelGUIElements : Control
|
||||
{
|
||||
public static LevelGUIElements Instance;
|
||||
|
||||
[Export]
|
||||
public HBoxContainer SeedpacketsHotbar;
|
||||
[Export]
|
||||
public TextureRect SunCounter;
|
||||
public override void _Ready()
|
||||
{
|
||||
Instance = this;
|
||||
}
|
||||
}
|
||||
|
|
@ -1,67 +0,0 @@
|
|||
using Godot;
|
||||
using System;
|
||||
|
||||
public partial class PlantSlot : TextureButton
|
||||
{
|
||||
[Export] private PlantResource _resource;
|
||||
[Export] private Label _cost;
|
||||
[Export] private TextureRect _icon;
|
||||
[Export] private Timer _timer;
|
||||
|
||||
private bool _recharging;
|
||||
|
||||
public override void _Ready()
|
||||
{
|
||||
if (_resource != null)
|
||||
UpdateContents();
|
||||
}
|
||||
public override void _Process(double delta)
|
||||
{
|
||||
if (_resource != null)
|
||||
{
|
||||
Disabled = _recharging || LevelController.Instance.LevelData.SunCount < _resource.Cost;
|
||||
FocusMode = Disabled ? FocusModeEnum.None : FocusModeEnum.All;
|
||||
}
|
||||
}
|
||||
|
||||
public void SetPlantResource( PlantResource resource )
|
||||
{
|
||||
_resource = resource;
|
||||
|
||||
UpdateContents();
|
||||
}
|
||||
|
||||
private void UpdateContents()
|
||||
{
|
||||
_cost.Text = _resource.Cost.ToString();
|
||||
_icon.Texture = _resource.Preview;
|
||||
_timer.WaitTime = _resource.ReloadTime;
|
||||
}
|
||||
|
||||
private void OnPressed()
|
||||
{
|
||||
if (_timer.TimeLeft == 0)
|
||||
{
|
||||
LevelController.Instance.PlantField.SetPlant(this, _resource);
|
||||
}
|
||||
}
|
||||
private void OnFocusExited()
|
||||
{
|
||||
LevelController.Instance.PlantField.SetPlant(null, null);
|
||||
}
|
||||
|
||||
|
||||
public void Recharge()
|
||||
{
|
||||
_recharging = true;
|
||||
|
||||
ReleaseFocus();
|
||||
|
||||
_timer.Start();
|
||||
}
|
||||
|
||||
private void Timeout()
|
||||
{
|
||||
_recharging = false;
|
||||
}
|
||||
}
|
||||
28
scripts/components/gui/choose_your_seeds/GridLoader.cs
Normal file
28
scripts/components/gui/choose_your_seeds/GridLoader.cs
Normal file
|
|
@ -0,0 +1,28 @@
|
|||
using Godot;
|
||||
using System;
|
||||
|
||||
public partial class GridLoader : GridContainer
|
||||
{
|
||||
private const string PLANT_RESOURCE_PATH = "res://resources/plants/";
|
||||
private PackedScene _plantCard;
|
||||
|
||||
public override void _Ready()
|
||||
{
|
||||
_plantCard = ResourceLoader.Load<PackedScene>("res://scenes/gui/seedpacket.tscn");
|
||||
|
||||
string[] files = DirAccess.GetFilesAt(PLANT_RESOURCE_PATH);
|
||||
|
||||
foreach(var file in files)
|
||||
{
|
||||
if(ResourceLoader.Exists(PLANT_RESOURCE_PATH+file))
|
||||
{
|
||||
Seedpacket slot = _plantCard.Instantiate<Seedpacket>();
|
||||
AddChild(slot);
|
||||
|
||||
slot.SetPlantResource(ResourceLoader.Load<PlantResource>(PLANT_RESOURCE_PATH+file));
|
||||
slot.SetHandler(new ChoosableHandler(slot));
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
13
scripts/components/gui/choose_your_seeds/LevelRunButton.cs
Normal file
13
scripts/components/gui/choose_your_seeds/LevelRunButton.cs
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
using Godot;
|
||||
|
||||
public partial class LevelRunButton : Button
|
||||
{
|
||||
[Export] private AnimationPlayer _player;
|
||||
public override void _Pressed()
|
||||
{
|
||||
RuntimeLevelData.Instance.SetLevelState(RuntimeLevelData.LevelStates.Game);
|
||||
GetTree().Paused = false;
|
||||
|
||||
_player.Play("Hide");
|
||||
}
|
||||
}
|
||||
24
scripts/components/gui/seedpackets/ChoosableHandler.cs
Normal file
24
scripts/components/gui/seedpackets/ChoosableHandler.cs
Normal file
|
|
@ -0,0 +1,24 @@
|
|||
public class ChoosableHandler : SeedpacketHandler, ISeedpacketPress
|
||||
{
|
||||
public ChoosableHandler(Seedpacket owner) : base(owner)
|
||||
{
|
||||
}
|
||||
|
||||
public void Pressed()
|
||||
{
|
||||
_owner.disablePacket = true;
|
||||
|
||||
var hotbarSeedpacket = Seedpacket.Prefab.Instantiate<Seedpacket>();
|
||||
LevelGUIElements.Instance.SeedpacketsHotbar.AddChild(hotbarSeedpacket);
|
||||
hotbarSeedpacket.SetPlantResource(_owner.GetPlantResource());
|
||||
|
||||
var pregameHandler = new HotbarPregameHandler(hotbarSeedpacket);
|
||||
hotbarSeedpacket.SetHandler(pregameHandler);
|
||||
pregameHandler.Clicked += OnHotbarClicked;
|
||||
}
|
||||
|
||||
public void OnHotbarClicked()
|
||||
{
|
||||
_owner.disablePacket = false;
|
||||
}
|
||||
}
|
||||
22
scripts/components/gui/seedpackets/HotbarHandler.cs
Normal file
22
scripts/components/gui/seedpackets/HotbarHandler.cs
Normal file
|
|
@ -0,0 +1,22 @@
|
|||
using System;
|
||||
using Godot;
|
||||
public class HotbarHandler : SeedpacketHandler, ISeedpacketPress, ISeedpacketProcess, ISeedpacketUnfocus
|
||||
{
|
||||
public HotbarHandler(Seedpacket owner) : base(owner)
|
||||
{
|
||||
}
|
||||
|
||||
public void Pressed()
|
||||
{
|
||||
PlantField.Instance.SetPlant(_owner,_owner.GetPlantResource());
|
||||
}
|
||||
|
||||
public void Process()
|
||||
{
|
||||
_owner.disablePacket = RuntimeLevelData.Instance.SunCount < _owner.GetPlantResource().Cost;
|
||||
}
|
||||
public void OnUnfocused()
|
||||
{
|
||||
PlantField.Instance.ResetPlant();
|
||||
}
|
||||
}
|
||||
29
scripts/components/gui/seedpackets/HotbarPregameHandler.cs
Normal file
29
scripts/components/gui/seedpackets/HotbarPregameHandler.cs
Normal file
|
|
@ -0,0 +1,29 @@
|
|||
using System;
|
||||
using Godot;
|
||||
public class HotbarPregameHandler : SeedpacketHandler, ISeedpacketPress
|
||||
{
|
||||
public HotbarPregameHandler(Seedpacket owner) : base(owner)
|
||||
{
|
||||
RuntimeLevelData.Instance.OnLevelStateChanged += OnLevelStateChanged;
|
||||
|
||||
}
|
||||
|
||||
public event Action Clicked;
|
||||
public void Pressed()
|
||||
{
|
||||
if (Clicked != null) Clicked();
|
||||
_owner.QueueFree();
|
||||
}
|
||||
|
||||
public void OnLevelStateChanged(RuntimeLevelData.LevelStates state)
|
||||
{
|
||||
if (state == RuntimeLevelData.LevelStates.Game)
|
||||
{
|
||||
_owner.SetHandler(new HotbarHandler(_owner));
|
||||
}
|
||||
else if (state != RuntimeLevelData.LevelStates.ChooseYourSeeds)
|
||||
{
|
||||
_owner.disablePacket = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
4
scripts/components/gui/seedpackets/ISeedpacketPress.cs
Normal file
4
scripts/components/gui/seedpackets/ISeedpacketPress.cs
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
public interface ISeedpacketPress
|
||||
{
|
||||
public void Pressed();
|
||||
}
|
||||
4
scripts/components/gui/seedpackets/ISeedpacketProcess.cs
Normal file
4
scripts/components/gui/seedpackets/ISeedpacketProcess.cs
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
public interface ISeedpacketProcess
|
||||
{
|
||||
public void Process();
|
||||
}
|
||||
4
scripts/components/gui/seedpackets/ISeedpacketUnfocus.cs
Normal file
4
scripts/components/gui/seedpackets/ISeedpacketUnfocus.cs
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
public interface ISeedpacketUnfocus
|
||||
{
|
||||
public void OnUnfocused();
|
||||
}
|
||||
76
scripts/components/gui/seedpackets/Seedpacket.cs
Normal file
76
scripts/components/gui/seedpackets/Seedpacket.cs
Normal file
|
|
@ -0,0 +1,76 @@
|
|||
using Godot;
|
||||
using System;
|
||||
|
||||
public partial class Seedpacket : TextureButton
|
||||
{
|
||||
private const string PATH_TO_PACKED_SCENE = "res://scenes/gui/seedpacket.tscn";
|
||||
private PlantResource _resource;
|
||||
private Label _cost;
|
||||
private TextureRect _icon;
|
||||
private Timer _timer;
|
||||
private SeedpacketHandler _handler;
|
||||
|
||||
public bool disablePacket = false;
|
||||
|
||||
public static PackedScene Prefab { get; private set; }
|
||||
|
||||
// Node overrides
|
||||
public override void _Ready()
|
||||
{
|
||||
if (_resource != null)
|
||||
UpdateContents();
|
||||
if (Prefab == null)
|
||||
{
|
||||
Prefab = ResourceLoader.Load<PackedScene>(PATH_TO_PACKED_SCENE);
|
||||
}
|
||||
_cost = GetNode<Label>("Cost");
|
||||
_icon = GetNode<TextureRect>("PlantPreviewContainer/Preview");
|
||||
_timer = GetNode<Timer>("RechargeTimer");
|
||||
}
|
||||
public override void _Process(double delta)
|
||||
{
|
||||
Disabled = disablePacket || _timer.TimeLeft > 0;
|
||||
if (_handler is ISeedpacketProcess processHandler) processHandler.Process();
|
||||
}
|
||||
public void SetPlantResource( PlantResource resource )
|
||||
{
|
||||
_resource = resource;
|
||||
|
||||
UpdateContents();
|
||||
}
|
||||
|
||||
public PlantResource GetPlantResource()
|
||||
{
|
||||
return _resource;
|
||||
}
|
||||
|
||||
public void SetHandler(SeedpacketHandler newHandler)
|
||||
{
|
||||
disablePacket = false;
|
||||
_handler = newHandler;
|
||||
}
|
||||
|
||||
protected virtual void UpdateContents()
|
||||
{
|
||||
_cost.Text = _resource.Cost.ToString();
|
||||
_icon.Texture = _resource.Preview;
|
||||
_timer.WaitTime = _resource.ReloadTime;
|
||||
}
|
||||
|
||||
public override void _Pressed()
|
||||
{
|
||||
if (_handler is ISeedpacketPress pressHandler)
|
||||
pressHandler.Pressed();
|
||||
}
|
||||
|
||||
public void Recharge()
|
||||
{
|
||||
_timer.Start();
|
||||
ReleaseFocus();
|
||||
}
|
||||
|
||||
public void OnUnfocused()
|
||||
{
|
||||
if (_handler is ISeedpacketUnfocus unfocusHandler) unfocusHandler.OnUnfocused();
|
||||
}
|
||||
}
|
||||
9
scripts/components/gui/seedpackets/SeedpacketHandler.cs
Normal file
9
scripts/components/gui/seedpackets/SeedpacketHandler.cs
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
public class SeedpacketHandler
|
||||
{
|
||||
protected Seedpacket _owner;
|
||||
|
||||
public SeedpacketHandler(Seedpacket owner)
|
||||
{
|
||||
_owner = owner;
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue