altering enemies into peg to open up for the future with hostile and friendly pegs. made some changes to the pathfinding. starting to add a mouse handler that will more easily handle single and double clicks, and holds. Enemy controller becomes peg controller and will handle all peg interactions
This commit is contained in:
@@ -52,9 +52,9 @@ public partial class Attack : RigidBody2D
|
|||||||
public void TakeAction(Node BODY)
|
public void TakeAction(Node BODY)
|
||||||
{
|
{
|
||||||
EmitSignal(SignalName.Hit, BODY);
|
EmitSignal(SignalName.Hit, BODY);
|
||||||
if (BODY is Enemy enemy)
|
if (BODY is Peg peg)
|
||||||
{
|
{
|
||||||
enemy.TakeDamage(_damage, _commanderOwner);
|
peg.TakeDamage(_damage, _commanderOwner);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,213 +0,0 @@
|
|||||||
using Godot;
|
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Diagnostics;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
public partial class EnemyController : TurnController
|
|
||||||
{
|
|
||||||
public int _actionLoop = 0;
|
|
||||||
public PackedScene _enemyScene = GD.Load<PackedScene>("res://Enemy.tscn");
|
|
||||||
public List<Enemy> _enemies = new();
|
|
||||||
public PlayerController _playerController;
|
|
||||||
public Dictionary<int, List<Tween>> _tweenStages = new();
|
|
||||||
public Tween _tween;
|
|
||||||
|
|
||||||
public void AddEnemies(int ENEMY_COUNT = 1)
|
|
||||||
{
|
|
||||||
for (int i = 0; i < ENEMY_COUNT; i++)
|
|
||||||
{
|
|
||||||
Enemy newEnemy = _enemyScene.Instantiate<Enemy>();
|
|
||||||
newEnemy.Death += HandleEnemyRemoval;
|
|
||||||
newEnemy.Clicked += HandleEnemyClick;
|
|
||||||
newEnemy.RightClicked += HandleEnemyRightClick;
|
|
||||||
|
|
||||||
newEnemy._stamina = Globals._rng.Next(2,4+1);
|
|
||||||
newEnemy.Modulate = new Color(newEnemy._stamina == 2 ? "#FF0000" : newEnemy._stamina == 3 ? "#00FF00" : "#0000FF");
|
|
||||||
newEnemy._enemyController = this;
|
|
||||||
List<Vector2I> unoccupied = [.. _playArea._map._bottomRow.Where(c => _enemies.All(e => e._address != c))];
|
|
||||||
Vector2I randomCell = unoccupied[Globals._rng.Next(unoccupied.Count)];
|
|
||||||
SetEnemy(newEnemy, randomCell);
|
|
||||||
_enemies.Add(newEnemy);
|
|
||||||
AddChild(newEnemy);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
public void AddEnemies(List<Vector2I> POSITIONS)
|
|
||||||
{
|
|
||||||
for (int i = 0; i < POSITIONS.Count; i++)
|
|
||||||
{
|
|
||||||
Enemy newEnemy = _enemyScene.Instantiate<Enemy>();
|
|
||||||
newEnemy.Death += HandleEnemyRemoval;
|
|
||||||
newEnemy.Clicked += HandleEnemyClick;
|
|
||||||
newEnemy.RightClicked += HandleEnemyRightClick;
|
|
||||||
|
|
||||||
newEnemy._stamina = Globals._rng.Next(2,4+1);
|
|
||||||
newEnemy._hitRange = Globals._rng.Next(1,2+1);
|
|
||||||
newEnemy.GetNode<Sprite2D>("Sprite2D").SelfModulate = new Color(newEnemy._stamina == 2 ? "#FF0000" : newEnemy._stamina == 3 ? "#00FF00" : "#0000FF");
|
|
||||||
newEnemy._enemyController = this;
|
|
||||||
|
|
||||||
SetEnemy(newEnemy, POSITIONS[i]);
|
|
||||||
_enemies.Add(newEnemy);
|
|
||||||
AddChild(newEnemy);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
public List<Enemy> GetRemainingEnemies()
|
|
||||||
{
|
|
||||||
return [.. _enemies.Where(e => e.CanMove(this) || e.CanAttack(this))];
|
|
||||||
}
|
|
||||||
|
|
||||||
public void HandleEnemyActions()
|
|
||||||
{
|
|
||||||
_actionLoop = 0;
|
|
||||||
_tweenStages.Clear();
|
|
||||||
Map map = _playArea._map;
|
|
||||||
|
|
||||||
_enemies.ForEach(e => e._path.Clear());
|
|
||||||
|
|
||||||
List<Enemy> remainingEnemies = GetRemainingEnemies();
|
|
||||||
while (remainingEnemies.Count > 0)
|
|
||||||
{
|
|
||||||
for (int i = 0; i < remainingEnemies.Count; i++)
|
|
||||||
{
|
|
||||||
Enemy enemy = remainingEnemies[i];
|
|
||||||
if (!enemy.CanMove(this) && !enemy.CanAttack(this))
|
|
||||||
{
|
|
||||||
GD.Print(i);
|
|
||||||
}
|
|
||||||
HandleEnemyPathing(enemy);
|
|
||||||
HandleEnemyAttacking(enemy);
|
|
||||||
}
|
|
||||||
remainingEnemies = GetRemainingEnemies();
|
|
||||||
_actionLoop++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public void HandleEnemyAttacking(Enemy ENEMY)
|
|
||||||
{
|
|
||||||
if (!ENEMY.CanAttack(this))
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
ENEMY.Attack(this);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public void HandleEnemyClick(Enemy ENEMY)
|
|
||||||
{
|
|
||||||
if (ENEMY._staminaRemaining <= 0){
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
TileMapLayer pathLayer = _playArea.GetNode<TileMapLayer>("PathLayer");
|
|
||||||
List<Vector2I> newPath = ENEMY.GetBestPath(_playArea._map);
|
|
||||||
|
|
||||||
|
|
||||||
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);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public void HandleEnemyRightClick(Enemy ENEMY)
|
|
||||||
{
|
|
||||||
HandleEnemyRemoval(ENEMY);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void HandleEnemyPathing(Enemy ENEMY)
|
|
||||||
{
|
|
||||||
if (!ENEMY.CanMove(this))
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
List<Vector2I> path = ENEMY.GetBestPath(_playArea._map);
|
|
||||||
|
|
||||||
if (path.Count == 0)
|
|
||||||
{
|
|
||||||
// ENEMY.Move(ENEMY._path.LastOrDefault(ENEMY._address), this);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
ENEMY.Move(path[0], this);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void HandleEnemyRemoval(Enemy ENEMY_TO_REMOVE)
|
|
||||||
{
|
|
||||||
_enemies.Remove(ENEMY_TO_REMOVE);
|
|
||||||
_playArea._map.SetCellEnemy(ENEMY_TO_REMOVE._address, null);
|
|
||||||
ENEMY_TO_REMOVE.QueueFree();
|
|
||||||
}
|
|
||||||
|
|
||||||
public void HandleEnemySort()
|
|
||||||
{
|
|
||||||
_enemies = [.. _enemies.OrderBy(e => e._address.Y).ThenBy(e => e._path.Count).ThenBy(e => Math.Abs(e._address.X - _playArea._map._maxX / 2))];
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public void Initiate()
|
|
||||||
{
|
|
||||||
List<Vector2I> positions = [.. _playArea.GetNode<TileMapLayer>("InitialPositions").GetUsedCells()];
|
|
||||||
|
|
||||||
AddEnemies(positions);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void ProcessTween()
|
|
||||||
{
|
|
||||||
_tweenStages = _tweenStages.OrderBy(s => s.Key).ToDictionary();
|
|
||||||
GD.Print(string.Join(", ", _tweenStages.Keys));
|
|
||||||
if (_tweenStages.Count <= 0)
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (_tween != null)
|
|
||||||
{
|
|
||||||
_tween.Kill();
|
|
||||||
}
|
|
||||||
|
|
||||||
_tween = CreateTween();
|
|
||||||
|
|
||||||
for (int i = 0; i < _tweenStages.Count; i++)
|
|
||||||
{
|
|
||||||
_tween.Chain().TweenInterval(0.5f);
|
|
||||||
List<Tween> tweenSteps = _tweenStages.Values.ElementAt(i);
|
|
||||||
for (int j = 0; j < tweenSteps.Count; j++)
|
|
||||||
{
|
|
||||||
Tween step = tweenSteps[j];
|
|
||||||
_tween.Parallel().TweenSubtween(step);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
_tween.TweenCallback(Callable.From(EndTurn));
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
public override void StartTurn()
|
|
||||||
{
|
|
||||||
|
|
||||||
AddEnemies(1);
|
|
||||||
|
|
||||||
for (int i = 0; i < _enemies.Count; i++)
|
|
||||||
{
|
|
||||||
_enemies[i].StartTurn();
|
|
||||||
}
|
|
||||||
|
|
||||||
HandleEnemySort();
|
|
||||||
|
|
||||||
HandleEnemyActions();
|
|
||||||
|
|
||||||
ProcessTween();
|
|
||||||
}
|
|
||||||
|
|
||||||
public void SetEnemy(Enemy ENEMY, Vector2I CELL)
|
|
||||||
{
|
|
||||||
if (CELL == new Vector2I(16, 14))
|
|
||||||
{
|
|
||||||
ENEMY._track = true;
|
|
||||||
}
|
|
||||||
_playArea._map.SetCellEnemy(CELL, ENEMY);
|
|
||||||
ENEMY.GlobalPosition = _playArea._map.GetCellPositionFromAddress(CELL);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
+2
-1
@@ -1,9 +1,10 @@
|
|||||||
using Godot;
|
using Godot;
|
||||||
using System;
|
using System;
|
||||||
|
|
||||||
public partial class Globals : Node
|
public partial class Globals : Node2D
|
||||||
{
|
{
|
||||||
public static Random _rng = new();
|
public static Random _rng = new();
|
||||||
public static float _gravity = (float)ProjectSettings.GetSetting("physics/2d/default_gravity"), _drag = (float)ProjectSettings.GetSetting("physics/2d/default_linear_damp");
|
public static float _gravity = (float)ProjectSettings.GetSetting("physics/2d/default_gravity"), _drag = (float)ProjectSettings.GetSetting("physics/2d/default_linear_damp");
|
||||||
|
public static MouseHandler _mouse;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,21 @@
|
|||||||
|
using Godot;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
public partial class HostilePeg : Peg
|
||||||
|
{
|
||||||
|
|
||||||
|
public override void _Ready()
|
||||||
|
{
|
||||||
|
base._Ready();
|
||||||
|
}
|
||||||
|
|
||||||
|
// public void OnMouseEntered(){
|
||||||
|
// _hovered = true;
|
||||||
|
// }
|
||||||
|
// public void OnMouseExited(){
|
||||||
|
// _hovered = false;
|
||||||
|
// }
|
||||||
|
}
|
||||||
@@ -0,0 +1,48 @@
|
|||||||
|
using Godot;
|
||||||
|
using System;
|
||||||
|
|
||||||
|
public partial class HoverableNode : Node2D
|
||||||
|
{
|
||||||
|
[Signal]
|
||||||
|
public delegate void HoverEventHandler(HoverableNode THIS, bool IS_HOVERED);
|
||||||
|
[Signal]
|
||||||
|
public delegate void ClickEventHandler(HoverableNode THIS, int CLICK_TYPE);
|
||||||
|
|
||||||
|
public bool _hovered;
|
||||||
|
public Area2D _bounds;
|
||||||
|
|
||||||
|
public override void _Ready()
|
||||||
|
{
|
||||||
|
base._Ready();
|
||||||
|
_bounds = GetNode<Area2D>("HoverBounds");
|
||||||
|
_bounds.MouseEntered += OnMouseEntered;
|
||||||
|
_bounds.MouseExited += OnMouseExited;
|
||||||
|
}
|
||||||
|
|
||||||
|
public override void _Input(InputEvent @event)
|
||||||
|
{
|
||||||
|
if (_hovered)
|
||||||
|
{
|
||||||
|
if (Input.IsActionJustReleased("lmb"))
|
||||||
|
{
|
||||||
|
EmitSignal(SignalName.Click, this, 0);
|
||||||
|
}
|
||||||
|
if (Input.IsActionJustReleased("rmb"))
|
||||||
|
{
|
||||||
|
EmitSignal(SignalName.Click, this, 1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public virtual void OnMouseEntered()
|
||||||
|
{
|
||||||
|
_hovered = true;
|
||||||
|
EmitSignal(SignalName.Hover, this,_hovered);
|
||||||
|
}
|
||||||
|
|
||||||
|
public virtual void OnMouseExited()
|
||||||
|
{
|
||||||
|
_hovered = false;
|
||||||
|
EmitSignal(SignalName.Hover, this, _hovered);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
uid://dqvysa2n208d3
|
||||||
@@ -7,27 +7,28 @@ public partial class Main : Node
|
|||||||
{
|
{
|
||||||
public PlayArea _playArea;
|
public PlayArea _playArea;
|
||||||
public PlayerController _playerController;
|
public PlayerController _playerController;
|
||||||
public EnemyController _enemyController;
|
public PegController _pegController;
|
||||||
public TurnController _turnController;
|
public TurnController _turnController;
|
||||||
public Random _rng = new();
|
public Random _rng = new();
|
||||||
public override void _Ready()
|
public override void _Ready()
|
||||||
{
|
{
|
||||||
base._Ready();
|
base._Ready();
|
||||||
|
Globals._mouse = GetNode<MouseHandler>("MouseHandler");
|
||||||
_playArea = GetNode<PlayArea>("PlayArea");
|
_playArea = GetNode<PlayArea>("PlayArea");
|
||||||
_playerController = GetNode<PlayerController>("PlayerController");
|
_playerController = GetNode<PlayerController>("PlayerController");
|
||||||
_enemyController = GetNode<EnemyController>("EnemyController");
|
_pegController = GetNode<PegController>("PegController");
|
||||||
|
|
||||||
_playerController._enemyController = _enemyController;
|
_playerController._pegController = _pegController;
|
||||||
_enemyController._playerController = _playerController;
|
_pegController._playerController = _playerController;
|
||||||
|
|
||||||
_playerController._playArea = _playArea;
|
_playerController._playArea = _playArea;
|
||||||
_enemyController._playArea = _playArea;
|
_pegController._playArea = _playArea;
|
||||||
|
|
||||||
_playerController.TurnDone += ChangeTurn;
|
_playerController.TurnDone += ChangeTurn;
|
||||||
_playerController.Death += EndGame;
|
_playerController.Death += EndGame;
|
||||||
_enemyController.TurnDone += ChangeTurn;
|
_pegController.TurnDone += ChangeTurn;
|
||||||
|
|
||||||
_enemyController.Initiate();
|
_pegController.Initiate();
|
||||||
_playerController.SetUpTowers();
|
_playerController.SetUpTowers();
|
||||||
ChangeTurn();
|
ChangeTurn();
|
||||||
}
|
}
|
||||||
@@ -50,7 +51,7 @@ public partial class Main : Node
|
|||||||
|
|
||||||
public void ChangeTurn()
|
public void ChangeTurn()
|
||||||
{
|
{
|
||||||
_turnController = _turnController == _playerController ? _enemyController : _playerController;
|
_turnController = _turnController == _playerController ? _pegController : _playerController;
|
||||||
_turnController.StartTurn();
|
_turnController.StartTurn();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ public partial class Map : TileMapLayer
|
|||||||
public Vector2I _pathTakenAtlasCoordinates = new Vector2I(4, 0);
|
public Vector2I _pathTakenAtlasCoordinates = new Vector2I(4, 0);
|
||||||
public List<Vector2I> _cells = new(), _leftmostColumn = new(), _rightmostColumn = new(), _topRow = new(), _bottomRow = new();
|
public List<Vector2I> _cells = new(), _leftmostColumn = new(), _rightmostColumn = new(), _topRow = new(), _bottomRow = new();
|
||||||
public AStarGrid2D _astar = new();
|
public AStarGrid2D _astar = new();
|
||||||
public Dictionary<Vector2I, Enemy> _addressOccupants = new();
|
public Dictionary<Vector2I, Peg> _addressOccupants = new();
|
||||||
public int _firstOpenRow
|
public int _firstOpenRow
|
||||||
{
|
{
|
||||||
get
|
get
|
||||||
@@ -64,7 +64,7 @@ public partial class Map : TileMapLayer
|
|||||||
return GlobalPosition + CELL_ADDRESS * _cellSize + _cellSize / 2;
|
return GlobalPosition + CELL_ADDRESS * _cellSize + _cellSize / 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Enemy GetOccupant(Vector2I CELL_TO_CHECK)
|
public Peg GetOccupant(Vector2I CELL_TO_CHECK)
|
||||||
{
|
{
|
||||||
return _addressOccupants[CELL_TO_CHECK];
|
return _addressOccupants[CELL_TO_CHECK];
|
||||||
}
|
}
|
||||||
@@ -90,20 +90,20 @@ public partial class Map : TileMapLayer
|
|||||||
return rowCells.All(c => _astar.IsPointSolid(c));
|
return rowCells.All(c => _astar.IsPointSolid(c));
|
||||||
}
|
}
|
||||||
|
|
||||||
public void SetCellEnemy(Vector2I ADDRESS, Enemy ENEMY)
|
public void SetCellPeg(Vector2I ADDRESS, Peg PEG)
|
||||||
{
|
{
|
||||||
if (ENEMY != null)
|
if (PEG != null)
|
||||||
{
|
{
|
||||||
if (ENEMY._address != -Vector2I.One)
|
if (PEG._address != -Vector2I.One)
|
||||||
{
|
{
|
||||||
_addressOccupants[ENEMY._address] = null;
|
_addressOccupants[PEG._address] = null;
|
||||||
SetCellSolid(ENEMY._address);
|
SetCellSolid(PEG._address);
|
||||||
}
|
}
|
||||||
ENEMY._address = ADDRESS;
|
PEG._address = ADDRESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
_addressOccupants[ADDRESS] = ENEMY;
|
_addressOccupants[ADDRESS] = PEG;
|
||||||
SetCellSolid(ADDRESS);
|
SetCellSolid(ADDRESS);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,18 @@
|
|||||||
|
using Godot;
|
||||||
|
using System;
|
||||||
|
|
||||||
|
public partial class MouseHandler : Node
|
||||||
|
{
|
||||||
|
public enum ClickType
|
||||||
|
{
|
||||||
|
LEFT_CLICK,
|
||||||
|
MIDDLE_CLICK,
|
||||||
|
RIGHT_CLICK,
|
||||||
|
LEFT_HOLD,
|
||||||
|
MIDDLE_HOLD,
|
||||||
|
RIGHT_HOLD,
|
||||||
|
LEFT_DOUBLE,
|
||||||
|
MIDDLE_DOUBLE,
|
||||||
|
RIGHT_DOUBLE
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
uid://dewxuppyw2gtp
|
||||||
+43
-45
@@ -2,17 +2,16 @@ using Godot;
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
public partial class Enemy : StaticBody2D
|
public partial class Peg : HoverableNode
|
||||||
{
|
{
|
||||||
[Signal]
|
[Signal]
|
||||||
public delegate void DeathEventHandler(Enemy THIS);
|
public delegate void DeathEventHandler(Peg THIS);
|
||||||
[Signal]
|
[Signal]
|
||||||
public delegate void ClickedEventHandler(Enemy THIS);
|
public delegate void ClickedEventHandler(Peg THIS);
|
||||||
[Signal]
|
[Signal]
|
||||||
public delegate void RightClickedEventHandler(Enemy THIS);
|
public delegate void RightClickedEventHandler(Peg THIS);
|
||||||
public bool _hovered = false, _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()
|
||||||
{
|
{
|
||||||
@@ -20,9 +19,9 @@ public partial class Enemy : StaticBody2D
|
|||||||
{"movement", 0} // 0 to 999999 reserved for movement priorities
|
{"movement", 0} // 0 to 999999 reserved for movement priorities
|
||||||
};
|
};
|
||||||
public Vector2I _address = -Vector2I.One, _range = Vector2I.Up;
|
public Vector2I _address = -Vector2I.One, _range = Vector2I.Up;
|
||||||
public List<Vector2I> _path = new(), _pathStored = new();
|
public List<Vector2I> _path = new();
|
||||||
public float _movement = 0;
|
public float _movement = 0;
|
||||||
public EnemyController _enemyController;
|
public PegController _pegController;
|
||||||
public Sprite2D _attack;
|
public Sprite2D _attack;
|
||||||
|
|
||||||
public override void _Ready()
|
public override void _Ready()
|
||||||
@@ -30,7 +29,6 @@ public partial class Enemy : StaticBody2D
|
|||||||
base._Ready();
|
base._Ready();
|
||||||
_attack = GetNode<Sprite2D>("Attack");
|
_attack = GetNode<Sprite2D>("Attack");
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void _Process(double delta)
|
public override void _Process(double delta)
|
||||||
{
|
{
|
||||||
base._Process(delta);
|
base._Process(delta);
|
||||||
@@ -45,43 +43,39 @@ public partial class Enemy : StaticBody2D
|
|||||||
EmitSignal(SignalName.RightClicked, this);
|
EmitSignal(SignalName.RightClicked, this);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
public override void _PhysicsProcess(double delta)
|
|
||||||
{
|
|
||||||
base._PhysicsProcess(delta);
|
|
||||||
}
|
}
|
||||||
|
public void Attack()
|
||||||
public void Attack(EnemyController CONTROLLER)
|
|
||||||
{
|
{
|
||||||
_attack.Visible = true;
|
// _attack.Visible = true;
|
||||||
Tween subtween = CreateTween();
|
Tween subtween = CreateTween();
|
||||||
|
subtween.TweenProperty(_attack, "visible", true, 0.0f);
|
||||||
subtween.TweenProperty(_attack, "global_position", Vector2.Zero, 0.5f);
|
subtween.TweenProperty(_attack, "global_position", Vector2.Zero, 0.5f);
|
||||||
subtween.TweenCallback(Callable.From(() =>
|
subtween.TweenCallback(Callable.From(() =>
|
||||||
{
|
{
|
||||||
CONTROLLER._playerController.ChangeHealth(-1, this);
|
_pegController._playerController.ChangeHealth(-1, this);
|
||||||
_attack.Position = Vector2.Zero;
|
_attack.Position = Vector2.Zero;
|
||||||
_attack.Visible = false;
|
_attack.Visible = false;
|
||||||
}));
|
}));
|
||||||
int key = _priorities["attack"];
|
int key = _priorities["attack"];
|
||||||
|
|
||||||
if (!CONTROLLER._tweenStages.ContainsKey(key))
|
if (!_pegController._tweenStages.ContainsKey(key))
|
||||||
{
|
{
|
||||||
CONTROLLER._tweenStages[key] = new();
|
_pegController._tweenStages[key] = new();
|
||||||
}
|
}
|
||||||
CONTROLLER._tweenStages[key].Add(subtween);
|
_pegController._tweenStages[key].Add(subtween);
|
||||||
_staminaRemaining = Math.Max(_staminaRemaining - 2, 0);
|
_staminaRemaining = Math.Max(_staminaRemaining - 2, 0);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool CanAttack(EnemyController CONTROLLER)
|
public bool CanAttack()
|
||||||
{
|
{
|
||||||
return _staminaRemaining > 0 && _address.Y <= _hitRange;
|
return _staminaRemaining > 0 && _address.Y <= _hitRange;
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool CanMove(EnemyController CONTROLLER)
|
public bool CanMove()
|
||||||
{
|
{
|
||||||
// GD.Print(_staminaRemaining," ",_address.Y," ", CONTROLLER._playArea._map._firstOpenRow);
|
// GD.Print(_staminaRemaining," ",_address.Y," ", CONTROLLER._playArea._map._firstOpenRow);
|
||||||
return _staminaRemaining > 0 && _address.Y > CONTROLLER._playArea._map._firstOpenRow;
|
return _staminaRemaining > 0 && _address.Y > _pegController._playArea._map._firstOpenRow;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void CounterAttack(Commander COMMANDER)
|
public void CounterAttack(Commander COMMANDER)
|
||||||
@@ -89,39 +83,49 @@ public partial class Enemy : StaticBody2D
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public virtual List<Vector2I> GetBestPath(Map MAP)
|
public virtual List<Vector2I> GetBestPath()
|
||||||
{
|
{
|
||||||
List<Vector2I> goals = GetGoals(MAP);
|
Map map = _pegController._playArea._map;
|
||||||
List<List<Vector2I>> paths = new();
|
List<Vector2I> goals = GetGoals();
|
||||||
|
// List<List<Vector2I>> paths = new();
|
||||||
for (int i = 0; i < goals.Count; i++)
|
Vector2I bestGoal = goals[0];
|
||||||
|
float bestCost = map._astar._EstimateCost(_address, bestGoal);
|
||||||
|
for (int i = 1; i < goals.Count; i++)
|
||||||
{
|
{
|
||||||
paths.Add(MAP.GetPath(_address, goals[i]));
|
Vector2I testGoal = goals[i];
|
||||||
|
float testCost = map._astar._EstimateCost(_address, testGoal);
|
||||||
|
if (testCost < bestCost)
|
||||||
|
{
|
||||||
|
bestCost = testCost;
|
||||||
|
bestGoal = testGoal;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
List<Vector2I> bestPath = paths.Where(p => p.Count > 0).OrderBy(p => p.Count).ToList()[0];
|
// List<Vector2I> bestPath = paths.Where(p => p.Count > 0).OrderBy(p => p.Count).ToList()[0];
|
||||||
|
List<Vector2I> bestPath = map.GetPath(_address, bestGoal);
|
||||||
return bestPath;
|
return bestPath;
|
||||||
}
|
}
|
||||||
|
|
||||||
public virtual List<Vector2I> GetGoals(Map MAP)
|
public virtual List<Vector2I> GetGoals()
|
||||||
{
|
{
|
||||||
return [.. MAP._cells.Where(c => c.Y == Math.Max(_address.Y - _visibilityRange, MAP._firstOpenRow)).Where(c => !MAP._astar.IsPointSolid(c))];
|
Map map = _pegController._playArea._map;
|
||||||
|
return [.. map._cells.Where(c => c.Y == Math.Max(_address.Y - _visibilityRange, map._firstOpenRow)).Where(c => !map._astar.IsPointSolid(c))];
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Move(Vector2I PATH_STEP, EnemyController CONTROLLER)
|
public void Move(Vector2I PATH_STEP)
|
||||||
{
|
{
|
||||||
CONTROLLER._playArea._map.SetCellEnemy(PATH_STEP, this);
|
_pegController._playArea._map.SetCellPeg(PATH_STEP, this);
|
||||||
_path.Add(PATH_STEP);
|
_path.Add(PATH_STEP);
|
||||||
|
|
||||||
Tween subtween = CreateTween();
|
Tween subtween = CreateTween();
|
||||||
subtween.TweenProperty(this, "global_position", CONTROLLER._playArea._map.GetCellPositionFromAddress(PATH_STEP), 0.25f);
|
subtween.TweenProperty(this, "global_position", _pegController._playArea._map.GetCellPositionFromAddress(PATH_STEP), 0.25f);
|
||||||
int key = _priorities["movement"] + CONTROLLER._actionLoop;
|
int key = _priorities["movement"] + _pegController._actionLoop;
|
||||||
GD.Print(key);
|
GD.Print(key);
|
||||||
if (!CONTROLLER._tweenStages.ContainsKey(key))
|
if (!_pegController._tweenStages.ContainsKey(key))
|
||||||
{
|
{
|
||||||
CONTROLLER._tweenStages[key] = new();
|
_pegController._tweenStages[key] = new();
|
||||||
}
|
}
|
||||||
|
|
||||||
CONTROLLER._tweenStages[key].Add(subtween);
|
_pegController._tweenStages[key].Add(subtween);
|
||||||
_staminaRemaining--;
|
_staminaRemaining--;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -140,10 +144,4 @@ public partial class Enemy : StaticBody2D
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void OnMouseEntered(){
|
|
||||||
_hovered = true;
|
|
||||||
}
|
|
||||||
public void OnMouseExited(){
|
|
||||||
_hovered = false;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
uid://g2ucwg3k342p
|
||||||
@@ -0,0 +1,214 @@
|
|||||||
|
using Godot;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Diagnostics;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
public partial class PegController : TurnController
|
||||||
|
{
|
||||||
|
public int _actionLoop = 0;
|
||||||
|
public PackedScene _hostilePegScene = GD.Load<PackedScene>("res://hostile_peg.tscn");
|
||||||
|
public List<Peg> _pegs = new();
|
||||||
|
public PlayerController _playerController;
|
||||||
|
public Dictionary<int, List<Tween>> _tweenStages = new();
|
||||||
|
public Tween _tween;
|
||||||
|
|
||||||
|
public void AddHostilePegs(int PEG_COUNT = 1)
|
||||||
|
{
|
||||||
|
for (int i = 0; i < PEG_COUNT; i++)
|
||||||
|
{
|
||||||
|
HostilePeg newHostilePeg = _hostilePegScene.Instantiate<HostilePeg>();
|
||||||
|
newHostilePeg.Death += HandlePegRemoval;
|
||||||
|
newHostilePeg.Clicked += HandlePegClick;
|
||||||
|
newHostilePeg.RightClicked += HandlePegRightClick;
|
||||||
|
|
||||||
|
newHostilePeg._stamina = Globals._rng.Next(2,4+1);
|
||||||
|
newHostilePeg.Modulate = new Color(newHostilePeg._stamina == 2 ? "#FF0000" : newHostilePeg._stamina == 3 ? "#00FF00" : "#0000FF");
|
||||||
|
newHostilePeg._pegController = this;
|
||||||
|
List<Vector2I> unoccupied = [.. _playArea._map._bottomRow.Where(c => _pegs.All(e => e._address != c))];
|
||||||
|
Vector2I randomCell = unoccupied[Globals._rng.Next(unoccupied.Count)];
|
||||||
|
SetPeg(newHostilePeg, randomCell);
|
||||||
|
_pegs.Add(newHostilePeg);
|
||||||
|
AddChild(newHostilePeg);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
public void AddHostilePegs(List<Vector2I> POSITIONS)
|
||||||
|
{
|
||||||
|
for (int i = 0; i < POSITIONS.Count; i++)
|
||||||
|
{
|
||||||
|
HostilePeg newHostilePeg = _hostilePegScene.Instantiate<HostilePeg>();
|
||||||
|
newHostilePeg.Death += HandlePegRemoval;
|
||||||
|
newHostilePeg.Clicked += HandlePegClick;
|
||||||
|
newHostilePeg.RightClicked += HandlePegRightClick;
|
||||||
|
|
||||||
|
newHostilePeg._stamina = Globals._rng.Next(2,4+1);
|
||||||
|
newHostilePeg._hitRange = Globals._rng.Next(1,2+1);
|
||||||
|
newHostilePeg.GetNode<Sprite2D>("Sprite2D").SelfModulate = new Color(newHostilePeg._stamina == 2 ? "#FF0000" : newHostilePeg._stamina == 3 ? "#00FF00" : "#0000FF");
|
||||||
|
newHostilePeg._pegController = this;
|
||||||
|
|
||||||
|
SetPeg(newHostilePeg, POSITIONS[i]);
|
||||||
|
_pegs.Add(newHostilePeg);
|
||||||
|
AddChild(newHostilePeg);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<Peg> GetRemainingPegs()
|
||||||
|
{
|
||||||
|
return [.. _pegs.Where(e => e.CanMove() || e.CanAttack())];
|
||||||
|
}
|
||||||
|
|
||||||
|
public void HandlePegActions()
|
||||||
|
{
|
||||||
|
_actionLoop = 0;
|
||||||
|
_tweenStages.Clear();
|
||||||
|
Map map = _playArea._map;
|
||||||
|
|
||||||
|
_pegs.ForEach(e => e._path.Clear());
|
||||||
|
|
||||||
|
List<Peg> remainingPegs = GetRemainingPegs();
|
||||||
|
while (remainingPegs.Count > 0 && _actionLoop <100)
|
||||||
|
{
|
||||||
|
for (int i = 0; i < remainingPegs.Count; i++)
|
||||||
|
{
|
||||||
|
Peg peg = remainingPegs[i];
|
||||||
|
if (!peg.CanMove() && !peg.CanAttack())
|
||||||
|
{
|
||||||
|
GD.Print(i);
|
||||||
|
}
|
||||||
|
HandlePegPathing(peg);
|
||||||
|
HandlePegAttacking(peg);
|
||||||
|
}
|
||||||
|
remainingPegs = GetRemainingPegs();
|
||||||
|
_actionLoop++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void HandlePegAttacking(Peg PEG)
|
||||||
|
{
|
||||||
|
if (!PEG.CanAttack())
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
PEG.Attack();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public void HandlePegClick(Peg PEG)
|
||||||
|
{
|
||||||
|
if (PEG._staminaRemaining <= 0){
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
TileMapLayer pathLayer = _playArea.GetNode<TileMapLayer>("PathLayer");
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void HandlePegRightClick(Peg PEG)
|
||||||
|
{
|
||||||
|
HandlePegRemoval(PEG);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void HandlePegPathing(Peg PEG)
|
||||||
|
{
|
||||||
|
if (!PEG.CanMove())
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
List<Vector2I> path = PEG.GetBestPath();
|
||||||
|
|
||||||
|
if (path?.Count == 0)
|
||||||
|
{
|
||||||
|
// PEG.Move(PEG._path.LastOrDefault(PEG._address), this);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
PEG.Move(path[0]);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void HandlePegRemoval(Peg PEG_TO_REMOVE)
|
||||||
|
{
|
||||||
|
_pegs.Remove(PEG_TO_REMOVE);
|
||||||
|
_playArea._map.SetCellPeg(PEG_TO_REMOVE._address, null);
|
||||||
|
PEG_TO_REMOVE.QueueFree();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void HandlePegSort()
|
||||||
|
{
|
||||||
|
_pegs = [.. _pegs.OrderBy(e => e._address.Y).ThenBy(e => e._path.Count).ThenBy(e => Math.Abs(e._address.X - _playArea._map._maxX / 2))];
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public void Initiate()
|
||||||
|
{
|
||||||
|
List<Vector2I> positions = [.. _playArea.GetNode<TileMapLayer>("InitialPositions").GetUsedCells()];
|
||||||
|
|
||||||
|
AddHostilePegs(positions);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void ProcessTween()
|
||||||
|
{
|
||||||
|
_tweenStages = _tweenStages.OrderBy(s => s.Key).ToDictionary();
|
||||||
|
GD.Print(string.Join(", ", _tweenStages.Keys));
|
||||||
|
if (_tweenStages.Count <= 0)
|
||||||
|
{
|
||||||
|
EndTurn();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (_tween != null)
|
||||||
|
{
|
||||||
|
_tween.Kill();
|
||||||
|
}
|
||||||
|
|
||||||
|
_tween = CreateTween();
|
||||||
|
|
||||||
|
for (int i = 0; i < _tweenStages.Count; i++)
|
||||||
|
{
|
||||||
|
_tween.Chain().TweenInterval(0.5f);
|
||||||
|
List<Tween> tweenSteps = _tweenStages.Values.ElementAt(i);
|
||||||
|
for (int j = 0; j < tweenSteps.Count; j++)
|
||||||
|
{
|
||||||
|
Tween step = tweenSteps[j];
|
||||||
|
_tween.Parallel().TweenSubtween(step);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
_tween.TweenCallback(Callable.From(EndTurn));
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public override void StartTurn()
|
||||||
|
{
|
||||||
|
|
||||||
|
AddHostilePegs(1);
|
||||||
|
|
||||||
|
for (int i = 0; i < _pegs.Count; i++)
|
||||||
|
{
|
||||||
|
_pegs[i].StartTurn();
|
||||||
|
}
|
||||||
|
|
||||||
|
HandlePegSort();
|
||||||
|
|
||||||
|
HandlePegActions();
|
||||||
|
|
||||||
|
ProcessTween();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void SetPeg(Peg PEG, Vector2I CELL)
|
||||||
|
{
|
||||||
|
if (CELL == new Vector2I(16, 14))
|
||||||
|
{
|
||||||
|
PEG._track = true;
|
||||||
|
}
|
||||||
|
_playArea._map.SetCellPeg(CELL, PEG);
|
||||||
|
PEG.GlobalPosition = _playArea._map.GetCellPositionFromAddress(CELL);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
+1
-1
@@ -10,7 +10,7 @@ public partial class PlayerController : TurnController
|
|||||||
public delegate void DeathEventHandler(PlayerController THIS);
|
public delegate void DeathEventHandler(PlayerController THIS);
|
||||||
public bool _dead = false;
|
public bool _dead = false;
|
||||||
public int _health, _healthMax = 100;
|
public int _health, _healthMax = 100;
|
||||||
public EnemyController _enemyController;
|
public PegController _pegController;
|
||||||
public PackedScene _commanderScene = GD.Load<PackedScene>("res://Commander.tscn");
|
public PackedScene _commanderScene = GD.Load<PackedScene>("res://Commander.tscn");
|
||||||
public List<Tower> _towers = new();
|
public List<Tower> _towers = new();
|
||||||
|
|
||||||
|
|||||||
@@ -25,6 +25,8 @@ shape = SubResource("CircleShape2D_7yfhp")
|
|||||||
scale = Vector2(0.5, 0.5)
|
scale = Vector2(0.5, 0.5)
|
||||||
texture = ExtResource("2_hqc8w")
|
texture = ExtResource("2_hqc8w")
|
||||||
|
|
||||||
|
[node name="Ray" type="RayCast2D" parent="." unique_id=113171676]
|
||||||
|
|
||||||
[node name="PredictedPath" type="Path2D" parent="." unique_id=1505290715]
|
[node name="PredictedPath" type="Path2D" parent="." unique_id=1505290715]
|
||||||
modulate = Color(1, 0, 1, 1)
|
modulate = Color(1, 0, 1, 1)
|
||||||
top_level = true
|
top_level = true
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
[gd_scene format=3 uid="uid://drt7w0eqp13tu"]
|
[gd_scene format=3 uid="uid://drt7w0eqp13tu"]
|
||||||
|
|
||||||
[ext_resource type="Script" uid="uid://dfba4vq6jv0a6" path="res://Enemy.cs" id="1_4gyqm"]
|
[ext_resource type="Script" uid="uid://dfba4vq6jv0a6" path="res://HostilePeg.cs" id="1_4gyqm"]
|
||||||
[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="1_7k104"]
|
||||||
[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_qi2p4"]
|
||||||
|
|
||||||
@@ -10,7 +10,7 @@ bounce = 0.5
|
|||||||
[sub_resource type="CircleShape2D" id="CircleShape2D_4gyqm"]
|
[sub_resource type="CircleShape2D" id="CircleShape2D_4gyqm"]
|
||||||
radius = 12.5
|
radius = 12.5
|
||||||
|
|
||||||
[node name="Enemy" 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_4gyqm")
|
||||||
@@ -0,0 +1,10 @@
|
|||||||
|
[gd_scene format=3 uid="uid://dse0sugndsrs"]
|
||||||
|
|
||||||
|
[ext_resource type="Script" uid="uid://dqvysa2n208d3" path="res://HoverableNode.cs" id="1_14v3m"]
|
||||||
|
|
||||||
|
[node name="HoverableNode" type="Node2D" unique_id=946672764]
|
||||||
|
script = ExtResource("1_14v3m")
|
||||||
|
|
||||||
|
[node name="Bounds" type="Area2D" parent="." unique_id=783465962]
|
||||||
|
|
||||||
|
[node name="CollisionShape2D" type="CollisionShape2D" parent="Bounds" unique_id=585114419]
|
||||||
@@ -2,8 +2,9 @@
|
|||||||
|
|
||||||
[ext_resource type="Script" uid="uid://cg1m762ed04kv" path="res://Main.cs" id="1_ig7tw"]
|
[ext_resource type="Script" uid="uid://cg1m762ed04kv" path="res://Main.cs" id="1_ig7tw"]
|
||||||
[ext_resource type="PackedScene" uid="uid://dumcridek4xy3" path="res://play_area.tscn" id="2_1bvp3"]
|
[ext_resource type="PackedScene" uid="uid://dumcridek4xy3" path="res://play_area.tscn" id="2_1bvp3"]
|
||||||
[ext_resource type="PackedScene" uid="uid://c6b188d2a20eq" path="res://enemy_controller.tscn" id="4_1bvp3"]
|
[ext_resource type="PackedScene" uid="uid://c6b188d2a20eq" path="res://peg_controller.tscn" id="4_1bvp3"]
|
||||||
[ext_resource type="PackedScene" uid="uid://b7kvx7p0b2086" path="res://player_controller.tscn" id="4_lquwl"]
|
[ext_resource type="PackedScene" uid="uid://b7kvx7p0b2086" path="res://player_controller.tscn" id="4_lquwl"]
|
||||||
|
[ext_resource type="PackedScene" uid="uid://by0a5f2ft0u03" path="res://mouse_handler.tscn" id="5_lquwl"]
|
||||||
|
|
||||||
[node name="Main" type="Node" unique_id=535208469]
|
[node name="Main" type="Node" unique_id=535208469]
|
||||||
script = ExtResource("1_ig7tw")
|
script = ExtResource("1_ig7tw")
|
||||||
@@ -14,3 +15,5 @@ position = Vector2(360, 180)
|
|||||||
[node name="EnemyController" parent="." unique_id=1894449838 instance=ExtResource("4_1bvp3")]
|
[node name="EnemyController" 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")]
|
||||||
|
|
||||||
|
[node name="MouseHandler" parent="." unique_id=1823071759 instance=ExtResource("5_lquwl")]
|
||||||
|
|||||||
@@ -0,0 +1,6 @@
|
|||||||
|
[gd_scene format=3 uid="uid://by0a5f2ft0u03"]
|
||||||
|
|
||||||
|
[ext_resource type="Script" uid="uid://dewxuppyw2gtp" path="res://MouseHandler.cs" id="1_r4hv2"]
|
||||||
|
|
||||||
|
[node name="MouseHandler" type="Node2D" unique_id=215972463]
|
||||||
|
script = ExtResource("1_r4hv2")
|
||||||
@@ -0,0 +1,32 @@
|
|||||||
|
[gd_scene format=3 uid="uid://b06qhbc336iwh"]
|
||||||
|
|
||||||
|
[ext_resource type="Script" uid="uid://g2ucwg3k342p" path="res://Peg.cs" id="1_cavuh"]
|
||||||
|
[ext_resource type="Texture2D" uid="uid://nwj4n7if8kqd" path="res://Art/circle25r.png" id="2_cut4e"]
|
||||||
|
[ext_resource type="Texture2D" uid="uid://m4wfj36twmqy" path="res://Art/attack.png" id="3_inmy4"]
|
||||||
|
|
||||||
|
[sub_resource type="PhysicsMaterial" id="PhysicsMaterial_7k104"]
|
||||||
|
bounce = 0.5
|
||||||
|
|
||||||
|
[sub_resource type="CircleShape2D" id="CircleShape2D_4gyqm"]
|
||||||
|
radius = 12.5
|
||||||
|
|
||||||
|
[node name="Peg" type="StaticBody2D" unique_id=1417697759]
|
||||||
|
input_pickable = true
|
||||||
|
physics_material_override = SubResource("PhysicsMaterial_7k104")
|
||||||
|
script = ExtResource("1_cavuh")
|
||||||
|
|
||||||
|
[node name="CollisionShape2D" type="CollisionShape2D" parent="." unique_id=1762191899]
|
||||||
|
shape = SubResource("CircleShape2D_4gyqm")
|
||||||
|
|
||||||
|
[node name="Sprite2D" type="Sprite2D" parent="." unique_id=1941012605]
|
||||||
|
texture_filter = 1
|
||||||
|
scale = Vector2(0.5, 0.5)
|
||||||
|
texture = ExtResource("2_cut4e")
|
||||||
|
|
||||||
|
[node name="Attack" type="Sprite2D" parent="." unique_id=1776738311]
|
||||||
|
visible = false
|
||||||
|
texture_filter = 1
|
||||||
|
texture = ExtResource("3_inmy4")
|
||||||
|
|
||||||
|
[connection signal="mouse_entered" from="." to="." method="OnMouseEntered"]
|
||||||
|
[connection signal="mouse_exited" from="." to="." method="OnMouseExited"]
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
[gd_scene format=3 uid="uid://c6b188d2a20eq"]
|
[gd_scene format=3 uid="uid://c6b188d2a20eq"]
|
||||||
|
|
||||||
[ext_resource type="Script" uid="uid://brsi76xcgx3et" path="res://EnemyController.cs" id="1_tkpyo"]
|
[ext_resource type="Script" uid="uid://brsi76xcgx3et" path="res://PegController.cs" id="1_tkpyo"]
|
||||||
|
|
||||||
[node name="EnemyController" type="Node2D" unique_id=197453707]
|
[node name="PegController" type="Node2D" unique_id=197453707]
|
||||||
script = ExtResource("1_tkpyo")
|
script = ExtResource("1_tkpyo")
|
||||||
Reference in New Issue
Block a user