123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131 |
- 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);
- }
- protected int _id;
- protected int _typeId;
- protected 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()
- {
- }
- }
|