Action Points Movement Perfected
This commit is contained in:
@@ -85,6 +85,14 @@ namespace DepthsBelow.Component
|
||||
}
|
||||
}
|
||||
|
||||
public int Length
|
||||
{
|
||||
get
|
||||
{
|
||||
return (path != null) ? path.Count : 0;
|
||||
}
|
||||
}
|
||||
|
||||
private AStar.PathFinderFast pathFinder;
|
||||
private List<AStar.PathFinderNode> path;
|
||||
|
||||
|
||||
@@ -177,7 +177,12 @@ namespace DepthsBelow
|
||||
Vector2 fromMain = new Vector2((mainpath.X - unit.Position.X)*Grid.TileSize,
|
||||
(mainpath.Y - unit.Position.Y)*Grid.TileSize);
|
||||
var goal = Grid.WorldToGrid(mouseWorldPos - fromMain);
|
||||
Console.WriteLine("First " + unit.AP);
|
||||
unit.GetComponent<Component.PathFinder>().Goal = goal;
|
||||
var length = unit.GetComponent<Component.PathFinder>().Length - 1;
|
||||
if (unit.AP >= length)
|
||||
{
|
||||
|
||||
if (unit.GetComponent<Component.PathFinder>().IsMoving == false)
|
||||
{
|
||||
// If a path was not found, add the unit to the stack
|
||||
@@ -185,9 +190,17 @@ namespace DepthsBelow
|
||||
}
|
||||
else
|
||||
{
|
||||
unit.AP -= length;
|
||||
Console.WriteLine("then " + unit.AP);
|
||||
collisionMap[goal.X, goal.Y] = 0;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
unit.GetComponent<Component.PathFinder>().Stop();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
// Loop in a spiral and assign the soldiers in the stack their own unblocked positions
|
||||
@@ -217,10 +230,16 @@ namespace DepthsBelow
|
||||
}
|
||||
else
|
||||
{
|
||||
if (soldier.AP >= soldier.GetComponent<Component.PathFinder>().Length)
|
||||
{
|
||||
soldier.GetComponent<Component.PathFinder>().Goal = point;
|
||||
soldier.AP -= soldier.GetComponent<Component.PathFinder>().Length;
|
||||
|
||||
Console.WriteLine(x + " " + y);
|
||||
Console.WriteLine(soldier.GetComponent<Component.PathFinder>().Goal.X + " " +
|
||||
soldier.GetComponent<Component.PathFinder>().Goal.Y);
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -140,7 +140,7 @@ namespace DepthsBelow
|
||||
{
|
||||
foreach (var unit in core.Squad)
|
||||
{
|
||||
unit.AP = 0;
|
||||
unit.AP = unit.MaxActionPoints;
|
||||
unit.Fired = false;
|
||||
}
|
||||
|
||||
@@ -227,10 +227,10 @@ namespace DepthsBelow
|
||||
cost = rocketCost;
|
||||
type = "Rocket";
|
||||
}
|
||||
if (soldier.AP <= soldier.NumberOfActionPoints - cost)
|
||||
if (soldier.AP >= cost)
|
||||
{
|
||||
core.Volley.Add(new Shot(core.EntityManager, soldier.GetComponent<Component.Stat>(), type));
|
||||
soldier.AP += cost;
|
||||
soldier.AP -= cost;
|
||||
soldier.Fired = true;
|
||||
}
|
||||
else
|
||||
|
||||
@@ -35,16 +35,16 @@ namespace DepthsBelow
|
||||
}
|
||||
}
|
||||
|
||||
public int NumberOfActionPoints = 10;
|
||||
int spentActionPoints = 0;
|
||||
public int MaxActionPoints = 10;
|
||||
int actionPointsLeft = 0;
|
||||
|
||||
public int AP
|
||||
{
|
||||
get { return spentActionPoints; }
|
||||
get { return actionPointsLeft; }
|
||||
set
|
||||
{
|
||||
spentActionPoints = value;
|
||||
GetComponent<Component.Stat>().GetStep = spentActionPoints;
|
||||
actionPointsLeft = value;
|
||||
GetComponent<Component.Stat>().GetStep = actionPointsLeft;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -174,17 +174,17 @@ namespace DepthsBelow
|
||||
|
||||
if (Transform.World == nodeWorldPos)
|
||||
{
|
||||
if (AP < NumberOfActionPoints)
|
||||
{
|
||||
AP++;
|
||||
//if (AP < NumberOfActionPoints)
|
||||
//{
|
||||
//AP++;
|
||||
lastLastNode = lastNode;
|
||||
lastNode = nextNode;
|
||||
nextNode = GetComponent<PathFinder>().Next();
|
||||
}
|
||||
else
|
||||
//}
|
||||
/*else
|
||||
{
|
||||
GetComponent<PathFinder>().Stop();
|
||||
}
|
||||
}*/
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user