✨ Turret tile basis
This commit is contained in:
@@ -21,6 +21,18 @@
|
||||
"layer": 1,
|
||||
"size": [1, 1]
|
||||
},
|
||||
"turret": {
|
||||
"scene": "res://Scenes/Tiles/TurretTile.tscn",
|
||||
"cost": {
|
||||
"stone": 10,
|
||||
"ore_iron": 5
|
||||
},
|
||||
"durability": 200,
|
||||
"buildTime": 5.0,
|
||||
"allowedRotations": [0],
|
||||
"layer": 1,
|
||||
"size": [1, 1]
|
||||
},
|
||||
"enemy_nest": {
|
||||
"scene": "res://Scenes/Tiles/EnemyNest.tscn",
|
||||
"cost": {},
|
||||
|
@@ -7,9 +7,10 @@
|
||||
[sub_resource type="RectangleShape2D" id="RectangleShape2D_id484"]
|
||||
size = Vector2(54, 54)
|
||||
|
||||
[node name="EnemyNest" type="CharacterBody2D"]
|
||||
[node name="EnemyNest" type="StaticBody2D"]
|
||||
script = ExtResource("1_4g0ff")
|
||||
EnemyScene = ExtResource("2_pka71")
|
||||
TileId = "enemy_nest"
|
||||
|
||||
[node name="Sprite2D" type="Sprite2D" parent="."]
|
||||
scale = Vector2(0.056, 0.056)
|
||||
|
BIN
Scenes/Tiles/TurretTile.png
Normal file
BIN
Scenes/Tiles/TurretTile.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 448 KiB |
34
Scenes/Tiles/TurretTile.png.import
Normal file
34
Scenes/Tiles/TurretTile.png.import
Normal file
@@ -0,0 +1,34 @@
|
||||
[remap]
|
||||
|
||||
importer="texture"
|
||||
type="CompressedTexture2D"
|
||||
uid="uid://ckssi7soymu7g"
|
||||
path="res://.godot/imported/TurretTile.png-d55543f854deaa0fedf248ba979d1cb4.ctex"
|
||||
metadata={
|
||||
"vram_texture": false
|
||||
}
|
||||
|
||||
[deps]
|
||||
|
||||
source_file="res://Scenes/Tiles/TurretTile.png"
|
||||
dest_files=["res://.godot/imported/TurretTile.png-d55543f854deaa0fedf248ba979d1cb4.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
|
32
Scenes/Tiles/TurretTile.tscn
Normal file
32
Scenes/Tiles/TurretTile.tscn
Normal file
@@ -0,0 +1,32 @@
|
||||
[gd_scene load_steps=5 format=3 uid="uid://dbup2pvjl8het"]
|
||||
|
||||
[ext_resource type="Script" uid="uid://n5g6i0uovxfk" path="res://Scripts/Tiles/TurretTile.cs" id="1_j3157"]
|
||||
[ext_resource type="Texture2D" uid="uid://ckssi7soymu7g" path="res://Scenes/Tiles/TurretTile.png" id="2_7ljeh"]
|
||||
[ext_resource type="Texture2D" uid="uid://dmbbkwgff7dej" path="res://Scenes/Tiles/TurretTileBarrel.png" id="3_gfad6"]
|
||||
|
||||
[sub_resource type="RectangleShape2D" id="RectangleShape2D_pndcb"]
|
||||
size = Vector2(54, 54)
|
||||
|
||||
[node name="Turret" type="StaticBody2D"]
|
||||
script = ExtResource("1_j3157")
|
||||
TileId = "turret"
|
||||
|
||||
[node name="Sprite2D" type="Sprite2D" parent="."]
|
||||
scale = Vector2(0.1, 0.1)
|
||||
texture = ExtResource("2_7ljeh")
|
||||
|
||||
[node name="Barrel" type="Sprite2D" parent="."]
|
||||
position = Vector2(0, -3)
|
||||
scale = Vector2(0.08, 0.08)
|
||||
texture = ExtResource("3_gfad6")
|
||||
offset = Vector2(0, -54)
|
||||
|
||||
[node name="CollisionShape2D" type="CollisionShape2D" parent="."]
|
||||
shape = SubResource("RectangleShape2D_pndcb")
|
||||
|
||||
[node name="ProgressOverlay" type="ColorRect" parent="."]
|
||||
visible = false
|
||||
offset_left = -27.0
|
||||
offset_top = -27.0
|
||||
offset_right = 27.0
|
||||
offset_bottom = 27.0
|
BIN
Scenes/Tiles/TurretTileBarrel.png
Normal file
BIN
Scenes/Tiles/TurretTileBarrel.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 185 KiB |
34
Scenes/Tiles/TurretTileBarrel.png.import
Normal file
34
Scenes/Tiles/TurretTileBarrel.png.import
Normal file
@@ -0,0 +1,34 @@
|
||||
[remap]
|
||||
|
||||
importer="texture"
|
||||
type="CompressedTexture2D"
|
||||
uid="uid://dmbbkwgff7dej"
|
||||
path="res://.godot/imported/TurretTileBarrel.png-a9f6a29579c44d5d6ed4cc8f6c09fd72.ctex"
|
||||
metadata={
|
||||
"vram_texture": false
|
||||
}
|
||||
|
||||
[deps]
|
||||
|
||||
source_file="res://Scenes/Tiles/TurretTileBarrel.png"
|
||||
dest_files=["res://.godot/imported/TurretTileBarrel.png-a9f6a29579c44d5d6ed4cc8f6c09fd72.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
|
@@ -4,6 +4,8 @@ namespace AceFieldNewHorizon.Scripts.Entities;
|
||||
|
||||
public partial class Enemy : CharacterBody2D
|
||||
{
|
||||
public const string EnemyGroupName = "Enemy";
|
||||
|
||||
[Export] public float MoveSpeed = 150.0f;
|
||||
[Export] public float DetectionRadius = 300.0f;
|
||||
[Export] public float AttackRange = 50.0f;
|
||||
@@ -29,6 +31,8 @@ public partial class Enemy : CharacterBody2D
|
||||
// Connect signals
|
||||
_detectionArea.BodyEntered += OnBodyEnteredDetection;
|
||||
_detectionArea.BodyExited += OnBodyExitedDetection;
|
||||
|
||||
AddToGroup(EnemyGroupName);
|
||||
}
|
||||
|
||||
public override void _Process(double delta)
|
||||
|
@@ -16,7 +16,7 @@ public partial class PlacementManager : Node2D
|
||||
[Export] public bool Enabled { get; set; } = true;
|
||||
[Export] public StringName ToggleBuildAction { get; set; } = "toggle_build";
|
||||
|
||||
private static readonly List<string> BuildableTiles = ["wall", "miner"];
|
||||
private static readonly List<string> BuildableTiles = ["wall", "miner", "turret"];
|
||||
private readonly Dictionary<Node2D, BuildTask> _buildTasks = new();
|
||||
private AudioStreamPlayer _completionSound;
|
||||
private AudioStreamPlayer _buildingSound;
|
||||
|
@@ -28,7 +28,7 @@ public partial class BaseTile : Node2D
|
||||
_progressOverlay.Visible = false;
|
||||
}
|
||||
|
||||
public void SetGhostMode(bool canPlace)
|
||||
public virtual void SetGhostMode(bool canPlace)
|
||||
{
|
||||
// Don't modify collision for constructing buildings
|
||||
if (IsConstructing) return;
|
||||
@@ -42,7 +42,7 @@ public partial class BaseTile : Node2D
|
||||
: new Color(1, 0, 0, 0.5f);
|
||||
}
|
||||
|
||||
public void FinalizePlacement()
|
||||
public virtual void FinalizePlacement()
|
||||
{
|
||||
if (_collisionShape != null)
|
||||
_collisionShape.Disabled = false;
|
||||
|
33
Scripts/Tiles/TurretTile.cs
Normal file
33
Scripts/Tiles/TurretTile.cs
Normal file
@@ -0,0 +1,33 @@
|
||||
using Godot;
|
||||
|
||||
namespace AceFieldNewHorizon.Scripts.Tiles;
|
||||
|
||||
public partial class TurretTile : BaseTile
|
||||
{
|
||||
private Sprite2D _spriteBarrel;
|
||||
|
||||
public override void _Ready()
|
||||
{
|
||||
base._Ready();
|
||||
|
||||
_spriteBarrel = GetNodeOrNull<Sprite2D>("Barrel");
|
||||
}
|
||||
|
||||
public override void SetGhostMode(bool canPlace)
|
||||
{
|
||||
base.SetGhostMode(canPlace);
|
||||
|
||||
if (_spriteBarrel != null)
|
||||
_spriteBarrel.Modulate = canPlace
|
||||
? new Color(0, 1, 0, 0.5f)
|
||||
: new Color(1, 0, 0, 0.5f);
|
||||
}
|
||||
|
||||
public override void FinalizePlacement()
|
||||
{
|
||||
base.FinalizePlacement();
|
||||
|
||||
if (_spriteBarrel != null)
|
||||
_spriteBarrel.Modulate = Colors.White;
|
||||
}
|
||||
}
|
1
Scripts/Tiles/TurretTile.cs.uid
Normal file
1
Scripts/Tiles/TurretTile.cs.uid
Normal file
@@ -0,0 +1 @@
|
||||
uid://n5g6i0uovxfk
|
Reference in New Issue
Block a user