예제 #1
0
파일: Board.cs 프로젝트: lebull/CheckEye
 /// <summary>
 /// Returns the BoardSquare at this position.  Returns null if the position isn't on the board.
 /// </summary>
 /// <param name="pos"></param>
 /// <returns></returns>
 public BoardSquare getSquare(BoardPosition pos)
 {
     if(!pos.inBoard)
     {
         return null;
     }
     return squareGrid[pos.horizontal, pos.vertical].GetComponent<BoardSquare>();
 }
예제 #2
0
        public BoardMove(BoardPiece movingPiece, 
                                BoardPosition destination,
                                List<BoardPiece> destroyedPieces = null, 
                                BoardPiece transformTo = null)
        {
            this.movingPiece = movingPiece;
            this.destination = destination;
            this.transformTo = transformTo;

            if (destroyedPieces == null)
            {
                this.destroyedPieces = new List<BoardPiece>();
            }
            else
            {
                this.destroyedPieces = destroyedPieces;
            }
        }
예제 #3
0
파일: Board.cs 프로젝트: lebull/CheckEye
        public List<BoardPiece> allPieces()
        {
            List<BoardPiece> returnList = new List<BoardPiece>();
            for (int horz = 0; horz < GRIDSIZE; horz++)
            {
                for (int vert = 0; vert < GRIDSIZE; vert++)
                {
                    BoardPosition boardPosition = new BoardPosition(horz, vert);
                    if (getSquare(boardPosition).occupied)
                    {
                        returnList.Add(getSquare(boardPosition).gamePiece);
                    }

                }
            }

            return returnList;
        }
예제 #4
0
 //TODO: This should move the piece if it already has a nonequivilant boardPosition
 public void setBoardPosition(BoardPosition pos)
 {
     _boardPosition = pos;
     string newName = string.Format("BoardSquare ({0}, {1})", pos.horizontal, pos.vertical);
     transform.name = newName;
 }
예제 #5
0
파일: Board.cs 프로젝트: lebull/CheckEye
 /// <summary>
 /// Returns true if the square has a gamepiece.
 /// </summary>
 /// <param name="pos"></param>
 /// <returns></returns>
 public bool isPositionIsOccupied(BoardPosition pos)
 {
     if (!pos.inBoard)
     {
         return false;
     }
     return getSquare(pos).occupied;
 }
예제 #6
0
파일: Board.cs 프로젝트: lebull/CheckEye
        private void spawnBoardSquares()
        {
            //Spawn boardSquares.
            //GameObject blackSquarePrefab = Resources.Load<GameObject>("Prefabs/BlackSquare");
            //GameObject whiteSquarePrefab = Resources.Load<GameObject>("Prefabs/WhiteSquare");

            GameObject newSquarePrefab = new GameObject();
            newSquarePrefab.transform.localScale = new Vector3(1 / GRIDSIZE * PLANESCALE, 0.5f, 1 / GRIDSIZE * PLANESCALE);
            newSquarePrefab.AddComponent<BoardSquare>();
            newSquarePrefab.name = "BoardSquare";
            newSquarePrefab.AddComponent<BoxCollider>();
            newSquarePrefab.layer = LayerMask.NameToLayer("BoardSquare");

            squareGrid = new GameObject[GRIDSIZE, GRIDSIZE];

            //Spawn our grid
            float separation = squarewidth;
            Vector3 squareScale = new Vector3(
                separation,
                newSquarePrefab.transform.localScale.y * transform.localScale.y,
                separation
                );

            //1 to 8
            for (int vertical_index = 0; vertical_index < GRIDSIZE; vertical_index++)
            {
                //a to h
                for (int horizontal_index = 0; horizontal_index < GRIDSIZE; horizontal_index++)
                {
                    //This should be local to this.transform
                    Vector3 spawnPosition = new Vector3(
                        (horizontal_index - (GRIDSIZE / 2)) * separation + separation / 2,
                        0,
                        (vertical_index - (GRIDSIZE / 2)) * separation + separation / 2
                        );

                    GameObject newSquare = (GameObject)Instantiate(newSquarePrefab, transform.position + spawnPosition, transform.rotation);
                    squareGrid[horizontal_index, vertical_index] = newSquare;
                    BoardPosition newBoardPosition = new BoardPosition(horizontal_index, vertical_index);
                    newSquare.transform.localScale = squareScale;
                    newSquare.transform.parent = transform;
                    newSquare.GetComponent<BoardSquare>().setBoardPosition(newBoardPosition);
                }
            }
        }