public void Init(int x, int z) { MAP_LENGTH_X = x; MAP_WIDTH_Z = z; for (int i = 0; i < MAP_LENGTH_X; ++i) { for (int j = 0; j < MAP_WIDTH_Z; ++j) { GridMapCell gridMapCell = new GridMapCell(); m_mapCellList.Add(gridMapCell); } } }
public bool TestAgentCells(Vector2i posi, PathFindAgent agent) { if (posi.m_x >= MAP_LENGTH_X || posi.m_y >= MAP_WIDTH_Z) { return(false); } List <Vector2i> outLineList = agent.m_outlineList; for (int i = 0; i < outLineList.Count; ++i) { outLineList[i] = posi + agent.m_outlineOffsetList[i]; } bool canUse = true; for (int i = 0; i < outLineList.Count; ++i) { int index = GetIndex(outLineList[i]); if (index >= 0 && index < m_mapCellList.Count) { GridMapCell cellInfo = m_mapCellList[index]; if (cellInfo.m_whoseArea.Count == 0) { //return true; } else if (cellInfo.m_whoseArea.Count == 1 && cellInfo.m_whoseArea[0] == agent.m_agentId) { //return true; } else { //return false; canUse = false; } } else { //return false; canUse = false; } } return(canUse); }
public void ShowColliderData() { foreach (var iter in m_debugGo) { GameObject.Destroy(iter); } UnityEngine.GameObject colliderPrefab = UnityEngine.Resources.Load("Barrier2") as UnityEngine.GameObject; for (int i = 0; i < m_mapCellList.Count; ++i) { GridMapCell iter = m_mapCellList[i]; if (iter.m_whoseArea.Count != 0) { Vector2i pos = ConvertIndexToPos(i); UnityEngine.GameObject.Instantiate(colliderPrefab, new UnityEngine.Vector3(pos.m_x, 0, pos.m_y), UnityEngine.Quaternion.identity); } } }