switching up some more clicking
This commit is contained in:
+5
-5
@@ -18,18 +18,18 @@ public partial class HoverableNode : Node2D
|
|||||||
_bounds.MouseEntered += OnMouseEntered;
|
_bounds.MouseEntered += OnMouseEntered;
|
||||||
_bounds.MouseExited += OnMouseExited;
|
_bounds.MouseExited += OnMouseExited;
|
||||||
}
|
}
|
||||||
|
public override void _Process(double delta)
|
||||||
public override void _Input(InputEvent @event)
|
|
||||||
{
|
{
|
||||||
|
base._Process(delta);
|
||||||
if (_hovered)
|
if (_hovered)
|
||||||
{
|
{
|
||||||
if (Input.IsActionJustReleased("lmb"))
|
if (Input.IsActionJustPressed("leftClick"))
|
||||||
{
|
{
|
||||||
EmitSignal(SignalName.Click, this, 0);
|
EmitSignal(SignalName.Click, this, 0);
|
||||||
}
|
}
|
||||||
if (Input.IsActionJustReleased("rmb"))
|
if (Input.IsActionJustPressed("rightClick"))
|
||||||
{
|
{
|
||||||
EmitSignal(SignalName.Click, this, 1);
|
EmitSignal(SignalName.Click, this, 2);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,10 +7,6 @@ public partial class Peg : HoverableNode
|
|||||||
{
|
{
|
||||||
[Signal]
|
[Signal]
|
||||||
public delegate void DeathEventHandler(Peg THIS);
|
public delegate void DeathEventHandler(Peg THIS);
|
||||||
[Signal]
|
|
||||||
public delegate void ClickedEventHandler(Peg THIS);
|
|
||||||
[Signal]
|
|
||||||
public delegate void RightClickedEventHandler(Peg THIS);
|
|
||||||
public bool _track = false, _warp = false;
|
public bool _track = false, _warp = false;
|
||||||
public int _damage = 1, _health = 2, _stamina, _staminaRemaining, _visibilityRange = 4, _hitRange, _attackCost = 1;
|
public int _damage = 1, _health = 2, _stamina, _staminaRemaining, _visibilityRange = 4, _hitRange, _attackCost = 1;
|
||||||
public Dictionary<string, int> _priorities = new()
|
public Dictionary<string, int> _priorities = new()
|
||||||
@@ -29,21 +25,6 @@ public partial class Peg : HoverableNode
|
|||||||
base._Ready();
|
base._Ready();
|
||||||
_attack = GetNode<Sprite2D>("Attack");
|
_attack = GetNode<Sprite2D>("Attack");
|
||||||
}
|
}
|
||||||
public override void _Process(double delta)
|
|
||||||
{
|
|
||||||
base._Process(delta);
|
|
||||||
if (_hovered)
|
|
||||||
{
|
|
||||||
if (Input.IsActionJustPressed("leftClick"))
|
|
||||||
{
|
|
||||||
EmitSignal(SignalName.Clicked, this);
|
|
||||||
}
|
|
||||||
if (Input.IsActionJustPressed("rightClick"))
|
|
||||||
{
|
|
||||||
EmitSignal(SignalName.RightClicked, this);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
public void Attack()
|
public void Attack()
|
||||||
{
|
{
|
||||||
// _attack.Visible = true;
|
// _attack.Visible = true;
|
||||||
|
|||||||
+22
-18
@@ -20,8 +20,7 @@ public partial class PegController : TurnController
|
|||||||
{
|
{
|
||||||
HostilePeg newHostilePeg = _hostilePegScene.Instantiate<HostilePeg>();
|
HostilePeg newHostilePeg = _hostilePegScene.Instantiate<HostilePeg>();
|
||||||
newHostilePeg.Death += HandlePegRemoval;
|
newHostilePeg.Death += HandlePegRemoval;
|
||||||
newHostilePeg.Clicked += HandlePegClick;
|
newHostilePeg.Click += HandlePegClick;
|
||||||
newHostilePeg.RightClicked += HandlePegRightClick;
|
|
||||||
|
|
||||||
newHostilePeg._stamina = Globals._rng.Next(2,4+1);
|
newHostilePeg._stamina = Globals._rng.Next(2,4+1);
|
||||||
newHostilePeg.Modulate = new Color(newHostilePeg._stamina == 2 ? "#FF0000" : newHostilePeg._stamina == 3 ? "#00FF00" : "#0000FF");
|
newHostilePeg.Modulate = new Color(newHostilePeg._stamina == 2 ? "#FF0000" : newHostilePeg._stamina == 3 ? "#00FF00" : "#0000FF");
|
||||||
@@ -39,8 +38,7 @@ public partial class PegController : TurnController
|
|||||||
{
|
{
|
||||||
HostilePeg newHostilePeg = _hostilePegScene.Instantiate<HostilePeg>();
|
HostilePeg newHostilePeg = _hostilePegScene.Instantiate<HostilePeg>();
|
||||||
newHostilePeg.Death += HandlePegRemoval;
|
newHostilePeg.Death += HandlePegRemoval;
|
||||||
newHostilePeg.Clicked += HandlePegClick;
|
newHostilePeg.Click += HandlePegClick;
|
||||||
newHostilePeg.RightClicked += HandlePegRightClick;
|
|
||||||
|
|
||||||
newHostilePeg._stamina = Globals._rng.Next(2,4+1);
|
newHostilePeg._stamina = Globals._rng.Next(2,4+1);
|
||||||
newHostilePeg._hitRange = Globals._rng.Next(1,2+1);
|
newHostilePeg._hitRange = Globals._rng.Next(1,2+1);
|
||||||
@@ -95,25 +93,31 @@ public partial class PegController : TurnController
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public void HandlePegClick(Peg PEG)
|
public void HandlePegClick(Node CLICKED_NODE, int CLICK_TYPE)
|
||||||
{
|
{
|
||||||
if (PEG._staminaRemaining <= 0){
|
if (CLICKED_NODE is not Peg peg)
|
||||||
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
TileMapLayer pathLayer = _playArea.GetNode<TileMapLayer>("PathLayer");
|
if (CLICK_TYPE == 0)
|
||||||
List<Vector2I> newPath = PEG.GetBestPath();
|
|
||||||
|
|
||||||
|
|
||||||
pathLayer.GetUsedCells().ToList().ForEach(c => pathLayer.SetCell(c,0,Vector2I.Down*4));
|
|
||||||
for (int i = 0; i < newPath.Count; i++)
|
|
||||||
{
|
{
|
||||||
pathLayer.SetCell(newPath[i],0,Vector2I.One);
|
if (peg._staminaRemaining <= 0){
|
||||||
}
|
return;
|
||||||
}
|
}
|
||||||
|
TileMapLayer pathLayer = _playArea.GetNode<TileMapLayer>("PathLayer");
|
||||||
|
List<Vector2I> newPath = peg.GetBestPath();
|
||||||
|
|
||||||
public void HandlePegRightClick(Peg PEG)
|
|
||||||
{
|
pathLayer.GetUsedCells().ToList().ForEach(c => pathLayer.SetCell(c,0,Vector2I.Down*4));
|
||||||
HandlePegRemoval(PEG);
|
for (int i = 0; i < newPath.Count; i++)
|
||||||
|
{
|
||||||
|
pathLayer.SetCell(newPath[i],0,Vector2I.One);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (CLICK_TYPE == 2)
|
||||||
|
{
|
||||||
|
HandlePegRemoval(peg);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void HandlePegPathing(Peg PEG)
|
public void HandlePegPathing(Peg PEG)
|
||||||
|
|||||||
@@ -3,9 +3,9 @@ using System;
|
|||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Diagnostics;
|
using System.Diagnostics;
|
||||||
|
|
||||||
public partial class Tower : Sprite2D
|
public partial class Tower : HoverableNode
|
||||||
{
|
{
|
||||||
public bool _hovered, _aiming;
|
public bool _aiming;
|
||||||
public int _launchSpeed = 1000, _arcIterations = 50;
|
public int _launchSpeed = 1000, _arcIterations = 50;
|
||||||
public Vector2 _aimOffset, _arcEnd;
|
public Vector2 _aimOffset, _arcEnd;
|
||||||
public List<Vector2> _arc = new();
|
public List<Vector2> _arc = new();
|
||||||
@@ -16,9 +16,9 @@ public partial class Tower : Sprite2D
|
|||||||
{
|
{
|
||||||
base._Ready();
|
base._Ready();
|
||||||
|
|
||||||
_area = GetNode<Area2D>("Area");
|
|
||||||
_offset = GetNode<Marker2D>("Offset");
|
_offset = GetNode<Marker2D>("Offset");
|
||||||
_attackSpawn = GetNode<Marker2D>("AttackSpawn");
|
_attackSpawn = GetNode<Marker2D>("AttackSpawn");
|
||||||
|
// Click += HandleClick;
|
||||||
}
|
}
|
||||||
public override void _Process(double delta)
|
public override void _Process(double delta)
|
||||||
{
|
{
|
||||||
@@ -56,6 +56,7 @@ public partial class Tower : Sprite2D
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public float CalculateLaunchAngle(Vector2 START, Vector2 END, int MAX_ITERATIONS = 20)
|
public float CalculateLaunchAngle(Vector2 START, Vector2 END, int MAX_ITERATIONS = 20)
|
||||||
|
|||||||
+14
-6
@@ -1,8 +1,8 @@
|
|||||||
[gd_scene format=3 uid="uid://drt7w0eqp13tu"]
|
[gd_scene format=3 uid="uid://drt7w0eqp13tu"]
|
||||||
|
|
||||||
[ext_resource type="Script" uid="uid://dfba4vq6jv0a6" path="res://HostilePeg.cs" id="1_4gyqm"]
|
[ext_resource type="Script" uid="uid://dfba4vq6jv0a6" path="res://HostilePeg.cs" id="1_nc8fp"]
|
||||||
[ext_resource type="Texture2D" uid="uid://nwj4n7if8kqd" path="res://Art/circle25r.png" id="1_7k104"]
|
[ext_resource type="Texture2D" uid="uid://nwj4n7if8kqd" path="res://Art/circle25r.png" id="2_0icqg"]
|
||||||
[ext_resource type="Texture2D" uid="uid://m4wfj36twmqy" path="res://Art/attack.png" id="3_qi2p4"]
|
[ext_resource type="Texture2D" uid="uid://m4wfj36twmqy" path="res://Art/attack.png" id="3_en3ow"]
|
||||||
|
|
||||||
[sub_resource type="PhysicsMaterial" id="PhysicsMaterial_7k104"]
|
[sub_resource type="PhysicsMaterial" id="PhysicsMaterial_7k104"]
|
||||||
bounce = 0.5
|
bounce = 0.5
|
||||||
@@ -10,10 +10,13 @@ bounce = 0.5
|
|||||||
[sub_resource type="CircleShape2D" id="CircleShape2D_4gyqm"]
|
[sub_resource type="CircleShape2D" id="CircleShape2D_4gyqm"]
|
||||||
radius = 12.5
|
radius = 12.5
|
||||||
|
|
||||||
|
[sub_resource type="CircleShape2D" id="CircleShape2D_6w6fg"]
|
||||||
|
radius = 12.5
|
||||||
|
|
||||||
[node name="HostilePeg" type="StaticBody2D" unique_id=1417697759]
|
[node name="HostilePeg" type="StaticBody2D" unique_id=1417697759]
|
||||||
input_pickable = true
|
input_pickable = true
|
||||||
physics_material_override = SubResource("PhysicsMaterial_7k104")
|
physics_material_override = SubResource("PhysicsMaterial_7k104")
|
||||||
script = ExtResource("1_4gyqm")
|
script = ExtResource("1_nc8fp")
|
||||||
|
|
||||||
[node name="CollisionShape2D" type="CollisionShape2D" parent="." unique_id=1762191899]
|
[node name="CollisionShape2D" type="CollisionShape2D" parent="." unique_id=1762191899]
|
||||||
shape = SubResource("CircleShape2D_4gyqm")
|
shape = SubResource("CircleShape2D_4gyqm")
|
||||||
@@ -21,12 +24,17 @@ shape = SubResource("CircleShape2D_4gyqm")
|
|||||||
[node name="Sprite2D" type="Sprite2D" parent="." unique_id=1941012605]
|
[node name="Sprite2D" type="Sprite2D" parent="." unique_id=1941012605]
|
||||||
texture_filter = 1
|
texture_filter = 1
|
||||||
scale = Vector2(0.5, 0.5)
|
scale = Vector2(0.5, 0.5)
|
||||||
texture = ExtResource("1_7k104")
|
texture = ExtResource("2_0icqg")
|
||||||
|
|
||||||
[node name="Attack" type="Sprite2D" parent="." unique_id=1776738311]
|
[node name="Attack" type="Sprite2D" parent="." unique_id=1776738311]
|
||||||
visible = false
|
visible = false
|
||||||
texture_filter = 1
|
texture_filter = 1
|
||||||
texture = ExtResource("3_qi2p4")
|
texture = ExtResource("3_en3ow")
|
||||||
|
|
||||||
|
[node name="HoverBounds" type="Area2D" parent="." unique_id=937525982]
|
||||||
|
|
||||||
|
[node name="CollisionShape2D" type="CollisionShape2D" parent="HoverBounds" unique_id=2142666816]
|
||||||
|
shape = SubResource("CircleShape2D_6w6fg")
|
||||||
|
|
||||||
[connection signal="mouse_entered" from="." to="." method="OnMouseEntered"]
|
[connection signal="mouse_entered" from="." to="." method="OnMouseEntered"]
|
||||||
[connection signal="mouse_exited" from="." to="." method="OnMouseExited"]
|
[connection signal="mouse_exited" from="." to="." method="OnMouseExited"]
|
||||||
|
|||||||
+2
-2
@@ -5,6 +5,6 @@
|
|||||||
[node name="HoverableNode" type="Node2D" unique_id=946672764]
|
[node name="HoverableNode" type="Node2D" unique_id=946672764]
|
||||||
script = ExtResource("1_14v3m")
|
script = ExtResource("1_14v3m")
|
||||||
|
|
||||||
[node name="Bounds" type="Area2D" parent="." unique_id=783465962]
|
[node name="HoverBounds" type="Area2D" parent="." unique_id=783465962]
|
||||||
|
|
||||||
[node name="CollisionShape2D" type="CollisionShape2D" parent="Bounds" unique_id=585114419]
|
[node name="CollisionShape2D" type="CollisionShape2D" parent="HoverBounds" unique_id=585114419]
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ script = ExtResource("1_ig7tw")
|
|||||||
[node name="PlayArea" parent="." unique_id=1123610167 instance=ExtResource("2_1bvp3")]
|
[node name="PlayArea" parent="." unique_id=1123610167 instance=ExtResource("2_1bvp3")]
|
||||||
position = Vector2(360, 180)
|
position = Vector2(360, 180)
|
||||||
|
|
||||||
[node name="EnemyController" parent="." unique_id=1894449838 instance=ExtResource("4_1bvp3")]
|
[node name="PegController" parent="." unique_id=1894449838 instance=ExtResource("4_1bvp3")]
|
||||||
|
|
||||||
[node name="PlayerController" parent="." unique_id=364781168 instance=ExtResource("4_lquwl")]
|
[node name="PlayerController" parent="." unique_id=364781168 instance=ExtResource("4_lquwl")]
|
||||||
|
|
||||||
|
|||||||
@@ -28,5 +28,10 @@ visible = false
|
|||||||
texture_filter = 1
|
texture_filter = 1
|
||||||
texture = ExtResource("3_inmy4")
|
texture = ExtResource("3_inmy4")
|
||||||
|
|
||||||
|
[node name="HoverBounds" type="Area2D" parent="." unique_id=2086452813]
|
||||||
|
|
||||||
|
[node name="CollisionShape2D" type="CollisionShape2D" parent="HoverBounds" unique_id=252175102]
|
||||||
|
shape = SubResource("CircleShape2D_4gyqm")
|
||||||
|
|
||||||
[connection signal="mouse_entered" from="." to="." method="OnMouseEntered"]
|
[connection signal="mouse_entered" from="." to="." method="OnMouseEntered"]
|
||||||
[connection signal="mouse_exited" from="." to="." method="OnMouseExited"]
|
[connection signal="mouse_exited" from="." to="." method="OnMouseExited"]
|
||||||
|
|||||||
+4
-4
@@ -11,9 +11,9 @@ self_modulate = Color(0, 0, 0, 1)
|
|||||||
texture = ExtResource("1_vedim")
|
texture = ExtResource("1_vedim")
|
||||||
script = ExtResource("1_k1sas")
|
script = ExtResource("1_k1sas")
|
||||||
|
|
||||||
[node name="Area" type="Area2D" parent="." unique_id=620986087]
|
[node name="HoverBounds" type="Area2D" parent="." unique_id=620986087]
|
||||||
|
|
||||||
[node name="Bounds" type="CollisionShape2D" parent="Area" unique_id=1639875880]
|
[node name="CollisionShape2D" type="CollisionShape2D" parent="HoverBounds" unique_id=1639875880]
|
||||||
position = Vector2(0, 0.5)
|
position = Vector2(0, 0.5)
|
||||||
shape = SubResource("RectangleShape2D_vedim")
|
shape = SubResource("RectangleShape2D_vedim")
|
||||||
debug_color = Color(0.6411928, 0.52469516, 0, 0.41960785)
|
debug_color = Color(0.6411928, 0.52469516, 0, 0.41960785)
|
||||||
@@ -24,5 +24,5 @@ position = Vector2(25, -50)
|
|||||||
[node name="AttackSpawn" type="Marker2D" parent="." unique_id=715904909]
|
[node name="AttackSpawn" type="Marker2D" parent="." unique_id=715904909]
|
||||||
position = Vector2(0, -24)
|
position = Vector2(0, -24)
|
||||||
|
|
||||||
[connection signal="mouse_entered" from="Area" to="." method="OnMouseEntered"]
|
[connection signal="mouse_entered" from="HoverBounds" to="." method="OnMouseEntered"]
|
||||||
[connection signal="mouse_exited" from="Area" to="." method="OnMouseExited"]
|
[connection signal="mouse_exited" from="HoverBounds" to="." method="OnMouseExited"]
|
||||||
|
|||||||
Reference in New Issue
Block a user