Nodule refactor
This commit is contained in:
@@ -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>
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ namespace Slimepire.Data;
|
|||||||
public partial class NoduleStats : Resource
|
public partial class NoduleStats : Resource
|
||||||
{
|
{
|
||||||
[Export]
|
[Export]
|
||||||
public SpriteFrames SpriteFrames;
|
public SpriteFrames SpriteFrames = null!;
|
||||||
|
|
||||||
[Export]
|
[Export]
|
||||||
public Color Color;
|
public Color Color;
|
||||||
|
|||||||
@@ -1,13 +1,16 @@
|
|||||||
using Godot;
|
using Godot;
|
||||||
using Slimepire.Gameplay.Components;
|
using Slimepire.Gameplay.Components;
|
||||||
using Nodule = Slimepire.Gameplay.Nodules.BasicNodule.Nodule;
|
using Slimepire.Gameplay.Nodules;
|
||||||
|
|
||||||
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,32 +18,37 @@ public partial class BuildGhost : Node2D
|
|||||||
|
|
||||||
public override void _Ready()
|
public override void _Ready()
|
||||||
{
|
{
|
||||||
// fix: after refactor
|
_tubeConnectionArea.AreaEntered += OnAreaEntered;
|
||||||
// _tubeConnectionArea.ConnectionAdded += ConnectionAdded;
|
_tubeConnectionArea.AreaExited += OnAreaExited;
|
||||||
// _tubeConnectionArea.ConnectionRemoved += ConnectionRemoved;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void ConnectionAdded(Nodule nodule)
|
private void OnAreaEntered(Area2D area)
|
||||||
{
|
{
|
||||||
CreateGhostTube(nodule, nodule.GlobalPosition);
|
if (area.GetParent() is Nodule nodule)
|
||||||
ConnectTubePlayer.Play();
|
{
|
||||||
|
CreateGhostTube(nodule, nodule.GlobalPosition);
|
||||||
|
ConnectTubePlayer.Play();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void ConnectionRemoved(Nodule nodule)
|
private void OnAreaExited(Area2D area)
|
||||||
{
|
{
|
||||||
var tube = _connectedTubes.GetValueOrDefault(nodule);
|
if (area.GetParent() is Nodule nodule)
|
||||||
if (tube == null)
|
{
|
||||||
return;
|
var tube = _connectedTubes.GetValueOrDefault(nodule);
|
||||||
|
if (tube == null)
|
||||||
|
return;
|
||||||
|
|
||||||
_connectedTubes.Remove(nodule);
|
_connectedTubes.Remove(nodule);
|
||||||
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);
|
||||||
}
|
}
|
||||||
@@ -77,12 +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;
|
||||||
|
|
||||||
GetParent()?.AddChild(nodule);
|
GetParent()?.AddChild(nodule);
|
||||||
|
|
||||||
CleanupBuildMode();
|
CleanupBuildMode();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,34 +1,8 @@
|
|||||||
using Godot;
|
using Godot;
|
||||||
using Slimepire.Gameplay.Nodules.BasicNodule;
|
|
||||||
|
|
||||||
namespace Slimepire.Gameplay.Components;
|
namespace Slimepire.Gameplay.Components;
|
||||||
|
|
||||||
[SceneTree]
|
[GlobalClass]
|
||||||
public partial class TubeConnectionArea : Area2D
|
public partial class TubeConnectionArea : Area2D
|
||||||
{
|
{
|
||||||
public List<INodule> Connections { get; } = [];
|
|
||||||
|
|
||||||
public override void _Ready()
|
|
||||||
{
|
|
||||||
AreaEntered += TubeConnectionAreaOnAreaEntered;
|
|
||||||
AreaExited += TubeConnectionAreaOnAreaExited;
|
|
||||||
}
|
|
||||||
|
|
||||||
private void TubeConnectionAreaOnAreaEntered(Area2D area)
|
|
||||||
{
|
|
||||||
if (area.GetParent() is INodule nodule)
|
|
||||||
{
|
|
||||||
Connections.Add(nodule);
|
|
||||||
NoduleManager.Instance.Update();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void TubeConnectionAreaOnAreaExited(Area2D area)
|
|
||||||
{
|
|
||||||
if (area.GetParent() is INodule nodule)
|
|
||||||
{
|
|
||||||
Connections.Remove(nodule);
|
|
||||||
NoduleManager.Instance.Update();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
using Godot;
|
using Godot;
|
||||||
using Slimepire.Gameplay.Nodules.BasicNodule;
|
using Slimepire.Gameplay.Nodules;
|
||||||
|
|
||||||
namespace Slimepire.Gameplay;
|
namespace Slimepire.Gameplay;
|
||||||
|
|
||||||
@@ -9,16 +9,16 @@ public partial class NoduleManager
|
|||||||
public bool Building { get; set; }
|
public bool Building { get; set; }
|
||||||
|
|
||||||
private AStar2D _aStar = new();
|
private AStar2D _aStar = new();
|
||||||
private readonly Dictionary<INodule, Node2D> _nodules = [];
|
private readonly Dictionary<long, Nodule> _nodules = [];
|
||||||
private readonly HashSet<NoduleConnection> _connections = [];
|
private readonly HashSet<NoduleConnection> _connections = [];
|
||||||
|
|
||||||
// GFX
|
// GFX
|
||||||
private readonly Dictionary<NoduleConnection, Tube> _tubeConnections = new();
|
private readonly Dictionary<NoduleConnection, Tube> _tubeConnections = new();
|
||||||
|
|
||||||
public void RegisterNodule(INodule nodule, Node2D node)
|
public void RegisterNodule(Nodule nodule)
|
||||||
{
|
{
|
||||||
_nodules.Add(nodule, node);
|
_nodules.Add(nodule.NoduleId, nodule);
|
||||||
_aStar.AddPoint(nodule.GetId(), node.Position);
|
_aStar.AddPoint(nodule.NoduleId, nodule.Position);
|
||||||
|
|
||||||
UpdateNoduleConnections();
|
UpdateNoduleConnections();
|
||||||
UpdateTubesAndAstar();
|
UpdateTubesAndAstar();
|
||||||
@@ -32,41 +32,38 @@ public partial class NoduleManager
|
|||||||
|
|
||||||
private void UpdateNoduleConnections()
|
private void UpdateNoduleConnections()
|
||||||
{
|
{
|
||||||
foreach (var (inodule, _) in _nodules)
|
foreach (var nodule in _nodules.Values)
|
||||||
{
|
{
|
||||||
foreach (var c in inodule.TubeConnectionArea.Connections)
|
foreach (var connected in nodule.Connections)
|
||||||
{
|
{
|
||||||
_connections.Add(new NoduleConnection(inodule, 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);
|
||||||
|
|
||||||
// TODO: Alles sehr ugly ...
|
conn.A.AddChild(tube);
|
||||||
tube.SetTarget(_nodules[c.B].Position);
|
tube.SetTarget(conn.B.GlobalPosition);
|
||||||
|
|
||||||
c.A.AttachTube(tube);
|
_aStar.ConnectPoints(conn.A.NoduleId, conn.B.NoduleId);
|
||||||
|
|
||||||
// TODO: refactor this out of gfx stuff
|
|
||||||
_aStar.ConnectPoints(c.A.GetId(), c.B.GetId());
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private record NoduleConnection
|
private record NoduleConnection
|
||||||
{
|
{
|
||||||
public INodule A { get; init; }
|
public Nodule A { get; init; }
|
||||||
public INodule B { get; init; }
|
public Nodule B { get; init; }
|
||||||
|
|
||||||
public NoduleConnection(INodule a, INodule b)
|
public NoduleConnection(Nodule a, Nodule b)
|
||||||
{
|
{
|
||||||
if (a.GetHashCode() <= b.GetHashCode())
|
if (a.GetHashCode() <= b.GetHashCode())
|
||||||
{
|
{
|
||||||
|
|||||||
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,23 +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/BasicNodule/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/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/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"]
|
[sub_resource type="CircleShape2D" id="CircleShape2D_t72h2"]
|
||||||
radius = 17.029387
|
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"]
|
||||||
@@ -44,14 +44,16 @@ 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]
|
[node name="CollisionShape2D" type="CollisionShape2D" parent="GrowArea" unique_id=282097141]
|
||||||
shape = SubResource("CircleShape2D_t72h2")
|
shape = SubResource("CircleShape2D_t72h2")
|
||||||
@@ -1,12 +0,0 @@
|
|||||||
using Slimepire.Gameplay.Components;
|
|
||||||
|
|
||||||
namespace Slimepire.Gameplay.Nodules.BasicNodule;
|
|
||||||
|
|
||||||
public interface INodule
|
|
||||||
{
|
|
||||||
TubeConnectionArea TubeConnectionArea { get; }
|
|
||||||
|
|
||||||
void AttachTube(Tube tube);
|
|
||||||
|
|
||||||
long GetId();
|
|
||||||
}
|
|
||||||
@@ -1 +0,0 @@
|
|||||||
uid://cy683somg41jj
|
|
||||||
@@ -1,33 +0,0 @@
|
|||||||
using Godot;
|
|
||||||
using Slimepire.Gameplay.Components;
|
|
||||||
|
|
||||||
namespace Slimepire.Gameplay.Nodules.BasicNodule;
|
|
||||||
|
|
||||||
[SceneTree]
|
|
||||||
public partial class Nodule : Node2D, INodule
|
|
||||||
{
|
|
||||||
[Export]
|
|
||||||
private TubeConnectionArea _tubeConnectionArea;
|
|
||||||
|
|
||||||
public TubeConnectionArea TubeConnectionArea => _tubeConnectionArea;
|
|
||||||
|
|
||||||
public void AttachTube(Tube tube)
|
|
||||||
{
|
|
||||||
AddChild(tube);
|
|
||||||
}
|
|
||||||
|
|
||||||
public long GetId()
|
|
||||||
{
|
|
||||||
return (long)GetInstanceId();
|
|
||||||
}
|
|
||||||
|
|
||||||
public override void _Ready()
|
|
||||||
{
|
|
||||||
Gfx.Play();
|
|
||||||
|
|
||||||
Gfx.SelfModulate = Colors.DarkOliveGreen;
|
|
||||||
|
|
||||||
// TODO: uiuiuiui
|
|
||||||
NoduleManager.Instance.RegisterNodule(this, this);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1 +0,0 @@
|
|||||||
uid://cmpl0if164dba
|
|
||||||
63
src/Gameplay/Nodules/Nodule.cs
Normal file
63
src/Gameplay/Nodules/Nodule.cs
Normal file
@@ -0,0 +1,63 @@
|
|||||||
|
using Godot;
|
||||||
|
using Slimepire.Gameplay.Components;
|
||||||
|
|
||||||
|
namespace Slimepire.Gameplay.Nodules;
|
||||||
|
|
||||||
|
public partial class Nodule : Node2D
|
||||||
|
{
|
||||||
|
[Export]
|
||||||
|
private TubeConnectionArea _tubeConnectionArea = null!;
|
||||||
|
|
||||||
|
[Export]
|
||||||
|
private AnimatedSprite2D _gfx = null!;
|
||||||
|
|
||||||
|
[Export]
|
||||||
|
private Label _energyLabel = null!;
|
||||||
|
|
||||||
|
public List<Nodule> Connections { get; } = [];
|
||||||
|
|
||||||
|
protected AnimatedSprite2D Gfx => _gfx;
|
||||||
|
|
||||||
|
public long NoduleId => (long)GetInstanceId();
|
||||||
|
|
||||||
|
public void AttachTube(Tube tube)
|
||||||
|
{
|
||||||
|
AddChild(tube);
|
||||||
|
}
|
||||||
|
|
||||||
|
public override void _Ready()
|
||||||
|
{
|
||||||
|
_tubeConnectionArea.AreaEntered += OnAreaEntered;
|
||||||
|
_tubeConnectionArea.AreaExited += OnAreaExited;
|
||||||
|
|
||||||
|
ApplyCustomizations();
|
||||||
|
NoduleManager.Instance.RegisterNodule(this);
|
||||||
|
|
||||||
|
// render above tubes
|
||||||
|
ZIndex = 1;
|
||||||
|
_gfx.Play();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void OnAreaEntered(Area2D area)
|
||||||
|
{
|
||||||
|
if (area.GetParent() is Nodule nodule)
|
||||||
|
{
|
||||||
|
Connections.Add(nodule);
|
||||||
|
NoduleManager.Instance.Update();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void OnAreaExited(Area2D area)
|
||||||
|
{
|
||||||
|
if (area.GetParent() is Nodule nodule)
|
||||||
|
{
|
||||||
|
Connections.Remove(nodule);
|
||||||
|
NoduleManager.Instance.Update();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
protected virtual void ApplyCustomizations()
|
||||||
|
{
|
||||||
|
_gfx.SelfModulate = Colors.DarkOliveGreen;
|
||||||
|
}
|
||||||
|
}
|
||||||
1
src/Gameplay/Nodules/Nodule.cs.uid
Normal file
1
src/Gameplay/Nodules/Nodule.cs.uid
Normal file
@@ -0,0 +1 @@
|
|||||||
|
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
|
||||||
@@ -1,6 +1,7 @@
|
|||||||
[gd_scene format=3 uid="uid://j15868gtem0y"]
|
[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="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="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"]
|
[ext_resource type="Texture2D" uid="uid://tomd3kojw0qy" path="res://assets/root_nodule.png" id="3_b03xe"]
|
||||||
|
|
||||||
@@ -25,7 +26,12 @@ 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="RootNodule" type="Node2D" unique_id=1797926942]
|
[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="TubeConnectionArea" parent="." unique_id=1821668398 instance=ExtResource("1_b03xe")]
|
||||||
|
|
||||||
|
|||||||
@@ -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/BasicNodule/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