Example #1
0
    private Grid[,] PopulateWithUnits(Grid[,] grids)
    {
        int otherSide = grids.GetLength(1) - 1;
        int end       = grids.GetLength(0) - 1;

        Unit[] occupants;
        for (int x = 1; x < end; x++)
        {
            occupants    = new Unit[1];
            occupants[0] = NewUnit(Unit.UNIT_TYPES.CUBE, Player.TEAM.GREEN, new Vector2(x, 0));
            occupants[0].SetGrid(grids[x, 0]);
            grids[x, 0].SetOccupants(occupants);

            occupants    = new Unit[1];
            occupants[0] = NewUnit(Unit.UNIT_TYPES.PYRAMID, Player.TEAM.GREEN, new Vector2(x, 1));
            occupants[0].SetGrid(grids[x, 1]);
            grids[x, 1].SetOccupants(occupants);

            occupants    = new Unit[1];
            occupants[0] = NewUnit(Unit.UNIT_TYPES.PYRAMID, Player.TEAM.RED, new Vector2(x, otherSide - 1));
            occupants[0].SetGrid(grids[x, otherSide - 1]);
            grids[x, otherSide - 1].SetOccupants(occupants);

            occupants    = new Unit[1];
            occupants[0] = NewUnit(Unit.UNIT_TYPES.CUBE, Player.TEAM.RED, new Vector2(x, otherSide));
            occupants[0].SetGrid(grids[x, otherSide]);
            grids[x, otherSide].SetOccupants(occupants);
        }


        return(grids);
    }
Example #2
0
        private void Awake()
        {
            Grids = new Grid[RowNum, ColumnNum];
            int rowLength    = Grids.GetLength(0);
            int columnLength = Grids.GetLength(1);

            for (int i = 0; i < rowLength - 1; i++)
            {
                for (int j = 0; j < columnLength; j++)
                {
                    Grids[i, j] = new WallGrid(new Vector2Int(i, j), Instantiate(Resources.Load("WallGrid") as GameObject, transform));
                    Grids[i, j].WorldPosition = new Vector2(j * WallGridSize.x, -i * WallGridSize.y);
                    Grids[i, j].gameObject.transform.localPosition = Grids[i, j].WorldPosition;
                }
            }

            for (int j = 0; j < columnLength; j++)
            {
                int i = rowLength - 1;
                Grids[i, j] = new GroundGrid(new Vector2Int(i, j), Instantiate(Resources.Load("GroundGrid") as GameObject, transform));
                Grids[i, j].WorldPosition = new Vector2(j * WallGridSize.x, -i * WallGridSize.y + 0.3f);
                Grids[i, j].gameObject.transform.localPosition = Grids[i, j].WorldPosition;
            }

            m_OccupyCraftAndStorage();
        }
Example #3
0
    private void spawnMines()
    {
        int totalGrids = grids.GetLength(0) * grids.GetLength(1);

        int[] seq = new int[totalGrids];
        for (int i = 0; i < seq.Length; ++i)
        {
            seq[i] = i;
        }
        for (int i = seq.Length - 1; i > 0; --i)
        {
            int random = Random.Range(0, i - 1);
            int t      = seq[i];
            seq[i]      = seq[random];
            seq[random] = t;
        }
        for (int i = 0; i < mineCount; ++i)
        {
            int index = seq[i];
            int r     = index / grids.GetLength(1);
            int c     = index % grids.GetLength(1);

            grids[r, c].type = GridType.Mine;
        }
    }
Example #4
0
        private HamsterMove Moveto(int target_row, int target_col)
        {
            int state = 11;

            if (target_row > row && row + 1 < envirment.GetLength(0) && envirment[row + 1, col].Value >= 0)
            {
                state += 10;
            }
            else if (target_row < row && row - 1 >= 0 && envirment[row - 1, col].Value >= 0)
            {
                state -= 10;
            }

            if (target_col > col && col + 1 < envirment.GetLength(1) && envirment[row, col + 1].Value >= 0)
            {
                state += 1;
            }
            else if (target_col < col && col - 1 >= 0 && envirment[row, col - 1].Value >= 0)
            {
                state -= 1;
            }

            switch (state)
            {
            case 11:
                return(HamsterMove.None);

            case 12:
                return(HamsterMove.Down);

            case 10:
                return(HamsterMove.Up);

            case 21:
                return(HamsterMove.Right);

            case 22:
                return(HamsterMove.DownRight);

            case 20:
                return(HamsterMove.UpRight);

            case 1:
                return(HamsterMove.Left);

            case 2:
                return(HamsterMove.DownLeft);

            case 0:
                return(HamsterMove.UpLeft);

            default:
                return(HamsterMove.None);
            }
        }
Example #5
0
        public long FindCornerProduct(string filePath)
        {
            Grid[,] overallMap = MakeCompositeMap(filePath);

            long cornerProduct = overallMap[0, 0].Id
                                 * overallMap[0, overallMap.GetLength(0) - 1].Id
                                 * overallMap[overallMap.GetLength(1) - 1, 0].Id
                                 * overallMap[overallMap.GetLength(0) - 1, overallMap.GetLength(1) - 1].Id;

            return(cornerProduct);
        }
Example #6
0
        public pathFinder(bool[,] bMap)
        {
            //read map
            map = new Grid[bMap.GetLength(0), bMap.GetLength(1)];

            for (int r = 0; r < map.GetLength(0); r++) {
                for (int c = 0; c < map.GetLength(1); c++) {
                    map[r, c] = new Grid();
                    map[r, c].Walkable = bMap[r, c];
                }
            }
        }
 public static bool Contains2D(Grid[,] arr2d, GridStatus value)
 {
     for (int i = 0; i < arr2d.GetLength(0); i++)
     {
         for (int j = 0; j < arr2d.GetLength(1); j++)
         {
             if (arr2d[i, j].gs.Equals(value))
             {
                 return(true);
             }
         }
     }
     return(false);
 }
Example #8
0
        /**
         * @return Return all node which surround the center point.
         */
        private static List <Node> Rounds(Node center, Grid[,] blocks, bool allowDiagonals)
        {
            var result = new List <Node>();

            if (blocks == null || blocks.Length <= 0)
            {
                return(result);
            }
            var centerX = center.X;
            var centerY = center.Y;

            if (allowDiagonals)
            {
                // 8 direction
                for (var i = centerX - 1; i <= centerX + 1; i++)
                {
                    //    row
                    for (var j = centerY - 1; j <= centerY + 1; j++)
                    {
//    column
                        if (centerX == i && centerY == j || i < 0 || i >= blocks.GetLength(0) || j < 0 ||
                            j >= blocks.GetLength(1))
                        {
                            continue;
                        }
                        result.Add(new Node(i, j, center));
                    }
                }
            }
            else
            {
                int[,] points =
                {
                    { centerX,     centerY - 1 }, //  up
                    { centerX,     centerY + 1 }, //  down
                    { centerX - 1, centerY     }, //  left
                    { centerX + 1, centerY     } //  right
                };
                for (var i = 0; i < points.GetLength(0); i++)
                {
                    if (IsOutOfBounds(points[i, 0], points[i, 1], blocks))
                    {
                        continue;
                    }
                    result.Add(new Node(points[i, 0], points[i, 1], center));
                }
            }
            return(result);
        }
Example #9
0
 public DialogResult Lose(int x, int y, int[,] CountMine, Grid[,] grid, FlagType[,] IsFlag)
 {
     grid[x - 1, y - 1].ReplaceMineClk();
     IsFlag[x - 1, y - 1] = FlagType.Open;
     for (int i = 0; i < grid.GetLength(0); i++)
     {
         for (int j = 0; j < grid.GetLength(1); j++)
         {
             if (CountMine[i + 1, j + 1] == -1 && IsFlag[i, j] == FlagType.None)
             {
                 grid[i, j].ReplaceMine();
             }
         }
     }
     return(MessageBox.Show("You Lose", "", MessageBoxButtons.RetryCancel));
 }
Example #10
0
    public Board(DiscPresenter prefab, SpriteRenderer marker)
    {
        _grids = new Grid[GRID_NUM, GRID_NUM];
        for (int j = 0; j < _grids.GetLength(1); j++)
        {
            for (int i = 0; i < _grids.GetLength(0); i++)
            {
                _grids[i, j] = new Grid(i, j);
            }
        }

        _pool       = new DiscPool(prefab);
        _markerPool = new MarkerPool(marker);

        _rentMarkers = new Queue <SpriteRenderer>(GRID_NUM * GRID_NUM);
    }
Example #11
0
 private void Update()
 {
     for (int i = 0; i < grids.GetLength(0); i++)
     {
         for (int j = 0; j < grids.GetLength(1); j++)
         {
             if (grids[i, j] != null)
             {
                 if (grids[i, j].GetComponent <Grid_Floor>() != null)
                 {
                     grids[i, j].GetComponent <Renderer>().material.color = grids[i, j].GetComponent <Grid_Floor>().HasPlayer() ? Color.yellow : floorColor;
                 }
             }
         }
     }
 }
Example #12
0
        public static Grid Combine(Grid[,] subgrids)
        {
            var subgridCount = subgrids.GetLength(0);
            var innerSize    = subgrids[0, 0].Size;
            var size         = subgridCount * innerSize;

            var content = new char[size, size];

            for (int i = 0; i < subgridCount; i++)
            {
                for (int j = 0; j < subgridCount; j++)
                {
                    for (int ii = 0; ii < innerSize; ii++)
                    {
                        for (int jj = 0; jj < innerSize; jj++)
                        {
                            content[i * innerSize + ii, j *innerSize + jj] = subgrids[i, j].content[ii, jj];
                        }
                    }
                }
            }

            return(new Grid {
                content = content
            });
        }
Example #13
0
 public void Draw()
 {
     for (int i = 0; i < grids.GetLength(0); i++)
     {
         for (int j = 0; j < grids.GetLength(1); j++)
         {
             Utils.WriteAt("+---+", (Game.GRID_CONSOLE_WIDTH - 1) * i, (Game.GRID_CONSOLE_HEIGHT - 1) * j);
             Utils.WriteAt("|", (Game.GRID_CONSOLE_WIDTH - 1) * i, (Game.GRID_CONSOLE_HEIGHT - 1) * j + 1);
             Utils.WriteAt("|", (Game.GRID_CONSOLE_WIDTH - 1) * (i + 1), (Game.GRID_CONSOLE_HEIGHT - 1) * j + 1);
             Utils.WriteAt("|", (Game.GRID_CONSOLE_WIDTH - 1) * i, (Game.GRID_CONSOLE_HEIGHT - 1) * j + 2);
             Utils.WriteAt("|", (Game.GRID_CONSOLE_WIDTH - 1) * (i + 1), (Game.GRID_CONSOLE_HEIGHT - 1) * j + 2);
             Utils.WriteAt("+---+", (Game.GRID_CONSOLE_WIDTH - 1) * i, (Game.GRID_CONSOLE_HEIGHT - 1) * (j + 1));
             grids[i, j].DrawContent((Game.GRID_CONSOLE_WIDTH - 1) * i + 1, (Game.GRID_CONSOLE_HEIGHT - 1) * j + 1);
         }
     }
 }
Example #14
0
    public GridMap(int width, int height)
    {
        this.width  = width;
        this.height = height;

        gridArray = new Grid[width, height];

        //fill grid array with empty grids
        for (int x = 0; x < gridArray.GetLength(0); x++)
        {
            for (int z = 0; z < gridArray.GetLength(1); z++)
            {
                gridArray[x, z] = new Grid((int)GridType.EMPTY);
            }
        }
    }
Example #15
0
        public static Grid transformAndMergeListOfGrids3D(Grid[,] array, int size)
        {
            var transformed = new Grid[size, size];

            for (int i = 0; i < array.GetLength(0); i++)
            {
                for (int j = 0; j < array.GetLength(1); j++)
                {
                    transformed[i, j] = _dic[array[i, j]];
                }
            }
            string finalPattern = String.Empty;

            var finalData = new int[size * 4, size * 4];

            for (int i = 0; i < size; i++)
            {
                for (int j = 0; j < size; j++)
                {
                    finalData[i * 4, j * 4]     = transformed[i, j].Data[0, 0];
                    finalData[i * 4, j * 4 + 1] = transformed[i, j].Data[0, 1];
                    finalData[i * 4, j * 4 + 2] = transformed[i, j].Data[0, 2];
                    finalData[i * 4, j * 4 + 3] = transformed[i, j].Data[0, 3];

                    finalData[i * 4 + 1, j * 4]     = transformed[i, j].Data[1, 0];
                    finalData[i * 4 + 1, j * 4 + 1] = transformed[i, j].Data[1, 1];
                    finalData[i * 4 + 1, j * 4 + 2] = transformed[i, j].Data[1, 2];
                    finalData[i * 4 + 1, j * 4 + 3] = transformed[i, j].Data[1, 3];

                    finalData[i * 4 + 2, j * 4]     = transformed[i, j].Data[2, 0];
                    finalData[i * 4 + 2, j * 4 + 1] = transformed[i, j].Data[2, 1];
                    finalData[i * 4 + 2, j * 4 + 2] = transformed[i, j].Data[2, 2];
                    finalData[i * 4 + 2, j * 4 + 3] = transformed[i, j].Data[2, 3];

                    finalData[i * 4 + 3, j * 4]     = transformed[i, j].Data[3, 0];
                    finalData[i * 4 + 3, j * 4 + 1] = transformed[i, j].Data[3, 1];
                    finalData[i * 4 + 3, j * 4 + 2] = transformed[i, j].Data[3, 2];
                    finalData[i * 4 + 3, j * 4 + 3] = transformed[i, j].Data[3, 3];
                }
            }

            //  Console.WriteLine(new Grid(finalData));
            //  Console.WriteLine(new Grid(finalData));
            return(new Grid(finalData));
        }
Example #16
0
        static bool[,] DetermineReservoirs(Grid[,] grid)
        {
            var reservoirs = new bool[grid.GetLength(0), grid.GetLength(1)];

            for (int y = grid.GetLength(1) - 2; y >= 0; y--)
            {
                for (int x = 1; x < grid.GetLength(0) - 1; x++)
                {
                    if (grid[x, y] == Grid.Sand)
                    {
                        if (grid[x - 1, y] == Grid.Sand)
                        {
                            reservoirs[x, y] = reservoirs[x - 1, y];
                        }
                        else
                        {
                            var right = -1;
                            for (int x2 = x + 1; x2 < grid.GetLength(0); x2++)
                            {
                                if (grid[x2, y] == Grid.Clay)
                                {
                                    right = x2;
                                    break;
                                }
                            }
                            if (right != -1)
                            {
                                var isReservoir = true;
                                for (int x2 = x; x2 < right; x2++)
                                {
                                    if (grid[x2, y + 1] == Grid.Sand && !reservoirs[x2, y + 1])
                                    {
                                        isReservoir = false;
                                        break;
                                    }
                                }
                                reservoirs[x, y] = isReservoir;
                            }
                        }
                    }
                }
            }
            return(reservoirs);
        }
Example #17
0
    //for each grid that is not blocked, generate a mosaic map for player to see
    public GameObject GenerateMosaicMap(GameObject mosaic)
    {
        GameObject ms = new GameObject("MosaicMap");

        for (int x = 0; x < gridArray.GetLength(0); x++)
        {
            for (int z = 0; z < gridArray.GetLength(1); z++)
            {
                if (!gridArray[x, z].isBlocked())
                {
                    Vector3    position = new Vector3(x, 0.06f, z);
                    GameObject m        = Object.Instantiate(mosaic, position, Quaternion.Euler(0, 180, 0));
                    m.transform.parent = ms.transform;
                }
            }
        }

        return(ms);
    }
Example #18
0
 static void FillGrid(Grid[,] grid, bool[,] reservoirs, int x, int y)
 {
     if (x < 0 || x >= grid.GetLength(0))
     {
         return;
     }
     if (y >= grid.GetLength(1))
     {
         return;
     }
     if (grid[x, y] == Grid.Clay)
     {
         return;
     }
     if (reservoirs[x, y])
     {
         if (grid[x, y] != Grid.Still)
         {
             grid[x, y] = Grid.Still;
             FillGrid(grid, reservoirs, x - 1, y);
             FillGrid(grid, reservoirs, x + 1, y);
             FillGrid(grid, reservoirs, x, y + 1);
         }
         return;
     }
     grid[x, y] = Grid.Flow;
     if (y < grid.GetLength(1) - 1)
     {
         FillGrid(grid, reservoirs, x, y + 1);
         if (grid[x, y + 1] == Grid.Clay || reservoirs[x, y + 1])
         {
             if (grid[x - 1, y] == Grid.Sand)
             {
                 FillGrid(grid, reservoirs, x - 1, y);
             }
             if (grid[x + 1, y] == Grid.Sand)
             {
                 FillGrid(grid, reservoirs, x + 1, y);
             }
         }
     }
 }
Example #19
0
        public Grid(Grid[,] grids)
        {
            Id = -1;

            _points = new List <char[]>();
            for (int gridRow = 0; gridRow < grids.GetLength(0); gridRow++)
            {
                for (int indRows = 0; indRows < grids[0, 0].Points.Count; indRows++)
                {
                    StringBuilder builder = new StringBuilder();
                    for (int gridCol = 0; gridCol < grids.GetLength(1); gridCol++)
                    {
                        builder.Append(grids[gridRow, gridCol].Points[indRows]).ToString();
                    }
                    _points.Add(builder.ToString().ToCharArray());
                }
            }

            Output();
        }
Example #20
0
        //function for rendering all grid in array
        public void Render(CDrawer canvas)
        {
            canvas.Clear();
            //creating instance before loop for preventing creating new instance during rendering
            Point temp = new Point(0, 0);

            for (int row = 0; row < arrayGrid.GetLength(0); row++)
            {
                for (int col = 0; col < arrayGrid.GetLength(1); col++)
                {
                    if (arrayGrid[row, col].live == Alive.alive)
                    {
                        //get the location of grid for rendering
                        temp = arrayGrid[row, col].position;

                        canvas.AddRectangle(temp.X, temp.Y, arrayGrid[row, col].size, arrayGrid[row, col].size, arrayGrid[row, col].color, 3, Color.Black);

                        canvas.Render();
                    }
                }
            }
        }
Example #21
0
        public long FindActivePixelsNotPartOfSeaMonster(string filePath)
        {
            Grid[,] overallMap = MakeCompositeMap(filePath);
            // Trim all
            for (int gridRow = 0; gridRow < overallMap.GetLength(0); gridRow++)
            {
                for (int gridCol = 0; gridCol < overallMap.GetLength(1); gridCol++)
                {
                    overallMap[gridRow, gridCol].TrimEdges();
                    overallMap[gridRow, gridCol].Output();
                }
            }
            Grid masterGrid   = new Grid(overallMap);
            int  mostMonsters = 0;

            // Go through all possibilities to find the most monsters
            for (int i = 0; i < 8; i++)
            {
                masterGrid.Output();

                int found = masterGrid.ContainsNumberOfSeaMonsters();
                if (found > mostMonsters)
                {
                    mostMonsters = found;
                }

                // Otherwise rotate/flip
                if (i == 3)
                {
                    masterGrid.FlipVertical();
                }

                masterGrid.Rotate();
            }

            long pixels = masterGrid.CountPixels();

            return(pixels - (mostMonsters * 15));
        }
Example #22
0
        public void QuickScanGrids()
        {
            if (GridRectangle == Rectangle.Empty)
            {
                throw new InvalidOperationException();
            }
            if (Grids == null)
            {
                throw new InvalidOperationException();
            }

            var captureLog = TimeLog.Stopwatch("Capture Grid");
            var bitmap     = GetCapture(GridRectangle);

            captureLog.Dispose();

            var readLog = TimeLog.Stopwatch("Read Grid");

            using (var integerMap = new IntegerMap(bitmap))
            {
                var gridCountX  = Grids.GetLength(0);
                var gridCountY  = Grids.GetLength(1);
                var gridIndexes = EnumerableUtil.Rectangle(gridCountX, gridCountY);
                foreach (var gridIndex in gridIndexes)
                {
                    var gridLocation = gridIndex.Multiply(Icons.Icon.RawGrid.IntegerMap.Size);
                    var gridIcon     = gridScanner.QuickRead(integerMap, gridLocation);
                    if (gridIcon == null)
                    {
                        throw new GameScanException("Scan grid failed");
                    }

                    var gridValue = MapGrid(gridIcon);
                    Grids[gridIndex.X, gridIndex.Y] = gridValue;
                }
            }
            readLog.Dispose();
        }
        void AssociateDoors()
        {
            int row = grids.GetLength(0);
            int col = grids.GetLength(1);

            for (int i = 0; i < row; ++i)
            {
                for (int j = 0; j < col; ++j)
                {
                    Grid grid  = GetGrid(i, j);
                    Grid up    = GetGrid(i - 1, j);
                    Grid down  = GetGrid(i + 1, j);
                    Grid left  = GetGrid(i, j - 1);
                    Grid right = GetGrid(i, j + 1);

                    if (up != null && CanAssociate(grid, grid.upDoor, up, up.downDoor))
                    {
                        grid.upDoor.Associate(up.downDoor);
                    }

                    if (down != null && CanAssociate(grid, grid.downDoor, down, down.upDoor))
                    {
                        grid.downDoor.Associate(down.upDoor);
                    }

                    if (left != null && CanAssociate(grid, grid.leftDoor, left, left.rightDoor))
                    {
                        grid.leftDoor.Associate(left.rightDoor);
                    }

                    if (right != null && CanAssociate(grid, grid.rightDoor, right, right.leftDoor))
                    {
                        grid.rightDoor.Associate(right.leftDoor);
                    }
                }
            }
        }
Example #24
0
    public int SearchPositionCanPutDisc(PlayerModel player)
    {
        int        canPutAmount = 0;
        Vector2Int pos          = Vector2Int.zero;

        while (_rentMarkers.Count > 0)
        {
            _markerPool.Return(_rentMarkers.Dequeue());
        }


        for (int j = 0; j < _grids.GetLength(1); j++)
        {
            for (int i = 0; i < _grids.GetLength(0); i++)
            {
                pos.x = i;
                pos.y = j;
                _grids[i, j].Init();
                if (IsExistDisc(pos))
                {
                    continue;
                }
                var result = SearchPositionAroundCanPutDisc(pos, player);
                if (result > 0)
                {
                    canPutAmount++;
                    var marker = _markerPool.Rent();
                    marker.transform.position = new Vector3(pos.x, pos.y, 0);
                    _rentMarkers.Enqueue(marker);
                    _grids[i, j].CanPutDisc = true;
                }
            }
        }

        return(canPutAmount);
    }
Example #25
0
 /// <summary>
 /// Populates the multidimensional array storing the grids class
 /// and instantiates a new class and assigns the appropriate variables
 /// </summary>
 private void PopulateGrid()
 {
     for (int x = 0; x < grids.GetLength(0); x++)
     {
         for (int y = 0; y < grids.GetLength(1); y++)
         {
             grids[x, y] = new Grid(Mark.None, new Tuple <int, int>(x, y));
             AssignWinningPositions(grids[x, y]);
         }
     }
 }
Example #26
0
 /**
  * Is point's position (x,y) out of tiled map's bounds.
  *
  * @return Return true if position out of bounds. otherwise false.
  */
 private static bool IsOutOfBounds(int x, int y, Grid[,] blocks)
 {
     return(x < 0 || x >= blocks.GetLength(0) || y < 0 || y >= blocks.GetLength(1));
 }
Example #27
0
 public A_Star(Grid[,] grids)
 {
     m_grids = grids;
     m_row   = m_grids.GetLength(0);
     m_col   = m_grids.GetLength(1);
 }
Example #28
0
        private RoyMove Moveto(int target_row, int target_col)
        {
            Random rand  = new Random();
            int    state = 11;

            if (target_row > row && row + 1 < envirment.GetLength(0) && envirment[row + 1, col].Value >= 0)
            {
                state += 10;
            }
            else if (target_row < row && row - 1 >= 0 && envirment[row - 1, col].Value >= 0)
            {
                state -= 10;
            }

            if (target_col > col && col + 1 < envirment.GetLength(1) && envirment[row, col + 1].Value >= 0)
            {
                state += 1;
            }
            else if (target_col < col && col - 1 >= 0 && envirment[row, col - 1].Value >= 0)
            {
                state -= 1;
            }

            switch (state)
            {
            case 11:
                return(RoyMove.None);

            case 12:
                return(RoyMove.Down);

            case 10:
                return(RoyMove.Up);

            case 21:
                return(RoyMove.Right);

            case 22:
                if (envirment[row + 1, col + 1].Value >= 0)
                {
                    return(RoyMove.DownRight);
                }
                else
                {
                    if (rand.Next(2) < 1)
                    {
                        return(RoyMove.Down);
                    }
                    else
                    {
                        return(RoyMove.Right);
                    }
                }

            case 20:
                if (envirment[row + 1, col - 1].Value >= 0)
                {
                    return(RoyMove.UpRight);
                }
                else
                {
                    if (rand.Next(2) < 1)
                    {
                        return(RoyMove.Up);
                    }
                    else
                    {
                        return(RoyMove.Right);
                    }
                }

            case 1:
                return(RoyMove.Left);

            case 2:
                if (envirment[row - 1, col + 1].Value >= 0)
                {
                    return(RoyMove.DownLeft);
                }
                else
                {
                    if (rand.Next(2) < 1)
                    {
                        return(RoyMove.Down);
                    }
                    else
                    {
                        return(RoyMove.Left);
                    }
                }

            case 0:
                if (envirment[row - 1, col - 1].Value >= 0)
                {
                    return(RoyMove.UpLeft);
                }
                else
                {
                    if (rand.Next(2) < 1)
                    {
                        return(RoyMove.Up);
                    }
                    else
                    {
                        return(RoyMove.Left);
                    }
                }

            default:
                return(RoyMove.None);
            }
        }
Example #29
0
        //---------------------------------------------------------------------
        public bool Load(string areaName, string levelName)
        {
            _currectArea  = areaName;
            _currectLevel = levelName;

            zeroOffset = Vector3.zero;

            _zeroPoint = GameObject.Find("ZeroPoint")?.transform;
            var ret = GridLoader.LoadGrid(_currectArea, _currectLevel, out rowStartGrids, out colStartGrids, out gridArray);

            blockMap = new int[gridArray.GetLength(0), gridArray.GetLength(1)];

            return(ret);
        }