Skip to content

Instantly share code, notes, and snippets.

@IronMonk-UK
Created May 11, 2016 17:13
Show Gist options
  • Save IronMonk-UK/bc9de704cf93e78220409925ab791e02 to your computer and use it in GitHub Desktop.
Save IronMonk-UK/bc9de704cf93e78220409925ab791e02 to your computer and use it in GitHub Desktop.
// Makes tiles populated by units unwalkable, so they cannot be moved to, or stopped on
void BlockUnitTiles() {
// If the current unit is a User unit, and moving
if (userUnits.Contains(units[currentUnitIndex]) && units[currentUnitIndex].moving) {
// For every unit
foreach(Unit u in units) {
// If the unit is not the current unit
if(u != units[currentUnitIndex])
// Set the walkable bool on the node of the populated tile to false
u.currentTile.node.walkable = false;
}
}
// If the unit has finished movement
if (units[currentUnitIndex].moved) {
// For every unit
foreach(Unit u in units) {
// Set the walkable bool on the node of the populated tile back to true
u.currentTile.node.walkable = true;
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment