This commit is contained in:
Фёдор Веселов 2024-09-10 19:36:20 +05:00
commit 2eb65c3092
24 changed files with 566 additions and 49 deletions

View file

@ -0,0 +1,13 @@
shader_type canvas_item;
uniform float amount : hint_range(0.0, 1.0, 0.1);
vec4 luminance(vec4 col)
{
return vec4(vec3(0.2126*col.r+0.7152*col.g+0.0722*col.b),col.a);
}
void fragment() {
COLOR = mix(COLOR, luminance(COLOR),amount);
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 329 B

View file

@ -0,0 +1,34 @@
[remap]
importer="texture"
type="CompressedTexture2D"
uid="uid://mmi6crnkn4jr"
path="res://.godot/imported/PlantPanel.png-80a3691aae5329c92a536e473dba5d28.ctex"
metadata={
"vram_texture": false
}
[deps]
source_file="res://assets/sprites/atlases/PlantPanel.png"
dest_files=["res://.godot/imported/PlantPanel.png-80a3691aae5329c92a536e473dba5d28.ctex"]
[params]
compress/mode=0
compress/high_quality=false
compress/lossy_quality=0.7
compress/hdr_compression=1
compress/normal_map=0
compress/channel_pack=0
mipmaps/generate=false
mipmaps/limit=-1
roughness/mode=0
roughness/src_normal=""
process/fix_alpha_border=true
process/premult_alpha=false
process/normal_map_invert_y=false
process/hdr_as_srgb=false
process/hdr_clamp_exposure=false
process/size_limit=0
detect_3d/compress_to=1

Binary file not shown.

Before

Width:  |  Height:  |  Size: 32 KiB

After

Width:  |  Height:  |  Size: 32 KiB

Before After
Before After

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.7 KiB

View file

@ -0,0 +1,34 @@
[remap]
importer="texture"
type="CompressedTexture2D"
uid="uid://brj0buevfwv21"
path="res://.godot/imported/basic.png-6d11a963868a5f527d4b4e56da4660f0.ctex"
metadata={
"vram_texture": false
}
[deps]
source_file="res://assets/sprites/atlases/zombies/basic.png"
dest_files=["res://.godot/imported/basic.png-6d11a963868a5f527d4b4e56da4660f0.ctex"]
[params]
compress/mode=0
compress/high_quality=false
compress/lossy_quality=0.7
compress/hdr_compression=1
compress/normal_map=0
compress/channel_pack=0
mipmaps/generate=false
mipmaps/limit=-1
roughness/mode=0
roughness/src_normal=""
process/fix_alpha_border=true
process/premult_alpha=false
process/normal_map_invert_y=false
process/hdr_as_srgb=false
process/hdr_clamp_exposure=false
process/size_limit=0
detect_3d/compress_to=1

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.1 KiB

View file

@ -0,0 +1,34 @@
[remap]
importer="texture"
type="CompressedTexture2D"
uid="uid://d02m0kdhuio5e"
path="res://.godot/imported/basic_fem.png-6547f99bebbd8ad1bfe017dfea81a7c3.ctex"
metadata={
"vram_texture": false
}
[deps]
source_file="res://assets/sprites/atlases/zombies/basic_fem.png"
dest_files=["res://.godot/imported/basic_fem.png-6547f99bebbd8ad1bfe017dfea81a7c3.ctex"]
[params]
compress/mode=0
compress/high_quality=false
compress/lossy_quality=0.7
compress/hdr_compression=1
compress/normal_map=0
compress/channel_pack=0
mipmaps/generate=false
mipmaps/limit=-1
roughness/mode=0
roughness/src_normal=""
process/fix_alpha_border=true
process/premult_alpha=false
process/normal_map_invert_y=false
process/hdr_as_srgb=false
process/hdr_clamp_exposure=false
process/size_limit=0
detect_3d/compress_to=1

Binary file not shown.

After

Width:  |  Height:  |  Size: 329 B

View file

@ -0,0 +1,34 @@
[remap]
importer="texture"
type="CompressedTexture2D"
uid="uid://bbh0uwloi87tn"
path="res://.godot/imported/PlantPanel.png-0763568f9f3ab7f90b34d5907a5a53a2.ctex"
metadata={
"vram_texture": false
}
[deps]
source_file="res://assets/sprites/gui/PlantPanel.png"
dest_files=["res://.godot/imported/PlantPanel.png-0763568f9f3ab7f90b34d5907a5a53a2.ctex"]
[params]
compress/mode=0
compress/high_quality=false
compress/lossy_quality=0.7
compress/hdr_compression=1
compress/normal_map=0
compress/channel_pack=0
mipmaps/generate=false
mipmaps/limit=-1
roughness/mode=0
roughness/src_normal=""
process/fix_alpha_border=true
process/premult_alpha=false
process/normal_map_invert_y=false
process/hdr_as_srgb=false
process/hdr_clamp_exposure=false
process/size_limit=0
detect_3d/compress_to=1

Binary file not shown.

Before

Width:  |  Height:  |  Size: 33 KiB

After

Width:  |  Height:  |  Size: 38 KiB

Before After
Before After

3
resources/GameStyle.tres Normal file
View file

@ -0,0 +1,3 @@
[gd_resource type="Theme" format=3 uid="uid://b8l285cjcgeyi"]
[resource]

View file

@ -1,11 +1,19 @@
[gd_scene load_steps=7 format=3 uid="uid://crxsvv7drckpw"]
[gd_scene load_steps=10 format=3 uid="uid://crxsvv7drckpw"]
[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://be1kgukmiu0hs" path="res://scenes/entities/plants/peashooter.tscn" id="4_esyy7"]
[ext_resource type="PackedScene" uid="uid://co11v3w8hbwgf" path="res://scenes/entities/Zombies/zombie.tscn" id="5_5jekn"]
[ext_resource type="Script" path="res://scripts/components/level/PlantField.cs" id="5_rcajd"]
[ext_resource type="Shader" path="res://assets/shaders/greyscale.gdshader" id="5_xsv1x"]
[ext_resource type="PackedScene" uid="uid://cfnmspei3k4p7" path="res://scenes/gui/runtime_gui.tscn" id="6_0baou"]
[ext_resource type="Texture2D" uid="uid://ot1n4nval86w" path="res://assets/sprites/plants/peashooter.tres" id="6_1r0ne"]
[sub_resource type="ShaderMaterial" id="ShaderMaterial_0miwm"]
shader = ExtResource("5_xsv1x")
shader_parameter/amount = 0.0
[sub_resource type="RectangleShape2D" id="RectangleShape2D_j04hk"]
size = Vector2(50, 60)
[node name="debug_lvl" type="Node2D"]
@ -23,29 +31,24 @@ script = ExtResource("1_i3bf5")
[node name="Pools" parent="." instance=ExtResource("3_jv7x4")]
[node name="Peashooter" parent="." instance=ExtResource("4_esyy7")]
position = Vector2(379, 105)
_line = 4
[node name="Peashooter2" parent="." instance=ExtResource("4_esyy7")]
position = Vector2(431, 162)
_line = 3
[node name="Peashooter3" parent="." instance=ExtResource("4_esyy7")]
position = Vector2(480, 224)
_line = 2
[node name="Peashooter4" parent="." instance=ExtResource("4_esyy7")]
position = Vector2(531, 283)
_line = 1
[node name="Peashooter5" parent="." instance=ExtResource("4_esyy7")]
position = Vector2(581, 345)
[node name="Zombie" parent="." instance=ExtResource("5_5jekn")]
position = Vector2(686, 191)
_line = 3
[node name="CanvasLayer" type="CanvasLayer" parent="."]
layer = 10
[node name="RuntimeGUI" parent="CanvasLayer" instance=ExtResource("6_0baou")]
[node name="FieldController" type="Node2D" parent="."]
visible = false
material = SubResource("ShaderMaterial_0miwm")
script = ExtResource("5_rcajd")
[node name="PlantSetter" type="Area2D" parent="FieldController"]
use_parent_material = true
collision_layer = 0
collision_mask = 2
[node name="CollisionShape2D" type="CollisionShape2D" parent="FieldController/PlantSetter"]
shape = SubResource("RectangleShape2D_j04hk")
[node name="Peashooter" type="Sprite2D" parent="FieldController/PlantSetter"]
use_parent_material = true
texture = ExtResource("6_1r0ne")

View file

@ -1,7 +1,10 @@
[gd_scene load_steps=5 format=3 uid="uid://co11v3w8hbwgf"]
[gd_scene load_steps=23 format=3 uid="uid://co11v3w8hbwgf"]
[ext_resource type="Script" path="res://scripts/components/zombies/RuntimeZombieData.cs" id="1_qq3f1"]
[ext_resource type="Texture2D" uid="uid://bwwbkybryi6k0" path="res://assets/sprites/zombie.tres" id="2_4pdxh"]
[ext_resource type="Script" path="res://scripts/components/zombies/EatBox.cs" id="3_2aulo"]
[ext_resource type="Script" path="res://scripts/components/zombies/ZombieMover.cs" id="4_u5syx"]
[ext_resource type="Script" path="res://scripts/components/zombies/behaviours/BasicZombieBehaviour.cs" id="5_2pvkr"]
[sub_resource type="RectangleShape2D" id="RectangleShape2D_hxyad"]
size = Vector2(24, 84)
@ -9,6 +12,141 @@ size = Vector2(24, 84)
[sub_resource type="RectangleShape2D" id="RectangleShape2D_r4ug6"]
size = Vector2(20, 48)
[sub_resource type="Animation" id="Animation_qv5y7"]
length = 0.001
tracks/0/type = "method"
tracks/0/imported = false
tracks/0/enabled = true
tracks/0/path = NodePath("Mover")
tracks/0/interp = 1
tracks/0/loop_wrap = true
tracks/0/keys = {
"times": PackedFloat32Array(0),
"transitions": PackedFloat32Array(1),
"values": [{
"args": [0.0],
"method": &"SetSpeed"
}]
}
[sub_resource type="AnimationLibrary" id="AnimationLibrary_sq25x"]
_data = {
"RESET": SubResource("Animation_qv5y7")
}
[sub_resource type="Animation" id="Animation_fwldj"]
resource_name = "eat"
loop_mode = 1
step = 0.1
tracks/0/type = "method"
tracks/0/imported = false
tracks/0/enabled = true
tracks/0/path = NodePath("Eatbox")
tracks/0/interp = 1
tracks/0/loop_wrap = true
tracks/0/keys = {
"times": PackedFloat32Array(0.5),
"transitions": PackedFloat32Array(1),
"values": [{
"args": [],
"method": &"Bite"
}]
}
tracks/1/type = "method"
tracks/1/imported = false
tracks/1/enabled = true
tracks/1/path = NodePath("Mover")
tracks/1/interp = 1
tracks/1/loop_wrap = true
tracks/1/keys = {
"times": PackedFloat32Array(0),
"transitions": PackedFloat32Array(1),
"values": [{
"args": [0.0],
"method": &"SetSpeed"
}]
}
[sub_resource type="Animation" id="Animation_lrgn8"]
resource_name = "idle"
loop_mode = 1
tracks/0/type = "method"
tracks/0/imported = false
tracks/0/enabled = true
tracks/0/path = NodePath("Mover")
tracks/0/interp = 1
tracks/0/loop_wrap = true
tracks/0/keys = {
"times": PackedFloat32Array(0),
"transitions": PackedFloat32Array(1),
"values": [{
"args": [0.0],
"method": &"SetSpeed"
}]
}
[sub_resource type="Animation" id="Animation_ebhxh"]
resource_name = "walk"
tracks/0/type = "method"
tracks/0/imported = false
tracks/0/enabled = true
tracks/0/path = NodePath("Mover")
tracks/0/interp = 1
tracks/0/loop_wrap = true
tracks/0/keys = {
"times": PackedFloat32Array(0),
"transitions": PackedFloat32Array(1),
"values": [{
"args": [0.5],
"method": &"SetSpeed"
}]
}
[sub_resource type="AnimationLibrary" id="AnimationLibrary_5ci4h"]
_data = {
"eat": SubResource("Animation_fwldj"),
"idle": SubResource("Animation_lrgn8"),
"walk": SubResource("Animation_ebhxh")
}
[sub_resource type="AnimationNodeAnimation" id="AnimationNodeAnimation_h0rfo"]
animation = &"baisc_zombie/eat"
[sub_resource type="AnimationNodeAnimation" id="AnimationNodeAnimation_nog33"]
animation = &"baisc_zombie/idle"
[sub_resource type="AnimationNodeAnimation" id="AnimationNodeAnimation_g2uel"]
animation = &"baisc_zombie/walk"
[sub_resource type="AnimationNodeStateMachineTransition" id="AnimationNodeStateMachineTransition_vxhht"]
advance_mode = 2
[sub_resource type="AnimationNodeStateMachineTransition" id="AnimationNodeStateMachineTransition_r8rju"]
advance_mode = 2
[sub_resource type="AnimationNodeStateMachineTransition" id="AnimationNodeStateMachineTransition_y2ivb"]
advance_mode = 2
advance_condition = &"eat"
[sub_resource type="AnimationNodeStateMachineTransition" id="AnimationNodeStateMachineTransition_7d3k4"]
advance_mode = 2
advance_condition = &"eat"
[sub_resource type="AnimationNodeStateMachineTransition" id="AnimationNodeStateMachineTransition_kk4wi"]
advance_mode = 2
advance_condition = &"end_eat"
[sub_resource type="AnimationNodeStateMachine" id="AnimationNodeStateMachine_qep5j"]
states/End/position = Vector2(1183, 100)
states/baisc_zombie_eat/node = SubResource("AnimationNodeAnimation_h0rfo")
states/baisc_zombie_eat/position = Vector2(575, 185)
states/baisc_zombie_idle/node = SubResource("AnimationNodeAnimation_nog33")
states/baisc_zombie_idle/position = Vector2(368, 100)
states/baisc_zombie_walk/node = SubResource("AnimationNodeAnimation_g2uel")
states/baisc_zombie_walk/position = Vector2(575, 35)
transitions = ["Start", "baisc_zombie_idle", SubResource("AnimationNodeStateMachineTransition_vxhht"), "baisc_zombie_idle", "baisc_zombie_walk", SubResource("AnimationNodeStateMachineTransition_r8rju"), "baisc_zombie_idle", "baisc_zombie_eat", SubResource("AnimationNodeStateMachineTransition_y2ivb"), "baisc_zombie_walk", "baisc_zombie_eat", SubResource("AnimationNodeStateMachineTransition_7d3k4"), "baisc_zombie_eat", "baisc_zombie_walk", SubResource("AnimationNodeStateMachineTransition_kk4wi")]
graph_offset = Vector2(-17, -2)
[node name="Zombie" type="Node2D"]
script = ExtResource("1_qq3f1")
_maxHP = 100
@ -25,8 +163,33 @@ collision_mask = 0
position = Vector2(2, -42)
shape = SubResource("RectangleShape2D_hxyad")
[node name="Eatbox" type="Area2D" parent="."]
[node name="Eatbox" type="Area2D" parent="." node_paths=PackedStringArray("_animationTree")]
collision_layer = 0
collision_mask = 2
script = ExtResource("3_2aulo")
_animationTree = NodePath("../AnimationTree")
[node name="CollisionShape2D" type="CollisionShape2D" parent="Eatbox"]
position = Vector2(-10, -24)
shape = SubResource("RectangleShape2D_r4ug6")
[node name="AnimationPlayer" type="AnimationPlayer" parent="."]
libraries = {
"": SubResource("AnimationLibrary_sq25x"),
"baisc_zombie": SubResource("AnimationLibrary_5ci4h")
}
[node name="AnimationTree" type="AnimationTree" parent="."]
tree_root = SubResource("AnimationNodeStateMachine_qep5j")
anim_player = NodePath("../AnimationPlayer")
parameters/conditions/eat = false
parameters/conditions/end_eat = false
[node name="Mover" type="Node" parent="."]
script = ExtResource("4_u5syx")
[node name="Behaviour" type="Node" parent="."]
script = ExtResource("5_2pvkr")
[connection signal="area_entered" from="Eatbox" to="Eatbox" method="OnAreaEntered"]
[connection signal="area_exited" from="Eatbox" to="Eatbox" method="OnAreaExited"]

View file

@ -1,25 +1,28 @@
[gd_scene load_steps=4 format=3 uid="uid://c8qru1yhnbbkl"]
[gd_scene load_steps=5 format=3 uid="uid://c8qru1yhnbbkl"]
[ext_resource type="Texture2D" uid="uid://cmgaryx5wgu14" path="res://assets/sprites/gui/PlantCard.tres" id="1_fugf5"]
[ext_resource type="Texture2D" uid="uid://cabpf23ndlvx0" path="res://assets/sprites/gui/Selection.tres" id="2_5mpv8"]
[ext_resource type="Script" path="res://scripts/components/gui/PlantSlot.cs" id="3_eer7n"]
[sub_resource type="LabelSettings" id="LabelSettings_js4li"]
font_size = 13
font_color = Color(0, 0, 0, 1)
[node name="PlantCard" type="TextureButton"]
[node name="PlantSlot" type="TextureButton" node_paths=PackedStringArray("_cost", "_icon")]
anchors_preset = -1
anchor_right = 0.137
anchor_bottom = 0.28
offset_right = -0.200005
mouse_default_cursor_shape = 2
texture_normal = ExtResource("1_fugf5")
texture_pressed = ExtResource("2_5mpv8")
texture_focused = ExtResource("2_5mpv8")
stretch_mode = 0
script = ExtResource("3_eer7n")
_cost = NodePath("Cost")
_icon = NodePath("PlantPreviewContainer/Preview")
metadata/_edit_use_anchors_ = true
[node name="Label" type="Label" parent="."]
[node name="Cost" type="Label" parent="."]
layout_mode = 1
anchors_preset = -1
anchor_left = 0.146
@ -36,3 +39,32 @@ label_settings = SubResource("LabelSettings_js4li")
horizontal_alignment = 1
vertical_alignment = 1
text_overrun_behavior = 3
[node name="PlantPreviewContainer" type="Control" parent="."]
clip_contents = true
layout_mode = 1
anchor_left = -0.061
anchor_top = -0.036
anchor_right = 1.061
anchor_bottom = 0.661
offset_left = 0.00199986
offset_top = 0.0320001
offset_right = -0.0019989
offset_bottom = -0.0319977
mouse_filter = 2
[node name="Preview" type="TextureRect" parent="PlantPreviewContainer"]
layout_mode = 1
anchors_preset = -1
anchor_left = 0.185
anchor_top = 0.205
anchor_right = 0.815
anchor_bottom = 1.333
offset_left = -0.0200005
offset_top = 0.00999928
offset_right = 0.0199966
offset_bottom = 0.0259933
mouse_filter = 2
mouse_default_cursor_shape = 2
expand_mode = 1
stretch_mode = 5

View file

@ -1,11 +1,21 @@
[gd_scene load_steps=6 format=3 uid="uid://cfnmspei3k4p7"]
[gd_scene load_steps=9 format=3 uid="uid://cfnmspei3k4p7"]
[ext_resource type="PackedScene" uid="uid://ky35veswaytr" path="res://scenes/gui/sun_counter.tscn" id="1_le3od"]
[ext_resource type="PackedScene" uid="uid://c8qru1yhnbbkl" path="res://scenes/gui/plant_card.tscn" id="2_cjtsw"]
[ext_resource type="Texture2D" uid="uid://bbh0uwloi87tn" path="res://assets/sprites/gui/PlantPanel.png" id="2_eg3hk"]
[ext_resource type="Resource" uid="uid://c8rr1dc7mjr3d" path="res://resources/plants/Peashooter.tres" id="3_42s2d"]
[ext_resource type="PackedScene" uid="uid://t0vpmycj6c8j" path="res://scenes/gui/shovel_button.tscn" id="3_bheea"]
[ext_resource type="PackedScene" uid="uid://cgm7td1hgs0rr" path="res://scenes/gui/fast_forward_button.tscn" id="4_66uy4"]
[ext_resource type="PackedScene" uid="uid://u5l3jd00s8vd" path="res://scenes/gui/pause_button.tscn" id="5_jyq78"]
[sub_resource type="StyleBoxTexture" id="StyleBoxTexture_ps2iw"]
texture = ExtResource("2_eg3hk")
texture_margin_left = 4.0
texture_margin_top = 4.0
texture_margin_right = 4.0
texture_margin_bottom = 4.0
axis_stretch_horizontal = 1
[node name="RuntimeGUI" type="Control"]
layout_mode = 3
anchors_preset = 15
@ -26,35 +36,41 @@ metadata/_edit_use_anchors_ = true
[node name="SunCounter" parent="Hotbar" instance=ExtResource("1_le3od")]
layout_mode = 2
[node name="Seedpackets" type="HBoxContainer" parent="Hotbar"]
[node name="PanelContainer" type="PanelContainer" parent="Hotbar"]
layout_mode = 2
theme_override_styles/panel = SubResource("StyleBoxTexture_ps2iw")
[node name="Seedpackets" type="HBoxContainer" parent="Hotbar/PanelContainer"]
layout_mode = 2
theme_override_constants/separation = 0
[node name="PlantCard" parent="Hotbar/Seedpackets" instance=ExtResource("2_cjtsw")]
[node name="FirstSlot" parent="Hotbar/PanelContainer/Seedpackets" instance=ExtResource("2_cjtsw")]
layout_mode = 2
focus_neighbor_right = NodePath("../SecondSlot")
_resource = ExtResource("3_42s2d")
[node name="SecondSlot" parent="Hotbar/PanelContainer/Seedpackets" instance=ExtResource("2_cjtsw")]
layout_mode = 2
[node name="PlantCard2" parent="Hotbar/Seedpackets" instance=ExtResource("2_cjtsw")]
[node name="ThirdSlot" parent="Hotbar/PanelContainer/Seedpackets" instance=ExtResource("2_cjtsw")]
layout_mode = 2
[node name="PlantCard3" parent="Hotbar/Seedpackets" instance=ExtResource("2_cjtsw")]
[node name="FourthSlot" parent="Hotbar/PanelContainer/Seedpackets" instance=ExtResource("2_cjtsw")]
layout_mode = 2
[node name="PlantCard4" parent="Hotbar/Seedpackets" instance=ExtResource("2_cjtsw")]
[node name="FifthSlot" parent="Hotbar/PanelContainer/Seedpackets" instance=ExtResource("2_cjtsw")]
layout_mode = 2
[node name="PlantCard5" parent="Hotbar/Seedpackets" instance=ExtResource("2_cjtsw")]
[node name="SixthSlot" parent="Hotbar/PanelContainer/Seedpackets" instance=ExtResource("2_cjtsw")]
layout_mode = 2
[node name="PlantCard6" parent="Hotbar/Seedpackets" instance=ExtResource("2_cjtsw")]
[node name="SeventhSlot" parent="Hotbar/PanelContainer/Seedpackets" instance=ExtResource("2_cjtsw")]
layout_mode = 2
[node name="PlantCard7" parent="Hotbar/Seedpackets" instance=ExtResource("2_cjtsw")]
[node name="EighthSlot" parent="Hotbar/PanelContainer/Seedpackets" instance=ExtResource("2_cjtsw")]
layout_mode = 2
[node name="PlantCard8" parent="Hotbar/Seedpackets" instance=ExtResource("2_cjtsw")]
layout_mode = 2
[node name="PlantCard9" parent="Hotbar/Seedpackets" instance=ExtResource("2_cjtsw")]
[node name="NinthSlot" parent="Hotbar/PanelContainer/Seedpackets" instance=ExtResource("2_cjtsw")]
layout_mode = 2
[node name="ShovelButton" parent="Hotbar" instance=ExtResource("3_bheea")]

View file

@ -7,12 +7,17 @@ public partial class Cursor : Node
public override void _Ready()
{
Instance = this;
SetDefaultCursorSet();
SetDefaultCursor();
}
public void SetDefaultCursorSet()
public void SetDefaultCursor()
{
Input.SetCustomMouseCursor(ResourceLoader.Load<Texture2D>("res://assets/sprites/atlases/cursor/default_arrow.png"));
Input.SetCustomMouseCursor(ResourceLoader.Load<Texture2D>("res://assets/sprites/atlases/cursor/default_point.png"),shape:Input.CursorShape.PointingHand);
}
public void SetPlantCursor()
{
Input.SetCustomMouseCursor(ResourceLoader.Load<Texture2D>("res://assets/sprites/atlases/cursor/plant_arrow.png"));
}
}

View file

@ -1,5 +1,4 @@
using Godot;
using System;
//
// Class that gives access to level data, pools and etc.
@ -11,8 +10,10 @@ public partial class LevelController : Node
private bool _isLevelRunning = false;
// Frequently accessed level elements
public RuntimeLevelData LevelData { get; set; }
public PoolContainer Pools { get; set; }
public PlantField PlantField { get; set; }
public override void _EnterTree()
{
@ -24,6 +25,11 @@ public partial class LevelController : Node
Instance = null;
}
/// <summary>
///
/// </summary>
/// <param name="levelTileset">Scene that will be loaded</param>
/// <param name="levelScript">Optional script that will be attached to loaded scene</param>
public void StartLevel(PackedScene levelTileset, Script levelScript = null)
{
if (_isLevelRunning)
@ -44,6 +50,7 @@ public partial class LevelController : Node
LevelData = null;
Pools = null;
PlantField = null;
_isLevelRunning = false;
}

View file

@ -0,0 +1,22 @@
using Godot;
using System;
public partial class PlantSlot : Node
{
[Export] private PlantResource _resource;
[Export] private Label _cost;
[Export] private TextureRect _icon;
public void SetPlantResource( PlantResource resource )
{
_resource = resource;
UpdateContents();
}
private void UpdateContents()
{
_cost.Text = _resource.Cost.ToString();
_icon.Texture = _resource.Preview;
}
}

View file

@ -0,0 +1,34 @@
using Godot;
public partial class PlantField : Node2D
{
private Area2D _plantSetter;
private readonly Vector2 tile = new Vector2(Utility.TileWidth, Utility.TileHeight);
private bool _canPlace;
public override void _Ready()
{
LevelController.Instance.PlantField = this;
_plantSetter = GetChild<Area2D>(0);
}
public override void _Process(double delta)
{
var mouse_pos = GetGlobalMousePosition();
_plantSetter.GlobalPosition = mouse_pos;
var expected_pos = (_plantSetter.GlobalPosition / tile).Ceil() * tile - new Vector2(20, 14);
if (expected_pos.X > Utility.LeftFieldBoundary.X && expected_pos.X < Utility.RightFieldBoundary.X && expected_pos.Y > Utility.LeftFieldBoundary.Y && expected_pos.Y < Utility.RightFieldBoundary.Y)
{
_canPlace = true;
Material.Set("shader_parameter/amount", 0);
Cursor.Instance.SetPlantCursor();
_plantSetter.GlobalPosition = expected_pos;
}
else
{
_canPlace = false;
Cursor.Instance.SetDefaultCursor();
Material.Set("shader_parameter/amount", 1);
}
}
}

View file

@ -0,0 +1,41 @@
using Godot;
using System;
public partial class EatBox : Area2D
{
// Rewrite this class completely when field system will be introduced.
[Export] private int _damage;
[Export] private AnimationTree _animationTree;
private RuntimePlantData plant;
public void Bite()
{
plant.TakeDamage(_damage);
}
public void OnAreaEntered(Area2D area)
{
var parent = area.GetParent();
if (parent != null && parent is RuntimePlantData plantData)
{
plant = plantData;
_animationTree.Set("parameters/conditions/eat", true);
_animationTree.Set("parameters/conditions/end_eat", false);
}
}
public void OnAreaExited(Area2D area)
{
var parent = area.GetParent();
if (parent == plant)
{
plant = null;
_animationTree.Set("parameters/conditions/eat", false);
_animationTree.Set("parameters/conditions/end_eat", true);
}
}
}

View file

@ -0,0 +1,24 @@
using Godot;
using System;
public partial class ZombieMover : Node
{
private float _speed;
private Node2D _zombie;
public override void _Ready()
{
_zombie = GetParent<Node2D>();
}
public override void _PhysicsProcess(double delta)
{
_zombie.Position -= _zombie.Transform.X * _speed * (float)delta * Utility.TileWidth;
}
public void SetSpeed(float speed)
{
_speed = speed;
}
}

View file

@ -0,0 +1,18 @@
using Godot;
using System;
public partial class BasicZombieBehaviour : Node
{
[Export] private AnimationTree _animationTree;
public void StartEating()
{
_animationTree.Set("parameters/conditions/eat",true);
_animationTree.Set("parameters/conditions/end_eat", false);
GD.Print("StartEating");
}
public void EndEating()
{
_animationTree.Set("parameters/conditions/eat", false);
_animationTree.Set("parameters/conditions/end_eat", true);
}
}

View file

@ -13,5 +13,5 @@ public partial class PlantResource : Resource
[Export]
public float StartReloadTime;
[Export]
public Texture Preview;
public Texture2D Preview;
}