Last active
April 7, 2016 13:07
-
-
Save IronMonk-UK/b2ba34b1652def8eae3de8863faf63f8 to your computer and use it in GitHub Desktop.
AI Snippets
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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