59 lines
1.4 KiB
C#
59 lines
1.4 KiB
C#
using Godot;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
|
|
public partial class BasicMovement : PegAction
|
|
{
|
|
public override void _Ready()
|
|
{
|
|
base._Ready();
|
|
_category = "movement";
|
|
_priority = 0;
|
|
_cost = 1;
|
|
_range = 2^32;
|
|
_usesMax = 2^32;
|
|
_usesRemaining = _usesMax;
|
|
}
|
|
|
|
public override Tween CreateAnimation(Peg PEG)
|
|
{
|
|
PegController pegController = PEG._pegController;
|
|
Map map = pegController._playArea._map;
|
|
MapCell cell = PEG._path[0];
|
|
|
|
Tween subtween = CreateTween();
|
|
Vector2 target = cell.GlobalPosition;
|
|
|
|
subtween.TweenProperty(PEG, "global_position", target, 0.25f);
|
|
PEG._path.RemoveAt(0);
|
|
return subtween;
|
|
}
|
|
|
|
public override void DoImmediately(Peg PEG)
|
|
{
|
|
List<MapCell> path = PEG.GetBestPath(true);
|
|
PegController pegController = PEG._pegController;
|
|
Map map = pegController._playArea._map;
|
|
if (path?.Count == 0)
|
|
{
|
|
return;
|
|
}
|
|
MapCell cell = path[0];
|
|
|
|
map.SetCellPeg(cell, PEG);
|
|
PEG._path.Add(cell);
|
|
}
|
|
|
|
public override bool MeetsCriteria(Peg PEG)
|
|
{
|
|
List<MapCell> bestPath = PEG.GetBestPath(true);
|
|
return base.MeetsCriteria(PEG)
|
|
&& bestPath.Count > 0
|
|
&& PEG._map.GetCellDisposition(bestPath[0]._address) != -(int)PEG._disposition;
|
|
}
|
|
|
|
|
|
|
|
}
|