public void Push(WorldTile pusher, WorldTile pushee) { List <Vector2Int> pushDirections = HexUtils.GetPushDirections(pusher.OffsetCoords, pushee.OffsetCoords); foreach (Vector2Int pushDirection in pushDirections) { WorldTile pushTile; if (tiles.TryGetValue(new Vector3Int(pushee.LocalPlace.x + pushDirection.x, pushee.LocalPlace.y + pushDirection.y, pushee.LocalPlace.z), out pushTile)) { if (pushTile.IsPassable() && pushTile.army == null) { pushTile.army = pushee.army; pushee.army = pusher.army; pusher.army = null; break; } } } }
//This makes the selected army "push" the losing army post-battle //TODO: can push onto an empty enemy tile public void Push() { List <Vector2Int> pushDirections = HexUtils.GetPushDirections(selectedTile.OffsetCoords, hovoredTile.OffsetCoords); foreach (Vector2Int pushDirection in pushDirections) { WorldTile pushTile; if (tiles.TryGetValue(new Vector3Int(hovoredTile.LocalPlace.x + pushDirection.x, hovoredTile.LocalPlace.y + pushDirection.y, hovoredTile.LocalPlace.z), out pushTile)) { if (pushTile.IsPassable() && pushTile.army == null) { pushTile.army = hovoredTile.army; hovoredTile.army = selectedTile.army; selectedTile.army = null; selectedTile.Deselect(); selectedTile = hovoredTile; selectedTile.Select(selectTile); break; } } } }