Skip to content

Instantly share code, notes, and snippets.

@IronMonk-UK
Last active April 7, 2016 13:07
Show Gist options
  • Save IronMonk-UK/b2ba34b1652def8eae3de8863faf63f8 to your computer and use it in GitHub Desktop.
Save IronMonk-UK/b2ba34b1652def8eae3de8863faf63f8 to your computer and use it in GitHub Desktop.
AI Snippets
public override void turnUpdate()
{
//A boolean added in preparation, should it be required
findUnits = true;
//I created a List within the GameManager to store specifically User Units, allowing the AI to loop through them
foreach (UserUnit u in gm.userUnits)
{
//The path target is set to the unit, creating a path from the AI Unit to the User Unit
path.target.transform.position = u.currentTile._pos;
//A debug log to ensure results were being picked up correctly
Debug.Log(u._name + " : " + u.gridPosition + " Path Count : " + grid.path.Count);
//If the length of the path is less than or equal to the AI Units movement
if(grid.path.Count <= moveLimit) {
//It is fed back that they are within range
Debug.Log(u._name + " is in range!");
Debug.Log(grid.path.Count);
}
}
if (units[currentUnitIndex].currentHealth > 0)
{
units[currentUnitIndex].turnUpdate();
Debug.Log("Turn Update.");
}
else
{
nextTurn();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment