Esempio n. 1
0
        public static CollisionType Check(GameObject cube, Direction direction, Grid grid)
        {
            int xPos  = (int)GridTools.GridPosition(cube.transform.position).x;
            int yPos  = (int)GridTools.GridPosition(cube.transform.position).y;
            int nextX = (int)direction.DirectionToVector().x;
            int nextY = (int)direction.DirectionToVector().y;

            if (xPos + nextX < Grid.gridWidth && xPos + nextX >= 0 && yPos + nextY < Grid.gridHeight && yPos + nextY >= 0)
            {
                for (int y = 0; y < Grid.gridHeight; y++)
                {
                    for (int x = 0; x < Grid.gridWidth; x++)
                    {
                        if (grid.Cells[xPos + nextX, yPos + nextY] == 1)
                        {
                            return(CollisionType.Stone);
                        }
                    }
                }
            }
            else
            {
                return(CollisionType.GridEdge);
            }
            return(CollisionType.None);
        }
Esempio n. 2
0
File: Grid.cs Progetto: qiwi92/Elara
        public bool IsInGrid(Vector3 currentPos)
        {
            int xPosOnGrid = (int)GridTools.GridPosition(currentPos).x;
            int yPosOnGrid = (int)GridTools.GridPosition(currentPos).y;

            if (xPosOnGrid > gridWidth || xPosOnGrid < 0)
            {
                return(false);
            }
            if (yPosOnGrid > gridHeight || yPosOnGrid < 0)
            {
                return(false);
            }
            return(true);
        }