public void selectTile() { Cursor c = currentCursor.GetComponent <Cursor> (); if (!selected) { TileStack ts = gameMap.GetComponent <BoardMap> ().getTile(c.getX(), c.getY()).GetComponent <TileStack> (); if (ts.getHeight() != 1 || ts.getPlayer() != null) { if (ts.getPlayer() == null || ts.getPlayer().GetComponent <Player> ().getTeam() == c.getTeam()) { selectX = c.getX(); selectY = c.getY(); selected = true; newNeutralCursor(c.getX(), c.getY(), c.getTeam()); } } } else { BoardMap bm = gameMap.GetComponent <BoardMap> (); Deselect(); if (bm.Move(bm.getTile(selectX, selectY), bm.getTile(c.getX(), c.getY()))) { newCursor(c.getX(), c.getY(), !c.getTeam()); } } }
public bool Move(TileStack src, TileStack dest) { //is source player if yes check if dest is legal Move //if yes player.src = false, dest.player = true // //if source or dest is a Source of water (source) return false // if (src.GetSource() == true || dest.GetSource() == true) { return(false); } if (CompareDistance(src, dest) > 1) { return(false); } else if (src.GetPlayer() != null) { if (dest.GetWater() == true) { return(false); } else { dest.SetPlayer(src.GetPlayer()); src.SetPlayer(null); //animate } } else { src.Lower(); dest.Raise(); } return(true); }
public bool Move(GameObject src, GameObject dest) { //is source player if yes check if dest is legal Move //if yes player.src = false, dest.player = true // //if source or dest is a Source of water (source) return false // int x, y; x = 0; y = 0; TileStack srcStack = src.GetComponent <TileStack> (); TileStack destStack = dest.GetComponent <TileStack> (); if (src.Equals(lastMoveDest) && dest.Equals(lastMoveSrc)) { return(false); } if (srcStack.getSource() == true || destStack.getSource() == true) { return(false); } if (CompareDistance(src, dest) > 1) { return(false); } if (srcStack.getPlayer() != null) { if (destStack.getWater() == true) { return(false); } if (destStack.getPlayer() != null) { return(false); } if (srcStack.getPlayer().GetComponent <Player> ().getTeam() != GameController.instance.teamTurn) { return(false); } if (srcStack.getPlayer().GetComponent <Player>().getTeam() == false) { findPos(dest, out x, out y); GameController.instance.newBluePlayer(x, y); } else { findPos(dest, out x, out y); GameController.instance.newRedPlayer(x, y); } src.GetComponent <TileStack>().setPlayer(null); } else { if (src.Equals(dest)) { return(false); } if (srcStack.getHeight() == 1) { return(false); } if (destStack.getHeight() == 6) { return(false); } lower(src); raise(dest, GameController.instance.teamTurn); } lastMoveSrc = src; lastMoveDest = dest; return(true); }
public int CompareDistance(TileStack src, TileStack dest) { return(1); }
public int CompareHeight(TileStack src, TileStack dest) { return(src.GetHeight() - dest.GetHeight()); }
public void Lower(TileStack tile) { tile.Lower(); }
public void Raise(TileStack tile) { tile.Raise(); }