Esempio n. 1
0
        private void RemoveEdgeFromMapDelegate(int x, int z)
        {
            x = SomeMath.Clamp(0, PathFinder.CELL_GRID_SIZE - 1, x);
            z = SomeMath.Clamp(0, PathFinder.CELL_GRID_SIZE - 1, z);
            //var list = dataMap[SomeMath.Clamp(0, PathFinder.CELL_GRID_SIZE - 1, x)][SomeMath.Clamp(0, PathFinder.CELL_GRID_SIZE - 1, z)];
            //Debug.Log(x + ":"+ z);
            //Debug.Log(dataMap == null);
            //Debug.Log(dataMap[x] == null);
            //Debug.Log(dataMap[x][z] == null);

            List <CellDataMapValue> tempList = new List <CellDataMapValue>(dataMap[x][z]);

            for (int i = tempList.Count - 1; i >= 0; i--)
            {
                if (tempList[i].connection == tempCellConnection)
                {
                    tempList.RemoveAt(i);
                }
            }
            dataMap[x][z] = tempList.ToArray();

            //for (int i = list.Count - 1; i >= 0; i--) {
            //    if(list[i].connection == tempCellConnection)
            //        list.RemoveAt(i);
            //}
        }
Esempio n. 2
0
        /// <summary>
        /// IMPORTANT:
        /// Sort so empty edges are at begining
        /// </summary>
        private void AddEdgeToMapDelegate(int x, int z)
        {
            x = SomeMath.Clamp(0, PathFinder.CELL_GRID_SIZE - 1, x);
            z = SomeMath.Clamp(0, PathFinder.CELL_GRID_SIZE - 1, z);

            CellDataMapValue[] arr = dataMap[x][z];
            if (arr == null)
            {
                arr = new CellDataMapValue[0];
            }
            CellDataMapValue[] newArr = new CellDataMapValue[arr.Length + 1];
            for (int i = 0; i < arr.Length; i++)
            {
                newArr[i] = arr[i];
            }
            newArr[arr.Length] = tempCellDataMapValue;
            Array.Sort(newArr, SortCellDataMapValue);
            dataMap[x][z] = newArr;

            //if(dataMap[x][z] == null)
            //    dataMap[x][z] = new List<CellDataMapValue>();
            //dataMap[x][z].Add(tempCellDataMapValue);
            //dataMap[x][z].Sort(SortCellDataMapValue);//place connections with null at the end and with connection at begining
        }