using UnityEngine; using System.Collections; public class Tile : MapObject { public const float TILE_WIDTH = 1f; public const float TILE_LENGTH = 1f; private int col; private int row; public int type; public void setGridPosition(int col, int row) { this.col = col; this.row = row; Vector3 position = transform.position; position.x = TILE_WIDTH*col + TILE_WIDTH*0.5f; position.z = TILE_LENGTH*row + TILE_LENGTH*0.5f; transform.position = position; } public int getCol() { return col; } public int getRow() { return row; } public void setType(int type) { this.type = type; Color color = this.GetComponent().material.color; if(type == AStarNode.Type.Empty.GetHashCode()) { color = Color.white; color.a = 0.5f; } else if(type == AStarNode.Type.Wall.GetHashCode()) { color = Color.black; color.a = 0.5f; } else if(type == AStarNode.Type.BlueWall.GetHashCode()) { color = TeamUtil.GetTeamColor(TeamUtil.Team.Blue.GetHashCode()); color.a = 0.5f; } else if(type == AStarNode.Type.RedWall.GetHashCode()) { color = TeamUtil.GetTeamColor(TeamUtil.Team.Red.GetHashCode()); color.a = 0.5f; } else if(type == AStarNode.Type.YellowWall.GetHashCode()) { color = TeamUtil.GetTeamColor(TeamUtil.Team.Yellow.GetHashCode()); color.a = 0.5f; } this.GetComponent().material.color = color; } }