public void GetNearbyTiles() { //retrieve the x and y coordinates int x = (int)att.x_coord; int y = (int)att.y_coord; //fill the nearby array nearby[0] = tm.GetTile(x, y + 1); //top right nearby[1] = tm.GetTile(x + 1, y); //top left nearby[2] = tm.GetTile(x, y - 1); //bottom left nearby[3] = tm.GetTile(x - 1, y); //bottom right }
public void MoveTile(int x, int y, int deltax, int deltay, TileScript tile) { moves++; gameMenuScript.UpdateMovesText(moves); GameObject activeTile = tileManagerScript.GetTile(x, y); tileManagerScript.UpdateIndexes(x, y, deltax, deltay); StartCoroutine(tile.Move(tileManagerScript.CalculatePosition(tile.XIndex + deltax, tile.YIndex + deltay, activeTile.transform.position.y), SPEED, deltax, deltay)); }
//why is this up here? List <GameObject> get_adj(GameObject node) { //im lazy //fix it if you want //Debug.Log ("in get_adj"); List <GameObject> neighbors = new List <GameObject>(); int x = node.GetComponent <NodeAttributes>().x_coord; int y = node.GetComponent <NodeAttributes>().y_coord; //only 4 directional movement //blame Thomas GameObject node_a = tm.GetTile(x, y + 1); neighbors.Add(node_a); GameObject node_b = tm.GetTile(x + 1, y); neighbors.Add(node_b); GameObject node_c = tm.GetTile(x - 1, y); neighbors.Add(node_c); GameObject node_d = tm.GetTile(x, y - 1); neighbors.Add(node_d); if (node_a == null) { Destroy(node_a); } if (node_b == null) { Destroy(node_b); } if (node_c == null) { Destroy(node_c); } if (node_d == null) { Destroy(node_d); } return(neighbors); }