public void Init(int row, int col, MapCtr map, AStarMap astarMap, PlayerCtrEx target, bool isLeft) { startRow = row; startCol = col; m_data = GetComponent <PlayerData> (); m_data.Init(row, col, map); m_astarMap = astarMap; m_target = target; m_data.RegisterMoveOverEvent(AutoMoveOver); if (isLeft) { if (m_astarMap.GetCell(m_data.Row, m_data.Column).IsToLeft) { m_data.Move(-1, 0); } else { m_data.Move(1, 0); } } else { if (m_astarMap.GetCell(m_data.Row, m_data.Column).IsToRight) { m_data.Move(1, 0); } else { m_data.Move(-1, 0); } } }
public void Clear() { if (null != Player) { GameObject.Destroy(Player.gameObject); } foreach (DogCtr dog in m_dogList) { GameObject.Destroy(dog.gameObject); } m_player = null; m_dogList.Clear(); // for (int i = 0; i < m_map.row; i++) { for (int j = 0; j < m_map.column; j++) { GameObject.Destroy(cells[j, i].gameObject); cells[j, i] = null; } } foreach (GameObject go in m_decorationList) { GameObject.Destroy(go); } m_decorationList.Clear(); GameObject.Destroy(this.gameObject); }
void LoadPlayer(int row, int col) { GameObject prefab = Resources.Load("Player") as GameObject; GameObject player = GameObject.Instantiate(prefab); m_player = player.GetComponent <PlayerCtrEx> (); m_player.Init(row, col, this); }
// Use this for initialization public void Init(int row, int col, MapCtr map, AStarMap astarMap, PlayerCtrEx target) { startRow = row; startCol = col; m_data = GetComponent <PlayerData> (); m_data.Init(row, col, map); m_astarMap = astarMap; m_target = target; m_data.RegisterMoveOverEvent(MoveOver); FindPath(); }