Compare commits
2 Commits
9a6566a178
...
ecea198766
| Author | SHA1 | Date | |
|---|---|---|---|
| ecea198766 | |||
| 8f2912a174 |
@@ -9,4 +9,7 @@
|
|||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<PackageReference Include="GodotSharp.SourceGenerators" Version="2.7.0" />
|
<PackageReference Include="GodotSharp.SourceGenerators" Version="2.7.0" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<Folder Include="src\Gameplay\Nodules\BasicNodule\" />
|
||||||
|
</ItemGroup>
|
||||||
</Project>
|
</Project>
|
||||||
|
|||||||
BIN
assets/root_nodule.aseprite
Normal file
BIN
assets/root_nodule.aseprite
Normal file
Binary file not shown.
BIN
assets/root_nodule.png
Normal file
BIN
assets/root_nodule.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 409 B |
40
assets/root_nodule.png.import
Normal file
40
assets/root_nodule.png.import
Normal file
@@ -0,0 +1,40 @@
|
|||||||
|
[remap]
|
||||||
|
|
||||||
|
importer="texture"
|
||||||
|
type="CompressedTexture2D"
|
||||||
|
uid="uid://tomd3kojw0qy"
|
||||||
|
path="res://.godot/imported/root_nodule.png-981ed6f2ff13b8d32aab753225ea9d2d.ctex"
|
||||||
|
metadata={
|
||||||
|
"vram_texture": false
|
||||||
|
}
|
||||||
|
|
||||||
|
[deps]
|
||||||
|
|
||||||
|
source_file="res://assets/root_nodule.png"
|
||||||
|
dest_files=["res://.godot/imported/root_nodule.png-981ed6f2ff13b8d32aab753225ea9d2d.ctex"]
|
||||||
|
|
||||||
|
[params]
|
||||||
|
|
||||||
|
compress/mode=0
|
||||||
|
compress/high_quality=false
|
||||||
|
compress/lossy_quality=0.7
|
||||||
|
compress/uastc_level=0
|
||||||
|
compress/rdo_quality_loss=0.0
|
||||||
|
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/channel_remap/red=0
|
||||||
|
process/channel_remap/green=1
|
||||||
|
process/channel_remap/blue=2
|
||||||
|
process/channel_remap/alpha=3
|
||||||
|
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
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
using Godot;
|
using Godot;
|
||||||
using Slimepire.Gameplay.Nodules.Components;
|
using Slimepire.Gameplay.Components;
|
||||||
|
|
||||||
namespace Slimepire.Core;
|
namespace Slimepire.Core;
|
||||||
|
|
||||||
|
|||||||
@@ -1,8 +1,8 @@
|
|||||||
[gd_resource type="Resource" script_class="NoduleResource" format=3 uid="uid://0d8vif4ejtp1"]
|
[gd_resource type="Resource" script_class="NoduleResource" format=3 uid="uid://0d8vif4ejtp1"]
|
||||||
|
|
||||||
[ext_resource type="Texture2D" uid="uid://ds1idectpqbnh" path="res://assets/energy_storage_nodule.png" id="1_237jx"]
|
[ext_resource type="Texture2D" uid="uid://ds1idectpqbnh" path="res://assets/energy_storage_nodule.png" id="1_237jx"]
|
||||||
[ext_resource type="PackedScene" uid="uid://by6iw05ovnhq8" path="res://src/Gameplay/Nodules/Components/EnergyStorage.tscn" id="1_dusyu"]
|
[ext_resource type="PackedScene" uid="uid://by6iw05ovnhq8" path="res://src/Gameplay/Components/EnergyStorage.tscn" id="1_dusyu"]
|
||||||
[ext_resource type="Script" uid="uid://bnf6qmk64i2wj" path="res://src/Data/NoduleResource.cs" id="2_dusyu"]
|
[ext_resource type="Script" uid="uid://bnf6qmk64i2wj" path="res://src/Data/NoduleStats.cs" id="2_dusyu"]
|
||||||
|
|
||||||
[sub_resource type="AtlasTexture" id="AtlasTexture_dusyu"]
|
[sub_resource type="AtlasTexture" id="AtlasTexture_dusyu"]
|
||||||
atlas = ExtResource("1_237jx")
|
atlas = ExtResource("1_237jx")
|
||||||
|
|||||||
@@ -3,10 +3,10 @@ using Godot;
|
|||||||
namespace Slimepire.Data;
|
namespace Slimepire.Data;
|
||||||
|
|
||||||
[GlobalClass]
|
[GlobalClass]
|
||||||
public partial class NoduleResource : Resource
|
public partial class NoduleStats : Resource
|
||||||
{
|
{
|
||||||
[Export]
|
[Export]
|
||||||
public SpriteFrames SpriteFrames;
|
public SpriteFrames SpriteFrames = null!;
|
||||||
|
|
||||||
[Export]
|
[Export]
|
||||||
public Color Color;
|
public Color Color;
|
||||||
@@ -1,7 +1,7 @@
|
|||||||
[gd_resource type="Resource" script_class="NoduleResource" format=3 uid="uid://5gk0giodp6g"]
|
[gd_resource type="Resource" script_class="NoduleStats" format=3 uid="uid://5gk0giodp6g"]
|
||||||
|
|
||||||
[ext_resource type="Texture2D" uid="uid://cecg47efx7gw8" path="res://assets/simple_nodule.png" id="1_j6wbi"]
|
[ext_resource type="Texture2D" uid="uid://cecg47efx7gw8" path="res://assets/simple_nodule.png" id="1_j6wbi"]
|
||||||
[ext_resource type="Script" uid="uid://bnf6qmk64i2wj" path="res://src/Data/NoduleResource.cs" id="1_otepm"]
|
[ext_resource type="Script" uid="uid://bnf6qmk64i2wj" path="res://src/Data/NoduleStats.cs" id="1_otepm"]
|
||||||
|
|
||||||
[sub_resource type="AtlasTexture" id="AtlasTexture_j6wbi"]
|
[sub_resource type="AtlasTexture" id="AtlasTexture_j6wbi"]
|
||||||
atlas = ExtResource("1_j6wbi")
|
atlas = ExtResource("1_j6wbi")
|
||||||
@@ -37,5 +37,4 @@ script = ExtResource("1_otepm")
|
|||||||
SpriteFrames = SubResource("SpriteFrames_x44k2")
|
SpriteFrames = SubResource("SpriteFrames_x44k2")
|
||||||
Color = Color(0.2642648, 0.46582836, 0.36528692, 1)
|
Color = Color(0.2642648, 0.46582836, 0.36528692, 1)
|
||||||
NoduleName = "Simple Nodule"
|
NoduleName = "Simple Nodule"
|
||||||
NoduleType = 1
|
|
||||||
metadata/_custom_type_script = "uid://bnf6qmk64i2wj"
|
metadata/_custom_type_script = "uid://bnf6qmk64i2wj"
|
||||||
|
|||||||
@@ -1,13 +1,16 @@
|
|||||||
using Godot;
|
using Godot;
|
||||||
|
using Slimepire.Gameplay.Components;
|
||||||
using Slimepire.Gameplay.Nodules;
|
using Slimepire.Gameplay.Nodules;
|
||||||
using Slimepire.Gameplay.Nodules.Components;
|
|
||||||
|
|
||||||
namespace Slimepire.Gameplay;
|
namespace Slimepire.Gameplay;
|
||||||
|
|
||||||
[SceneTree]
|
[SceneTree]
|
||||||
public partial class BuildGhost : Node2D
|
public partial class BuildGhost : Node2D
|
||||||
{
|
{
|
||||||
private Tube? _tube;
|
private static readonly PackedScene NoduleScene = GD.Load<PackedScene>(
|
||||||
|
"res://src/Gameplay/Nodules/BasicNodule/BasicNodule.tscn"
|
||||||
|
);
|
||||||
|
|
||||||
private readonly Dictionary<Nodule, Tube> _connectedTubes = [];
|
private readonly Dictionary<Nodule, Tube> _connectedTubes = [];
|
||||||
|
|
||||||
[Export]
|
[Export]
|
||||||
@@ -15,17 +18,22 @@ public partial class BuildGhost : Node2D
|
|||||||
|
|
||||||
public override void _Ready()
|
public override void _Ready()
|
||||||
{
|
{
|
||||||
_tubeConnectionArea.ConnectionAdded += ConnectionAdded;
|
_tubeConnectionArea.AreaEntered += OnAreaEntered;
|
||||||
_tubeConnectionArea.ConnectionRemoved += ConnectionRemoved;
|
_tubeConnectionArea.AreaExited += OnAreaExited;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void ConnectionAdded(Nodule nodule)
|
private void OnAreaEntered(Area2D area)
|
||||||
|
{
|
||||||
|
if (area.GetParent() is Nodule nodule)
|
||||||
{
|
{
|
||||||
CreateGhostTube(nodule, nodule.GlobalPosition);
|
CreateGhostTube(nodule, nodule.GlobalPosition);
|
||||||
ConnectTubePlayer.Play();
|
ConnectTubePlayer.Play();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private void ConnectionRemoved(Nodule nodule)
|
private void OnAreaExited(Area2D area)
|
||||||
|
{
|
||||||
|
if (area.GetParent() is Nodule nodule)
|
||||||
{
|
{
|
||||||
var tube = _connectedTubes.GetValueOrDefault(nodule);
|
var tube = _connectedTubes.GetValueOrDefault(nodule);
|
||||||
if (tube == null)
|
if (tube == null)
|
||||||
@@ -35,11 +43,12 @@ public partial class BuildGhost : Node2D
|
|||||||
tube.QueueFree();
|
tube.QueueFree();
|
||||||
DisconnectTubePlayer.Play();
|
DisconnectTubePlayer.Play();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private void CreateGhostTube(Nodule connectedNodule, Vector2 pos)
|
private void CreateGhostTube(Nodule connectedNodule, Vector2 pos)
|
||||||
{
|
{
|
||||||
var tube = Instantiator.Instantiate<Tube>();
|
var tube = Instantiator.Instantiate<Tube>();
|
||||||
tube.Position = pos / 2; // TODO WHYYY????
|
tube.Position = pos;
|
||||||
_connectedTubes.Add(connectedNodule, tube);
|
_connectedTubes.Add(connectedNodule, tube);
|
||||||
GetParent()?.AddChild(tube);
|
GetParent()?.AddChild(tube);
|
||||||
}
|
}
|
||||||
@@ -76,15 +85,9 @@ public partial class BuildGhost : Node2D
|
|||||||
|
|
||||||
if (@event is InputEventMouseButton { Pressed: false, ButtonIndex: MouseButton.Left })
|
if (@event is InputEventMouseButton { Pressed: false, ButtonIndex: MouseButton.Left })
|
||||||
{
|
{
|
||||||
var nodule = Instantiator.Instantiate<Nodule>();
|
var nodule = NoduleScene.Instantiate<Nodule>();
|
||||||
|
|
||||||
nodule.Position = Position;
|
nodule.Position = Position;
|
||||||
// nodule.NoduleResource = GD.Load<NoduleResource>(
|
|
||||||
// GameResources.SimpleNoduleTres.ResourcePath
|
|
||||||
// );
|
|
||||||
|
|
||||||
GetParent()?.AddChild(nodule);
|
GetParent()?.AddChild(nodule);
|
||||||
|
|
||||||
CleanupBuildMode();
|
CleanupBuildMode();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
[ext_resource type="Script" uid="uid://ck5yw760bu8sb" path="res://src/Gameplay/BuildGhost.cs" id="1_ahcoi"]
|
[ext_resource type="Script" uid="uid://ck5yw760bu8sb" path="res://src/Gameplay/BuildGhost.cs" id="1_ahcoi"]
|
||||||
[ext_resource type="Texture2D" uid="uid://cecg47efx7gw8" path="res://assets/simple_nodule.png" id="2_uo42j"]
|
[ext_resource type="Texture2D" uid="uid://cecg47efx7gw8" path="res://assets/simple_nodule.png" id="2_uo42j"]
|
||||||
[ext_resource type="PackedScene" uid="uid://bjesfu1mfx8l5" path="res://src/Gameplay/Nodules/Components/TubeConnectionArea.tscn" id="2_vecmk"]
|
[ext_resource type="PackedScene" uid="uid://bjesfu1mfx8l5" path="res://src/Gameplay/Components/TubeConnectionArea.tscn" id="2_vecmk"]
|
||||||
[ext_resource type="AudioStream" uid="uid://mj8wvuwfc6o7" path="res://assets/sfx/tube_disconnect.wav" id="3_nxaxp"]
|
[ext_resource type="AudioStream" uid="uid://mj8wvuwfc6o7" path="res://assets/sfx/tube_disconnect.wav" id="3_nxaxp"]
|
||||||
[ext_resource type="AudioStream" uid="uid://bxxi7grsubvgm" path="res://assets/sfx/tube_connect.wav" id="3_quiac"]
|
[ext_resource type="AudioStream" uid="uid://bxxi7grsubvgm" path="res://assets/sfx/tube_connect.wav" id="3_quiac"]
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
using Godot;
|
using Godot;
|
||||||
using Slimepire.Core;
|
using Slimepire.Core;
|
||||||
|
|
||||||
namespace Slimepire.Gameplay.Nodules.Components;
|
namespace Slimepire.Gameplay.Components;
|
||||||
|
|
||||||
public partial class EnergyProducer : Node
|
public partial class EnergyProducer : Node
|
||||||
{
|
{
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
[gd_scene format=3 uid="uid://t0gdf172f65v"]
|
[gd_scene format=3 uid="uid://t0gdf172f65v"]
|
||||||
|
|
||||||
[ext_resource type="Script" uid="uid://bku1vey63ew65" path="res://src/Gameplay/Nodules/Components/EnergyProducer.cs" id="1_4q7h4"]
|
[ext_resource type="Script" uid="uid://bku1vey63ew65" path="res://src/Gameplay/Components/EnergyProducer.cs" id="1_4q7h4"]
|
||||||
|
|
||||||
[node name="EnergyProducer" type="Node" unique_id=1184182162]
|
[node name="EnergyProducer" type="Node" unique_id=1184182162]
|
||||||
script = ExtResource("1_4q7h4")
|
script = ExtResource("1_4q7h4")
|
||||||
@@ -1,7 +1,7 @@
|
|||||||
using Godot;
|
using Godot;
|
||||||
using Slimepire.Core;
|
using Slimepire.Core;
|
||||||
|
|
||||||
namespace Slimepire.Gameplay.Nodules.Components;
|
namespace Slimepire.Gameplay.Components;
|
||||||
|
|
||||||
public partial class EnergyStorage : Node
|
public partial class EnergyStorage : Node
|
||||||
{
|
{
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
[gd_scene format=3 uid="uid://by6iw05ovnhq8"]
|
[gd_scene format=3 uid="uid://by6iw05ovnhq8"]
|
||||||
|
|
||||||
[ext_resource type="Script" uid="uid://dgkeo1wsicv13" path="res://src/Gameplay/Nodules/Components/EnergyStorage.cs" id="1_vetx7"]
|
[ext_resource type="Script" uid="uid://dgkeo1wsicv13" path="res://src/Gameplay/Components/EnergyStorage.cs" id="1_vetx7"]
|
||||||
|
|
||||||
[node name="EnergyStorage" type="Node" unique_id=1765924301]
|
[node name="EnergyStorage" type="Node" unique_id=1765924301]
|
||||||
script = ExtResource("1_vetx7")
|
script = ExtResource("1_vetx7")
|
||||||
@@ -1,7 +1,6 @@
|
|||||||
using Godot;
|
using Godot;
|
||||||
using Slimepire.Core;
|
|
||||||
|
|
||||||
namespace Slimepire.Gameplay.Nodules.Components;
|
namespace Slimepire.Gameplay.Components;
|
||||||
|
|
||||||
[SceneTree]
|
[SceneTree]
|
||||||
public partial class GrowArea : Area2D
|
public partial class GrowArea : Area2D
|
||||||
7
src/Gameplay/Components/GrowArea.tscn
Normal file
7
src/Gameplay/Components/GrowArea.tscn
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
[gd_scene format=3 uid="uid://3x5pqm4t5cbl"]
|
||||||
|
|
||||||
|
[ext_resource type="Script" uid="uid://cfxb8wmnt7ej7" path="res://src/Gameplay/Components/GrowArea.cs" id="1_a3tcn"]
|
||||||
|
|
||||||
|
[node name="GrowArea" type="Area2D" unique_id=979341496]
|
||||||
|
monitorable = false
|
||||||
|
script = ExtResource("1_a3tcn")
|
||||||
8
src/Gameplay/Components/TubeConnectionArea.cs
Normal file
8
src/Gameplay/Components/TubeConnectionArea.cs
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
using Godot;
|
||||||
|
|
||||||
|
namespace Slimepire.Gameplay.Components;
|
||||||
|
|
||||||
|
[GlobalClass]
|
||||||
|
public partial class TubeConnectionArea : Area2D
|
||||||
|
{
|
||||||
|
}
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
[gd_scene format=3 uid="uid://bjesfu1mfx8l5"]
|
[gd_scene format=3 uid="uid://bjesfu1mfx8l5"]
|
||||||
|
|
||||||
[ext_resource type="Script" uid="uid://bcw8vylpb533h" path="res://src/Gameplay/Nodules/Components/TubeConnectionArea.cs" id="1_uhdst"]
|
[ext_resource type="Script" uid="uid://bcw8vylpb533h" path="res://src/Gameplay/Components/TubeConnectionArea.cs" id="1_uhdst"]
|
||||||
|
|
||||||
[sub_resource type="CircleShape2D" id="CircleShape2D_x44k2"]
|
[sub_resource type="CircleShape2D" id="CircleShape2D_x44k2"]
|
||||||
radius = 96.38
|
radius = 96.38
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
using Godot;
|
using Godot;
|
||||||
using Slimepire.Gameplay.Nodules;
|
using Slimepire.Gameplay.Nodules;
|
||||||
|
|
||||||
namespace Slimepire.Gameplay;
|
namespace Slimepire.Gameplay;
|
||||||
@@ -9,7 +9,7 @@ public partial class NoduleManager
|
|||||||
public bool Building { get; set; }
|
public bool Building { get; set; }
|
||||||
|
|
||||||
private AStar2D _aStar = new();
|
private AStar2D _aStar = new();
|
||||||
private readonly List<Nodule> _nodules = [];
|
private readonly Dictionary<long, Nodule> _nodules = [];
|
||||||
private readonly HashSet<NoduleConnection> _connections = [];
|
private readonly HashSet<NoduleConnection> _connections = [];
|
||||||
|
|
||||||
// GFX
|
// GFX
|
||||||
@@ -17,8 +17,8 @@ public partial class NoduleManager
|
|||||||
|
|
||||||
public void RegisterNodule(Nodule nodule)
|
public void RegisterNodule(Nodule nodule)
|
||||||
{
|
{
|
||||||
_nodules.Add(nodule);
|
_nodules.Add(nodule.NoduleId, nodule);
|
||||||
_aStar.AddPoint(nodule.Id, nodule.Position);
|
_aStar.AddPoint(nodule.NoduleId, nodule.Position);
|
||||||
|
|
||||||
UpdateNoduleConnections();
|
UpdateNoduleConnections();
|
||||||
UpdateTubesAndAstar();
|
UpdateTubesAndAstar();
|
||||||
@@ -32,29 +32,28 @@ public partial class NoduleManager
|
|||||||
|
|
||||||
private void UpdateNoduleConnections()
|
private void UpdateNoduleConnections()
|
||||||
{
|
{
|
||||||
foreach (var n in _nodules)
|
foreach (var nodule in _nodules.Values)
|
||||||
{
|
{
|
||||||
foreach (var c in n.Connections)
|
foreach (var connected in nodule.Connections)
|
||||||
{
|
{
|
||||||
_connections.Add(new NoduleConnection(n, c));
|
_connections.Add(new NoduleConnection(nodule, connected));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void UpdateTubesAndAstar()
|
private void UpdateTubesAndAstar()
|
||||||
{
|
{
|
||||||
foreach (var c in _connections)
|
foreach (var conn in _connections)
|
||||||
{
|
{
|
||||||
if (!_tubeConnections.ContainsKey(c))
|
if (!_tubeConnections.ContainsKey(conn))
|
||||||
{
|
{
|
||||||
var tube = Instantiator.Instantiate<Tube>();
|
var tube = Instantiator.Instantiate<Tube>();
|
||||||
_tubeConnections.Add(c, tube);
|
_tubeConnections.Add(conn, tube);
|
||||||
c.A.AddChild(tube);
|
|
||||||
|
|
||||||
tube.SetTarget(c.B.Position);
|
conn.A.AddChild(tube);
|
||||||
|
tube.SetTarget(conn.B.GlobalPosition);
|
||||||
|
|
||||||
// TODO: refactor this out of gfx stuff
|
_aStar.ConnectPoints(conn.A.NoduleId, conn.B.NoduleId);
|
||||||
_aStar.ConnectPoints(c.A.Id, c.B.Id);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
3
src/Gameplay/Nodules/BasicNodule/BasicNodule.cs
Normal file
3
src/Gameplay/Nodules/BasicNodule/BasicNodule.cs
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
using Slimepire.Gameplay.Nodules;
|
||||||
|
|
||||||
|
public partial class BasicNodule : Nodule { }
|
||||||
1
src/Gameplay/Nodules/BasicNodule/BasicNodule.cs.uid
Normal file
1
src/Gameplay/Nodules/BasicNodule/BasicNodule.cs.uid
Normal file
@@ -0,0 +1 @@
|
|||||||
|
uid://b2b2irskqp5au
|
||||||
@@ -1,20 +1,23 @@
|
|||||||
[gd_scene format=3 uid="uid://cnl6t8o4mh0j3"]
|
[gd_scene format=3 uid="uid://cnl6t8o4mh0j3"]
|
||||||
|
|
||||||
[ext_resource type="Script" uid="uid://cmpl0if164dba" path="res://src/Gameplay/Nodules/Nodule.cs" id="1_yembh"]
|
[ext_resource type="Script" uid="uid://b2b2irskqp5au" path="res://src/Gameplay/Nodules/BasicNodule/BasicNodule.cs" id="1_wbqr8"]
|
||||||
[ext_resource type="Texture2D" uid="uid://cecg47efx7gw8" path="res://assets/simple_nodule.png" id="2_7qt20"]
|
[ext_resource type="PackedScene" uid="uid://bjesfu1mfx8l5" path="res://src/Gameplay/Components/TubeConnectionArea.tscn" id="2_dehe6"]
|
||||||
[ext_resource type="PackedScene" uid="uid://bjesfu1mfx8l5" path="res://src/Gameplay/Nodules/Components/TubeConnectionArea.tscn" id="2_inlcu"]
|
[ext_resource type="PackedScene" uid="uid://3x5pqm4t5cbl" path="res://src/Gameplay/Components/GrowArea.tscn" id="3_pcav2"]
|
||||||
[ext_resource type="PackedScene" uid="uid://3x5pqm4t5cbl" path="res://src/Gameplay/Nodules/Components/GrowArea.tscn" id="2_x44k2"]
|
[ext_resource type="Texture2D" uid="uid://cecg47efx7gw8" path="res://assets/simple_nodule.png" id="4_w4wqd"]
|
||||||
|
|
||||||
|
[sub_resource type="CircleShape2D" id="CircleShape2D_t72h2"]
|
||||||
|
radius = 17.029387
|
||||||
|
|
||||||
[sub_resource type="AtlasTexture" id="AtlasTexture_7qt20"]
|
[sub_resource type="AtlasTexture" id="AtlasTexture_7qt20"]
|
||||||
atlas = ExtResource("2_7qt20")
|
atlas = ExtResource("4_w4wqd")
|
||||||
region = Rect2(32, 0, 32, 32)
|
region = Rect2(32, 0, 32, 32)
|
||||||
|
|
||||||
[sub_resource type="AtlasTexture" id="AtlasTexture_x44k2"]
|
[sub_resource type="AtlasTexture" id="AtlasTexture_x44k2"]
|
||||||
atlas = ExtResource("2_7qt20")
|
atlas = ExtResource("4_w4wqd")
|
||||||
region = Rect2(0, 0, 32, 32)
|
region = Rect2(0, 0, 32, 32)
|
||||||
|
|
||||||
[sub_resource type="AtlasTexture" id="AtlasTexture_inlcu"]
|
[sub_resource type="AtlasTexture" id="AtlasTexture_inlcu"]
|
||||||
atlas = ExtResource("2_7qt20")
|
atlas = ExtResource("4_w4wqd")
|
||||||
region = Rect2(64, 0, 32, 32)
|
region = Rect2(64, 0, 32, 32)
|
||||||
|
|
||||||
[sub_resource type="SpriteFrames" id="SpriteFrames_xyjsl"]
|
[sub_resource type="SpriteFrames" id="SpriteFrames_xyjsl"]
|
||||||
@@ -41,14 +44,19 @@ outline_color = Color(0, 0, 0, 1)
|
|||||||
shadow_size = 3
|
shadow_size = 3
|
||||||
shadow_color = Color(0, 0, 0, 1)
|
shadow_color = Color(0, 0, 0, 1)
|
||||||
|
|
||||||
[node name="Nodule" type="Node2D" unique_id=1637542829 node_paths=PackedStringArray("_tubeConnectionArea")]
|
[node name="BasicNodule" type="Node2D" unique_id=1637542829 node_paths=PackedStringArray("_tubeConnectionArea", "_gfx", "_energyLabel")]
|
||||||
z_index = 1
|
z_index = 1
|
||||||
script = ExtResource("1_yembh")
|
script = ExtResource("1_wbqr8")
|
||||||
_tubeConnectionArea = NodePath("TubeConnectionArea")
|
_tubeConnectionArea = NodePath("TubeConnectionArea")
|
||||||
|
_gfx = NodePath("Gfx")
|
||||||
|
_energyLabel = NodePath("EnergyLabel")
|
||||||
|
|
||||||
[node name="TubeConnectionArea" parent="." unique_id=1821668398 instance=ExtResource("2_inlcu")]
|
[node name="TubeConnectionArea" parent="." unique_id=1821668398 instance=ExtResource("2_dehe6")]
|
||||||
|
|
||||||
[node name="GrowArea" parent="." unique_id=979341496 instance=ExtResource("2_x44k2")]
|
[node name="GrowArea" parent="." unique_id=979341496 instance=ExtResource("3_pcav2")]
|
||||||
|
|
||||||
|
[node name="CollisionShape2D" type="CollisionShape2D" parent="GrowArea" unique_id=282097141]
|
||||||
|
shape = SubResource("CircleShape2D_t72h2")
|
||||||
|
|
||||||
[node name="Gfx" type="AnimatedSprite2D" parent="." unique_id=190397869]
|
[node name="Gfx" type="AnimatedSprite2D" parent="." unique_id=190397869]
|
||||||
unique_name_in_owner = true
|
unique_name_in_owner = true
|
||||||
@@ -1,13 +0,0 @@
|
|||||||
[gd_scene format=3 uid="uid://3x5pqm4t5cbl"]
|
|
||||||
|
|
||||||
[ext_resource type="Script" uid="uid://cfxb8wmnt7ej7" path="res://src/Gameplay/Nodules/Components/GrowArea.cs" id="1_a3tcn"]
|
|
||||||
|
|
||||||
[sub_resource type="CircleShape2D" id="CircleShape2D_7qt20"]
|
|
||||||
radius = 15.0
|
|
||||||
|
|
||||||
[node name="GrowArea" type="Area2D" unique_id=979341496]
|
|
||||||
monitorable = false
|
|
||||||
script = ExtResource("1_a3tcn")
|
|
||||||
|
|
||||||
[node name="CollisionShape2D" type="CollisionShape2D" parent="." unique_id=1616623898]
|
|
||||||
shape = SubResource("CircleShape2D_7qt20")
|
|
||||||
@@ -1,31 +0,0 @@
|
|||||||
using Godot;
|
|
||||||
|
|
||||||
namespace Slimepire.Gameplay.Nodules.Components;
|
|
||||||
|
|
||||||
public partial class TubeConnectionArea : Area2D
|
|
||||||
{
|
|
||||||
public Action<Nodule> ConnectionAdded { get; set; }
|
|
||||||
public Action<Nodule> ConnectionRemoved { get; set; }
|
|
||||||
|
|
||||||
public override void _Ready()
|
|
||||||
{
|
|
||||||
AreaEntered += TubeConnectionAreaOnAreaEntered;
|
|
||||||
AreaExited += TubeConnectionAreaOnAreaExited;
|
|
||||||
}
|
|
||||||
|
|
||||||
private void TubeConnectionAreaOnAreaEntered(Area2D area)
|
|
||||||
{
|
|
||||||
if (area.GetParent() is Nodule nodule)
|
|
||||||
{
|
|
||||||
ConnectionAdded?.Invoke(nodule);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void TubeConnectionAreaOnAreaExited(Area2D area)
|
|
||||||
{
|
|
||||||
if (area.GetParent() is Nodule nodule)
|
|
||||||
{
|
|
||||||
ConnectionRemoved?.Invoke(nodule);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,38 +1,63 @@
|
|||||||
using Godot;
|
using Godot;
|
||||||
using Slimepire.Gameplay.Nodules.Components;
|
using Slimepire.Gameplay.Components;
|
||||||
|
|
||||||
namespace Slimepire.Gameplay.Nodules;
|
namespace Slimepire.Gameplay.Nodules;
|
||||||
|
|
||||||
[SceneTree]
|
|
||||||
public partial class Nodule : Node2D
|
public partial class Nodule : Node2D
|
||||||
{
|
{
|
||||||
public long Id { get; set; } = BitConverter.ToInt64(Guid.NewGuid().ToByteArray(), 0);
|
[Export]
|
||||||
|
private TubeConnectionArea _tubeConnectionArea = null!;
|
||||||
|
|
||||||
|
[Export]
|
||||||
|
private AnimatedSprite2D _gfx = null!;
|
||||||
|
|
||||||
|
[Export]
|
||||||
|
private Label _energyLabel = null!;
|
||||||
|
|
||||||
public List<Nodule> Connections { get; } = [];
|
public List<Nodule> Connections { get; } = [];
|
||||||
|
|
||||||
[Export]
|
protected AnimatedSprite2D Gfx => _gfx;
|
||||||
private TubeConnectionArea _tubeConnectionArea;
|
|
||||||
|
public long NoduleId => (long)GetInstanceId();
|
||||||
|
|
||||||
|
public void AttachTube(Tube tube)
|
||||||
|
{
|
||||||
|
AddChild(tube);
|
||||||
|
}
|
||||||
|
|
||||||
public override void _Ready()
|
public override void _Ready()
|
||||||
{
|
{
|
||||||
Gfx.SelfModulate = Colors.DarkOliveGreen;
|
_tubeConnectionArea.AreaEntered += OnAreaEntered;
|
||||||
Gfx.Play();
|
_tubeConnectionArea.AreaExited += OnAreaExited;
|
||||||
|
|
||||||
_tubeConnectionArea.ConnectionAdded += ConnectionAdded;
|
|
||||||
_tubeConnectionArea.ConnectionRemoved += ConnectionRemoved;
|
|
||||||
|
|
||||||
|
ApplyCustomizations();
|
||||||
NoduleManager.Instance.RegisterNodule(this);
|
NoduleManager.Instance.RegisterNodule(this);
|
||||||
|
|
||||||
|
// render above tubes
|
||||||
|
ZIndex = 1;
|
||||||
|
_gfx.Play();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void ConnectionAdded(Nodule nodule)
|
private void OnAreaEntered(Area2D area)
|
||||||
|
{
|
||||||
|
if (area.GetParent() is Nodule nodule)
|
||||||
{
|
{
|
||||||
Connections.Add(nodule);
|
Connections.Add(nodule);
|
||||||
NoduleManager.Instance.Update();
|
NoduleManager.Instance.Update();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private void ConnectionRemoved(Nodule nodule)
|
private void OnAreaExited(Area2D area)
|
||||||
|
{
|
||||||
|
if (area.GetParent() is Nodule nodule)
|
||||||
{
|
{
|
||||||
Connections.Remove(nodule);
|
Connections.Remove(nodule);
|
||||||
NoduleManager.Instance.Update();
|
NoduleManager.Instance.Update();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected virtual void ApplyCustomizations()
|
||||||
|
{
|
||||||
|
_gfx.SelfModulate = Colors.DarkOliveGreen;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
@@ -1 +1 @@
|
|||||||
uid://cmpl0if164dba
|
uid://ycm0pzamtclm
|
||||||
|
|||||||
11
src/Gameplay/Nodules/RootNodule/RootNodule.cs
Normal file
11
src/Gameplay/Nodules/RootNodule/RootNodule.cs
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
using Godot;
|
||||||
|
using Slimepire.Gameplay.Nodules;
|
||||||
|
|
||||||
|
[SceneTree]
|
||||||
|
public partial class RootNodule : Nodule
|
||||||
|
{
|
||||||
|
protected override void ApplyCustomizations()
|
||||||
|
{
|
||||||
|
Gfx.Modulate = Colors.Coral;
|
||||||
|
}
|
||||||
|
}
|
||||||
1
src/Gameplay/Nodules/RootNodule/RootNodule.cs.uid
Normal file
1
src/Gameplay/Nodules/RootNodule/RootNodule.cs.uid
Normal file
@@ -0,0 +1 @@
|
|||||||
|
uid://y4cpi50hsaj4
|
||||||
62
src/Gameplay/Nodules/RootNodule/RootNodule.tscn
Normal file
62
src/Gameplay/Nodules/RootNodule/RootNodule.tscn
Normal file
@@ -0,0 +1,62 @@
|
|||||||
|
[gd_scene format=3 uid="uid://j15868gtem0y"]
|
||||||
|
|
||||||
|
[ext_resource type="PackedScene" uid="uid://bjesfu1mfx8l5" path="res://src/Gameplay/Components/TubeConnectionArea.tscn" id="1_b03xe"]
|
||||||
|
[ext_resource type="Script" uid="uid://y4cpi50hsaj4" path="res://src/Gameplay/Nodules/RootNodule/RootNodule.cs" id="1_root"]
|
||||||
|
[ext_resource type="PackedScene" uid="uid://3x5pqm4t5cbl" path="res://src/Gameplay/Components/GrowArea.tscn" id="2_tg6hi"]
|
||||||
|
[ext_resource type="Texture2D" uid="uid://tomd3kojw0qy" path="res://assets/root_nodule.png" id="3_b03xe"]
|
||||||
|
|
||||||
|
[sub_resource type="CircleShape2D" id="CircleShape2D_t72h2"]
|
||||||
|
radius = 27.018513
|
||||||
|
|
||||||
|
[sub_resource type="SpriteFrames" id="SpriteFrames_cy5pc"]
|
||||||
|
animations = [{
|
||||||
|
"frames": [{
|
||||||
|
"duration": 1.0,
|
||||||
|
"texture": ExtResource("3_b03xe")
|
||||||
|
}],
|
||||||
|
"loop": 1,
|
||||||
|
"name": &"default",
|
||||||
|
"speed": 2.0
|
||||||
|
}]
|
||||||
|
|
||||||
|
[sub_resource type="LabelSettings" id="LabelSettings_cdcnu"]
|
||||||
|
font_size = 12
|
||||||
|
outline_size = 3
|
||||||
|
outline_color = Color(0, 0, 0, 1)
|
||||||
|
shadow_size = 3
|
||||||
|
shadow_color = Color(0, 0, 0, 1)
|
||||||
|
|
||||||
|
[node name="RootNodule" type="Node2D" unique_id=1797926942 node_paths=PackedStringArray("_tubeConnectionArea", "_gfx", "_energyLabel")]
|
||||||
|
z_index = 1
|
||||||
|
script = ExtResource("1_root")
|
||||||
|
_tubeConnectionArea = NodePath("TubeConnectionArea")
|
||||||
|
_gfx = NodePath("Gfx")
|
||||||
|
_energyLabel = NodePath("EnergyLabel")
|
||||||
|
|
||||||
|
[node name="TubeConnectionArea" parent="." unique_id=1821668398 instance=ExtResource("1_b03xe")]
|
||||||
|
|
||||||
|
[node name="GrowArea" parent="." unique_id=979341496 instance=ExtResource("2_tg6hi")]
|
||||||
|
|
||||||
|
[node name="CollisionShape2D" type="CollisionShape2D" parent="GrowArea" unique_id=1962902431]
|
||||||
|
shape = SubResource("CircleShape2D_t72h2")
|
||||||
|
|
||||||
|
[node name="Gfx" type="AnimatedSprite2D" parent="." unique_id=705500036]
|
||||||
|
unique_name_in_owner = true
|
||||||
|
texture_filter = 1
|
||||||
|
sprite_frames = SubResource("SpriteFrames_cy5pc")
|
||||||
|
autoplay = "default"
|
||||||
|
|
||||||
|
[node name="EnergyLabel" type="Label" parent="." unique_id=1654733583]
|
||||||
|
unique_name_in_owner = true
|
||||||
|
anchors_preset = 5
|
||||||
|
anchor_left = 0.5
|
||||||
|
anchor_right = 0.5
|
||||||
|
offset_left = -20.0
|
||||||
|
offset_top = 14.0
|
||||||
|
offset_right = 20.0
|
||||||
|
offset_bottom = 31.0
|
||||||
|
grow_horizontal = 2
|
||||||
|
text = "5"
|
||||||
|
label_settings = SubResource("LabelSettings_cdcnu")
|
||||||
|
horizontal_alignment = 1
|
||||||
|
vertical_alignment = 1
|
||||||
@@ -14,13 +14,13 @@ public partial class Tube : Node2D
|
|||||||
float maxLength = 180;
|
float maxLength = 180;
|
||||||
|
|
||||||
// Generate 5 points from origin to Target
|
// Generate 5 points from origin to Target
|
||||||
var diff = Target.Position - Position;
|
var diff = Target.Position;
|
||||||
|
|
||||||
var points = new Vector2[5];
|
var points = new Vector2[5];
|
||||||
points[0] = Position;
|
points[0] = Vector2.Zero;
|
||||||
for (var i = 1; i < 4; i++)
|
for (var i = 1; i < 4; i++)
|
||||||
{
|
{
|
||||||
points[i] = points[i - 1] + diff / 5;
|
points[i] = diff * i / 5;
|
||||||
}
|
}
|
||||||
points[4] = Target.Position;
|
points[4] = Target.Position;
|
||||||
|
|
||||||
|
|||||||
@@ -3,7 +3,7 @@
|
|||||||
[ext_resource type="Script" uid="uid://dwunaa303epy6" path="res://src/Gameplay/Tube.cs" id="1_76hpl"]
|
[ext_resource type="Script" uid="uid://dwunaa303epy6" path="res://src/Gameplay/Tube.cs" id="1_76hpl"]
|
||||||
|
|
||||||
[sub_resource type="Curve" id="Curve_kvwlm"]
|
[sub_resource type="Curve" id="Curve_kvwlm"]
|
||||||
_data = [Vector2(0, 1), 0.0, 0.0, 0, 0, Vector2(0.5, 0), 0.0, 0.0, 0, 0, Vector2(1, 1), 0.0, 0.0, 0, 0]
|
_data = [Vector2(0, 1), 0.0, 0.0, 0, 0, Vector2(0.5, 0.9453219), 0.0, 0.0, 0, 0, Vector2(1, 1), 0.0, 0.0, 0, 0]
|
||||||
point_count = 3
|
point_count = 3
|
||||||
|
|
||||||
[node name="Tube" type="Node2D" unique_id=226677696]
|
[node name="Tube" type="Node2D" unique_id=226677696]
|
||||||
@@ -12,7 +12,7 @@ script = ExtResource("1_76hpl")
|
|||||||
[node name="Line2D" type="Line2D" parent="." unique_id=1553055261]
|
[node name="Line2D" type="Line2D" parent="." unique_id=1553055261]
|
||||||
unique_name_in_owner = true
|
unique_name_in_owner = true
|
||||||
z_as_relative = false
|
z_as_relative = false
|
||||||
points = PackedVector2Array(0, 0, 32.6, 17, 65.2, 34, 97.799995, 51, 163, 85)
|
points = PackedVector2Array(0, 0, 5.4, 18.2, 10.8, 36.4, 16.2, 54.6, 27, 91)
|
||||||
width = 8.0
|
width = 8.0
|
||||||
width_curve = SubResource("Curve_kvwlm")
|
width_curve = SubResource("Curve_kvwlm")
|
||||||
default_color = Color(0.30588236, 0.4862745, 0.23921569, 1)
|
default_color = Color(0.30588236, 0.4862745, 0.23921569, 1)
|
||||||
@@ -22,4 +22,4 @@ end_cap_mode = 2
|
|||||||
|
|
||||||
[node name="Target" type="Marker2D" parent="." unique_id=630564540]
|
[node name="Target" type="Marker2D" parent="." unique_id=630564540]
|
||||||
unique_name_in_owner = true
|
unique_name_in_owner = true
|
||||||
position = Vector2(163, 85)
|
position = Vector2(27, 91)
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
[ext_resource type="Script" uid="uid://c8l12dlpexosv" path="res://src/Levels/DemoLevel.cs" id="1_l2cn0"]
|
[ext_resource type="Script" uid="uid://c8l12dlpexosv" path="res://src/Levels/DemoLevel.cs" id="1_l2cn0"]
|
||||||
[ext_resource type="Script" uid="uid://cdgi3y0sm3rt1" path="res://src/Gameplay/Camera.cs" id="2_mxa1b"]
|
[ext_resource type="Script" uid="uid://cdgi3y0sm3rt1" path="res://src/Gameplay/Camera.cs" id="2_mxa1b"]
|
||||||
[ext_resource type="PackedScene" uid="uid://cnl6t8o4mh0j3" path="res://src/Gameplay/Nodules/Nodule.tscn" id="3_qhkhc"]
|
[ext_resource type="PackedScene" uid="uid://j15868gtem0y" path="res://src/Gameplay/Nodules/RootNodule/RootNodule.tscn" id="3_knlma"]
|
||||||
|
|
||||||
[sub_resource type="LabelSettings" id="LabelSettings_l2cn0"]
|
[sub_resource type="LabelSettings" id="LabelSettings_l2cn0"]
|
||||||
font_size = 107
|
font_size = 107
|
||||||
@@ -28,4 +28,4 @@ grow_vertical = 2
|
|||||||
text = "DEMO LEVEL"
|
text = "DEMO LEVEL"
|
||||||
label_settings = SubResource("LabelSettings_l2cn0")
|
label_settings = SubResource("LabelSettings_l2cn0")
|
||||||
|
|
||||||
[node name="Nodule" parent="." unique_id=1637542829 instance=ExtResource("3_qhkhc")]
|
[node name="RootNodule" parent="." unique_id=1797926942 instance=ExtResource("3_knlma")]
|
||||||
|
|||||||
Reference in New Issue
Block a user