using UnityEngine; using System.Collections; public class MapObject : MonoBehaviour, IMapObject { public enum StartPostionDirect { Bottom = 0, BottomLeft = 1, BottomRight = 2, Top = 3, TopLeft = 4, TopRight = 5, Left = 6, Right = 7, Center = 8, None = 9, } private static System.Array startPosDirArr = System.Enum.GetValues(typeof(StartPostionDirect)); public static StartPostionDirect GetStartPositionDirect(int code) { return (StartPostionDirect)startPosDirArr.GetValue(code); } public int _id; protected int _typeId; public TeamUtil.Team _team; protected Map map; public StartPostionDirect startPositionDirect; public virtual void Init(Map map) { this.map = map; } public int id { get{ return _id; } set{ _id = value; } } public virtual TeamUtil.Team team { get{ return _team; } set{ _team = value; } } public int typeId { get{ return _typeId; } set{ _typeId = value; } } public virtual Vector3 position { get{return transform.position;} set{transform.position = value;} } public Vector3 GetStartPosition() { Vector3 pos = position; if(startPositionDirect == StartPostionDirect.Bottom) { pos.z -= 4f; } else if(startPositionDirect == StartPostionDirect.BottomLeft) { pos.z -= 3f; pos.x -= 3f; } else if(startPositionDirect == StartPostionDirect.BottomRight) { pos.z -= 3f; pos.x += 3f; } else if(startPositionDirect == StartPostionDirect.Top) { pos.z += 4f; } else if(startPositionDirect == StartPostionDirect.TopLeft) { pos.z += 3f; pos.x -= 3f; } else if(startPositionDirect == StartPostionDirect.TopRight) { pos.z += 3f; pos.x += 3f; } else if(startPositionDirect == StartPostionDirect.Left) { pos.x -= 4f; } else if(startPositionDirect == StartPostionDirect.Right) { pos.x += 4f; } return pos; } public int col { get{return Map.XToColumn(position.x);} } public int row { get{return Map.ZToRow(position.z);} } public virtual void Remove() { } }