示例#1
0
 public bool CheckCollisionWithBotWall(Shape shape, UnityEngine.Vector3 movementVector)
 {
     List<Coordinate> filledGridPositions = shape.GetCurrentGridPosition ();
                 foreach (Coordinate pos in filledGridPositions) {
                         if (Math.Abs (pos.row + movementVector.y) >= mRowCount)
                                 return true;
                 }
                 return false;
 }
示例#2
0
 public bool CheckCollisionWithRightWall(Shape shape, UnityEngine.Vector3 movementVector)
 {
     List<Coordinate> filledGridPositions = shape.GetCurrentGridPosition ();
                 foreach (Coordinate pos in filledGridPositions) {
                         if (pos.column + movementVector.x >= mColumnCount) {
                                 return true;
                         }
                 }
                 return false;
 }
示例#3
0
 public bool CheckCollisionWithTopWall(Shape shape, UnityEngine.Vector3 movementVector)
 {
     List<Coordinate> filledGridPositions = shape.GetCurrentGridPosition ();
                 foreach (Coordinate pos in filledGridPositions) {
                         if (pos.row + movementVector.y > 0) {
                                 return true;
                         }
                 }
                 return false;
 }
示例#4
0
 private void AddCurrentShapeToSceneBitGrid(Shape shape, bool val)
 {
     List<Coordinate> filledGridPositions = shape.GetCurrentGridPosition ();
                 foreach (Coordinate pos in filledGridPositions) {
                         mSceneGrid [pos.row, pos.column] = val;
                 }
                 mSceneGrid.UpdateRowBytes ();
 }
示例#5
0
        //Returns information on each sub-block of the passed in Shape
        public List<CellInformation> GetCellInformation(Shape s, UnityEngine.Vector3 movementVector)
        {
            List<CellInformation> neighbors = new List<CellInformation> ();
                        List<Coordinate> filledGridPositions = s.GetCurrentGridPosition ();
                        foreach (AssemblyCSharp.Coordinate rowCol in filledGridPositions) {
                                CellInformation info = new CellInformation ();
                                info.coordinate.row = rowCol.row + (int)movementVector.y;
                                info.coordinate.column = rowCol.column + (int)movementVector.x;
                                int rowCount = mRowCount * -1;

                                if (info.coordinate.row > 0 || info.coordinate.row <= rowCount || info.coordinate.column < 0 || info.coordinate.column >= mColumnCount)
                                        return null;

                                int right = info.coordinate.column + 1;
                                int left = info.coordinate.column - 1;
                                int up = info.coordinate.row + 1;
                                int down = info.coordinate.row - 1;
                                if (up <= 0 && mSceneGrid [up, info.coordinate.column] == true) {
                                        info.TopNeighborStatus = TetrisGridCellStatus.Filled;
                                }

                                if (right < mColumnCount && mSceneGrid [info.coordinate.row, right] == true) {
                                        info.RightNeighborStatus = TetrisGridCellStatus.Filled;
                                }
                                if (right == mColumnCount) //boost a little bit on the sides of scores don't clump in the middle
                                        info.RightNeighborStatus = TetrisGridCellStatus.Wall;
                                if (left >= 0 && mSceneGrid [info.coordinate.row, left] == true) {
                                        info.LeftNeighborStatus = TetrisGridCellStatus.Filled;
                                }
                                if (left == -1)
                                        info.LeftNeighborStatus = TetrisGridCellStatus.Wall;
                                if (down > rowCount && mSceneGrid [down, info.coordinate.column] == true) {
                                        info.BotNeighborStatus = TetrisGridCellStatus.Filled;
                                }
                                if (down > rowCount && mSceneGrid [down, info.coordinate.column] == false && filledGridPositions.Count (x => x.row == (rowCol.row - 1) && x.column == rowCol.column) == 0) {
                                        info.BotNeighborStatus = TetrisGridCellStatus.Open;
                                }
                                if (down == rowCount) {
                                        info.BotNeighborStatus = TetrisGridCellStatus.Wall;
                                }

                                neighbors.Add (info);
                        }
                        return neighbors;
        }
示例#6
0
 //These collision detection functions are made public so they can be accessed by the AI
 public bool DoAnyShapesCollideInScene(Shape shape, UnityEngine.Vector3 movementVector)
 {
     List<Coordinate> filledGridPositions = shape.GetCurrentGridPosition ();
                 foreach (Coordinate pos in filledGridPositions) {
                         if (mSceneGrid [pos.row + (int)movementVector.y, pos.column + (int)movementVector.x] == true)
                                 return true;
                 }
                 return false;
 }