Пример #1
0
    void Start()
    {
        BoardTile[,] spPuzzle1Board =
        {
            { BoardTile.Path(false,  true),  BoardTile.Empty(),   BoardTile.Path(false,   true)  },
            { BoardTile.Target(true, true),  BoardTile.Path(true, false),                 BoardTile.Path(false, true)},
            { BoardTile.Path(false,  true),  BoardTile.Empty(),   BoardTile.Target(false, true)  },
            { BoardTile.Target(true, true),  BoardTile.Path(true, false),                 BoardTile.Path(false, true)},
            { BoardTile.Path(false,  false), BoardTile.Empty(),   BoardTile.Path(false,   false) },
        };

        BoardPillar[] spPuzzle1Pillars =
        {
            BoardPillar.Key(0,     0),
            BoardPillar.Key(0,     2),
            BoardPillar.Key(4,     0),
            BoardPillar.Regular(4, 2)
        };

        BoardTile[,] spPuzzle2Board =
        {
            { BoardTile.Empty(),      BoardTile.Path(false, true),                BoardTile.Empty() },
            { BoardTile.Path(true,    true),                BoardTile.Path(true,  true), BoardTile.Path(false, true)},
            { BoardTile.Target(false, true),                BoardTile.Path(false, true), BoardTile.Path(false, true)},
            { BoardTile.Path(false,   true),                BoardTile.Path(false, true), BoardTile.Path(false, true)},
            { BoardTile.Path(true,    false),               BoardTile.Path(true,  true), BoardTile.Path(true, false)},
            { BoardTile.Empty(),      BoardTile.Path(false, false),               BoardTile.Empty() },
        };

        spPuzzle1 = gameObject.GetComponent <SlidingPillars>();
        spPuzzle1.SetBoard(spPuzzle1Board);
        spPuzzle1.SetPillars(spPuzzle1Pillars);
        spPuzzle1.Generate();
    }
Пример #2
0
 //Use this for preinitialization
 public void Awake()
 {
     //Initalize the gridOutline
     gridOutline = new BoardTile[boardSize, boardSize];
     enemyOutline = new EnemyTile[boardSize, boardSize];
     boardCodes = new int[boardSize, boardSize];
 }
Пример #3
0
    /// <summary>
    /// Initializes the board.
    /// </summary>
    /// <param name="dimensions">The dimensions of the board. The length of a square side.</param>
    /// <param name="position">The position of this board in the world.</param>
    /// <param name="owner">The owner of this board.</param>
    /// <param name="gridMaterial">The material used to render the grid.</param>
    public void Initialize(int dimensions, Vector3 position, Player owner, Material gridMaterial)
    {
        tiles = new BoardTile[dimensions, dimensions];

        for (int x = 0; x < dimensions; x++)
        {
            for (int y = 0; y < dimensions; y++)
            {
                tiles[x, y] = new GameObject("Tile X: " + x + " Y: " + y).AddComponent <BoardTile>();
                tiles[x, y].transform.position = -new Vector3(1f, 0, 1f) * ((float)dimensions / 2f + 0.5f) + new Vector3(x + 1, 0f, y + 1);
                tiles[x, y].transform.parent   = this.transform;
                tiles[x, y].boardCoordinates   = new Vector2(x, y);
                tiles[x, y].board = this;
            }
        }

        //this.position = position;
        this.transform.position = position;
        this.transform.parent   = owner.transform;
        this.owner = owner;


        this.dimensions   = dimensions;
        this.gridMaterial = gridMaterial;

        //gridRendered = true;
        Set(BoardState.DISABLED);
    }
Пример #4
0
    void Awake()
    {
        GameObject container = new GameObject();

        container.transform.SetParent(transform);
        container.name = "Tiles";
        tilesPool      = new GameObjectPool(tilePrefab, maxTilesCount, container);
        tiles          = new BoardTile[maxTilesCount, maxTilesCount];
        boardGOs       = new GameObject[maxTilesCount, maxTilesCount];

        // allocate enough pieces to fill the board, and a second lot so things can animate, like if we want to clear the board and animate a new lot of pieces coming in
        container = new GameObject();
        container.transform.SetParent(transform);
        container.name = "Pieces";
        piecesPool     = new GameObjectPool(piecePrefab, maxTilesCount * 2, container);

        // waiters
        for (int i = 0; i < removeWaiterArraySize; i++)
        {
            removeTileDelayWaiters[i] = new WaitForSeconds(Mathf.SmoothStep(removeTileDelayMax, removeTileDelayMin, (float)i / (float)removeWaiterArraySize));
        }

        // Sounds
        for (int i = 0; i < 12; i++)
        {
            AudioSource source = gameObject.AddComponent <AudioSource>();
            randomPitchSources.Add(source);
            source.pitch = Random.Range(0.9f, 1.3f);
        }

        gameObject.SetActive(false);
    }
Пример #5
0
    private void InitializeBoard()
    {
        boardTiles = new BoardTile[width, height];

        for (int j = 0; j < height; j++)
        {
            for (int i = 0; i < width; i++)
            {
                bool isWalkable = true;

                if (j == 0 || j == height - 1 || Random.Range(0, 3) == 0)
                {
                    isWalkable = false;
                }

                boardTiles[i, j] = new BoardTile(i, j, isWalkable);

                if (i > 0)
                {
                    boardTiles[i, j].Neighbors.Add(boardTiles[i - 1, j]);
                    boardTiles[i - 1, j].Neighbors.Add(boardTiles[i, j]);
                }

                if (j > 0)
                {
                    boardTiles[i, j].Neighbors.Add(boardTiles[i, j - 1]);
                    boardTiles[i, j - 1].Neighbors.Add(boardTiles[i, j]);
                }
            }
        }

        Player.Instance.currentTile = boardTiles[0, 1];
    }
Пример #6
0
    private void CreateBoard(Vector2 offset, Vector2 baseSpaw)
    {
        board = new BoardTile[rows, columns];

        //Create frame
        if (framePrefab != null)
        {
            SpriteRenderer frame = Instantiate(framePrefab,
                                               new Vector3(transform.position.x,
                                                           transform.position.y,
                                                           0f),
                                               framePrefab.transform.rotation);

            frame.transform.SetParent(tilesParent.transform);

            frame.transform.localScale = new Vector2(columns + 0.3f, rows + 0.3f);
        }

        for (int i = 0; i < rows; i++)
        {
            for (int j = 0; j < columns; j++)
            {
                BoardTile tile = Instantiate(tilePrefab,
                                             new Vector3(baseSpaw.x + (offset.x * j),
                                                         baseSpaw.y + (offset.y * i),
                                                         0f),
                                             tilePrefab.transform.rotation);

                tile.transform.SetParent(tilesParent.transform);

                board[i, j] = tile;
                board[i, j].InitializeBoardTile(i, j);
            }
        }
    }
Пример #7
0
        /// <summary>
        /// Generates the game board
        /// </summary>
        /// <param name="row"></param>
        /// <param name="colum"></param>
        private void Createboard(int row, int column)
        {
            //Creates a new tileset size row x column
            _gameBoard = new BoardTile[row, column];

            for (int r = row - 1; r >= 0; r--)
            {
                for (int c = column - 1; c >= 0; c--)
                {
                    BoardTile tile = new BoardTile(r, c);
                    tile.Terrain = SquareTerrain.Grass;

                    if (r == row - 1)
                    {
                        tile.State   = SquareStatus.Enemy;
                        tile.Terrain = SquareTerrain.Woods;
                        _enemyUnits++;
                    }
                    else if (r == row - row)
                    {
                        tile.State   = SquareStatus.Player;
                        tile.Terrain = SquareTerrain.Woods;
                        _playerUnits++;
                    }
                    else
                    {
                        tile.State   = SquareStatus.None;
                        tile.Terrain = SquareTerrain.Grass;
                    }
                    _gameBoard[r, c] = tile;
                }
            }
        }
Пример #8
0
 protected override void Awake()
 {
     base.Awake();
     if (this.SkipRegen)
     {
         this.Tiles = new BoardTile[this.width, this.height];
         List <GameObject> children = this.gameObject.transform.GetChildren();
         Debug.Log("Found " + children.Count + " children");
         foreach (GameObject d in children)
         {
             BoardTile bt = d.GetComponent <BoardTile>();
             if (bt)
             {
                 bt.ColorManager.ChangeColor(Color.black);
                 this.Tiles[bt.x, bt.y] = bt;
             }
             else
             {
                 Debug.Log("Non-BT child found.");
             }
         }
         return;
     }
     this.DeleteAllChildren();
     this.GenerateBoard();
 }
Пример #9
0
 public MiniMax(int size, int Sequance)
 {
     BoardState    = new BoardTile[size, size];
     RowsEval      = new int[size];
     ColsEval      = new int[size];
     DiagsEval     = new int[2];
     this.Sequance = Sequance;
 }
Пример #10
0
        /// <summary>
        /// Function that handles a mouse click action
        /// </summary>
        /// <param name="mouseX">X position of the mouse</param>
        /// <param name="mouseY">Y position of the mouse</param>
        private void handleMouseAction(int mouseX, int mouseY)
        {
            //Make a rectangle for the mouse click size of 1 pixel
            Rectangle mouseClick = new Rectangle(mouseX, mouseY, 1, 1);

            //Below handles the event of when the black button is pressed
            if (mouseClick.Intersects(blackButton))
            {
                newGame(PieceColor.Black);
            }
            //Below handles the event of when the white button is pressed
            else if (mouseClick.Intersects(whiteButton))
            {
                newGame(PieceColor.White);
            }
            //Below handles any clicking of checkers pieces or board tiles
            else if (currentState.winner == PieceColor.None && currentState.turnColor != PieceColor.None)
            {
                bool clickablePlace = false;
                foreach (CheckersPiece gamePiece in currentState.moveablePieces)
                {
                    if (gamePiece.intersects(mouseClick) == true)
                    {
                        clickablePlace = true;
                        currentState.doGamePieceAction(gamePiece);
                        break;
                    }
                }
                BoardTile[,] tiles = currentState.gameBoard.getTiles();
                for (int x = 0; x < CheckersBoard.MAX_HORIZONTAL_TILES; x++)
                {
                    for (int y = 0; y < CheckersBoard.MAX_VERTICAL_TILES; y++)
                    {
                        if (tiles[x, y].intersects(mouseClick) == true)
                        {
                            clickablePlace = true;
                            if (currentState.doTileAction(tiles[x, y]) == true)
                            {
                                currentState.activeGamePiece.Update(currentState);
                                break;
                            }
                        }
                    }
                    if (clickablePlace == true)
                    {
                        break;
                    }
                }
                if (clickablePlace == false)
                {
                    currentState.gameBoard.clearMarkings();
                }
            }
        }
Пример #11
0
    void BuildBoard()
    {
        // move to center of screen
        transform.position = -(Vector2)Dimensions / 2 + Vector2.one / 2;

        // create 2D array for tiles
        _tiles = new BoardTile[Dimensions.x, Dimensions.y];

        // fill the board
        FillEmptySpaces();
    }
Пример #12
0
 public Board()
 {
     _board = new BoardTile[RowColLen, RowColLen];
     for (int i = 0; i < RowColLen; i++)
     {
         for (int j = 0; j < RowColLen; j++)
         {
             _board[i, j] = new BoardTile(new PiecePosition(i, j));
         }
     }
 }
Пример #13
0
    void ListPossibleMoves()
    {
        board = null;
        pieces.Clear();

        board = Board.instance.GetBoard();
        listAvaliableMoves = new List <AIMoviment>();

        //checking dark pieces
        for (int i = 0; i < board.GetLength(0); i++)
        {
            for (int j = 0; j < board.GetLength(1); j++)
            {
                if (board[i, j].currentPiece == null)
                {
                    continue;
                }

                if (board[i, j].currentPiece.CheckPieceType(PieceTypes.Black))
                {
                    pieces.Add(board[i, j].currentPiece);
                }
            }
        }
        //list possible piece moves
        for (int i = 0; i < pieces.Count; i++)
        {
            //getting piece tile coordinates
            int actualRow = pieces[i].currentTile.row;
            int actualCol = pieces[i].currentTile.column;

            if (pieces[i].IsKing()) //if the actual piece is a king
            {
                //checking diagonals
                bool downRight = AIKingTile(pieces[i], actualRow + 1, actualCol + 1, 1, 1, PieceTypes.Black);
                bool downLeft  = AIKingTile(pieces[i], actualRow + 1, actualCol - 1, 1, -1, PieceTypes.Black);
                bool upRight   = AIKingTile(pieces[i], actualRow - 1, actualCol + 1, -1, 1, PieceTypes.Black);
                bool upLeft    = AIKingTile(pieces[i], actualRow - 1, actualCol - 1, -1, -1, PieceTypes.Black);
            }
            else
            {
                if (pieces[i].IsDownMoviment())
                {
                    bool upRight = AIBoardTile(pieces[i], actualRow - 1, actualCol + 1, -1, 1, PieceTypes.Black);
                    bool upLeft  = AIBoardTile(pieces[i], actualRow - 1, actualCol - 1, -1, -1, PieceTypes.Black);
                }
                else
                {
                    bool downRight = AIBoardTile(pieces[i], actualRow + 1, actualCol + 1, 1, 1, PieceTypes.Black);
                    bool downLeft  = AIBoardTile(pieces[i], actualRow + 1, actualCol - 1, 1, -1, PieceTypes.Black);
                }
            }
        }
    }
Пример #14
0
 public FallLogic(
     Vector3 boardPosition,
     SGridCoords boardSize,
     BoardTile[,] boardTiles,
     float fallSpeed)
 {
     _BoardPosition = boardPosition;
     _BoardSize     = boardSize;
     _BoardTiles    = boardTiles;
     _FallSpeed     = fallSpeed;
     _LinkerObjects = new LinkerObject[_BoardSize._Column, _BoardSize._Row];
 }
Пример #15
0
 public void GenerateTiles()
 {
     Debug.Log("Called GenerateTiles");
     tiles = new BoardTile[size.x, size.z];
     for (int x = 0; x < size.x; x++)
     {
         for (int z = 0; z < size.z; z++)
         {
             CreateTile(new IntVector2(x, z), emptyTilePrefab, TileType.Empty, 1);
         }
     }
 }
Пример #16
0
 /// <summary>
 /// Copy constructor for the checkers board.
 /// This constructor is used for creating temporary states used in the AI.
 /// </summary>
 /// <param name="board">A board to copy</param>
 public CheckersBoard(CheckersBoard board)
 {
     tiles = new BoardTile[6, 6];
     for (int x = 0; x < MAX_HORIZONTAL_TILES; x++)
     {
         for (int y = 0; y < MAX_VERTICAL_TILES; y++)
         {
             BoardTile copyTile = board.tiles[x, y];
             tiles[x, y] = new BoardTile(copyTile);
         }
     }
 }
Пример #17
0
        /// <summary>
        /// Generate the chess board.
        /// </summary>
        public void GenerateBoard()
        {
            Tiles = new BoardTile[BoardSize, BoardSize];

            for (int y = 0; y < BoardSize; y++)
            {
                for (int x = 0; x < BoardSize; x++)
                {
                    Tiles[y, x] = new BoardTile(x, y);
                }
            }
        }
Пример #18
0
 public GameBoard(int rows, int columns)
 {
     Id       = Guid.NewGuid();
     tileGrid = new BoardTile[rows, columns];
     foreach (int rowNum in Enumerable.Range(0, rows))
     {
         foreach (int colNum in Enumerable.Range(0, columns))
         {
             BoardTile tile = new BoardTile(rowNum, colNum);
             tileGrid[rowNum, colNum] = tile;
         }
     }
 }
Пример #19
0
    public void Generate()
    {
        CalcStartPos();

        board = new BoardTile[rows, cols];
        for (int r = 0; r < rows; r++)
        {
            for (int c = 0; c < cols; c++)
            {
                CreateTile(r, c);
            }
        }
    }
Пример #20
0
 public LinkerLogic(
     Vector3 boardPosition,
     SGridCoords boardSize,
     BoardTile[,] boardTiles,
     float fallSpeed)
 {
     _FallLogic = new FallLogic(
         boardPosition,
         boardSize,
         boardTiles,
         fallSpeed
         );
 }
Пример #21
0
        /// <summary>
        /// Default constructor for the checkers board
        /// </summary>
        public CheckersBoard()
        {
            position = Vector2.Zero;
            tiles    = new BoardTile[6, 6];

            for (int x = 0; x < MAX_HORIZONTAL_TILES; x++)
            {
                for (int y = 0; y < MAX_VERTICAL_TILES; y++)
                {
                    Vector2 tilePosition = new Vector2(x, y);
                    tiles[x, y] = new BoardTile(tilePosition);
                }
            }
        }
Пример #22
0
        public Board(Texture2D spriteSheet)
        {
            Sprites = spriteSheet;

            boardRecs = new BoardTile[8, 8];

            for (int i = 0; i < 8; i++)
            {
                for (int j = 0; j < 8; j++)
                {
                    boardRecs[i, j] = new BoardTile(i, j, new Rectangle(i * S_LENGTH, j * S_LENGTH, S_LENGTH, S_LENGTH));
                }
            }
        }
Пример #23
0
    //finds closest possible target
    public BoardTile FindTarget(BoardTile[,] map, ChessPiece caster, bool ally)
    {
        ChessPiece        currentTarget         = null;
        float             currentTargetDistance = 0;
        List <ChessPiece> Targets = new List <ChessPiece>();

        //loop will find all available chess pieces to target
        for (int i = 0; i < 8; i++)
        {
            for (int j = 0; j < 8; j++)
            {
                if (!ally)
                {
                    if (map[i, j].CurrentPiece != caster && map[i, j].CurrentPiece != null && caster.isEnemy != map[i, j].CurrentPiece.isEnemy)
                    {
                        Targets.Add(map[i, j].CurrentPiece);
                    }
                }
                else
                {
                    if (map[i, j].CurrentPiece != caster && map[i, j].CurrentPiece != null && caster.isEnemy == map[i, j].CurrentPiece.isEnemy)
                    {
                        Targets.Add(map[i, j].CurrentPiece);
                    }
                }
            }
        }

        //will determine closest piece
        foreach (ChessPiece x in Targets)
        {
            float Distance = Mathf.Sqrt(Mathf.Pow((caster.CurrentBlock.CurrentX - x.CurrentBlock.CurrentX), 2) + Mathf.Pow((caster.CurrentBlock.CurrentZ - x.CurrentBlock.CurrentZ), 2));

            if (currentTarget == null)
            {
                currentTarget         = x;
                currentTargetDistance = Distance;
            }
            else
            {
                if (Distance < currentTargetDistance)
                {
                    currentTarget         = x;
                    currentTargetDistance = Distance;
                }
            }
        }
        return(currentTarget.CurrentBlock);
    }
Пример #24
0
    public BoardTile Pathfinding(BoardTile[,] map, BoardTile casterLocation, BoardTile targetLocation, int range)
    {
        BoardTile currentTarget         = null;
        float     currentTargetDistance = 0;
        //finds all possible tiles within range of target
        List <BoardTile> possible = new List <BoardTile>();
        int casterX = casterLocation.CurrentX;
        int casterZ = casterLocation.CurrentZ;

        int targetX = targetLocation.CurrentX;
        int targetZ = targetLocation.CurrentZ;

        for (int i = targetX - range; i <= targetX + range; i++)
        {
            if (i >= 0 && i < 8)
            {
                for (int j = targetZ - range; j <= targetZ + range; i++)
                {
                    if (j >= 0 && j < 8)
                    {
                        if (map[i, j] != targetLocation)
                        {
                            possible.Add(map[i, j]);
                        }
                    }
                }
            }
        }
        foreach (BoardTile x in possible)
        {
            float Distance = Mathf.Sqrt(Mathf.Pow((casterX - targetX), 2) + Mathf.Pow((casterZ - targetZ), 2));

            if (currentTarget == null)
            {
                currentTarget         = x;
                currentTargetDistance = Distance;
            }
            else
            {
                if (Distance < currentTargetDistance)
                {
                    currentTarget         = x;
                    currentTargetDistance = Distance;
                }
            }
        }
        return(currentTarget);
    }
Пример #25
0
    void Start()
    {
        gameObject.transform.position += Layouts.GetBoardPos();
        Layouts.UpdateCameraZoom();

        BoardTile[,] boardTiles = SpawnBackgroundTiles();

        _LinkerLogic = new LinkerLogic(
            gameObject.transform.position,
            new SGridCoords(LevelSettings.Instance.BoardWidth, LevelSettings.Instance.BoardHeight),
            boardTiles,
            _FallSpeed
            );
        _LinkerLogic.SetSpawners(SpawnLinkerSpawners());
        _LinkerLogic.Initialize();
    }
Пример #26
0
    //instantiates Tiles
    void Awake()
    {
        int numTiles = (leftOffset + rightOffset) * (downOffset + upOffset);

        holes = Mathf.Min(holes, numTiles);
        walls = Mathf.Min(walls, numTiles - holes);

        boardArray = new BoardTile[leftOffset + rightOffset, downOffset + upOffset];
        tileArray  = new GameObject[leftOffset + rightOffset, downOffset + upOffset];
        // i is width offset, j is height offset, i.e. # of tiles
        //(i,j) corresponds to tile with southwest corner being (i,j) * tileScale

        for (int i = -leftOffset; i < rightOffset; i++)
        {
            for (int j = -downOffset; j < upOffset; j++)
            {
                //center of the tile position
                float xPos = (i + 0.5f) * tileScale;
                float yPos = (j + 0.5f) * tileScale;

                int x_index = i + leftOffset;
                int y_index = j + downOffset;

                //10/27 changed implementation to have all board tiles simply be accessible by everyone by default
                //bool leftPlayer = (i < 0);

                boardArray[x_index, y_index] = new BoardTile(x_index, y_index, xPos, yPos, 2, true);

                //if (leftPlayer){
                tileArray[x_index, y_index] = Instantiate(DefaultTile, new Vector3(xPos, yPos, 0), Quaternion.identity);
                //} else {
                //    Instantiate(RightTile, new Vector3(xPos, yPos, 0), Quaternion.identity);
                //}
            }
        }

        control = GameObject.Find("GameManager").GetComponent <GameManager>();
        //lPlayer = GameObject.Find("LeftPlayer").GetComponent<Player>();
        //rPlayer = GameObject.Find("RightPlayer").GetComponent<Player>();

        leftPlayerTile  = PositionToTile(lPStartingLoc);
        rightPlayerTile = PositionToTile(rPStartingLoc);

        //i think 1/8 tiles being a hole, 1/8 tiles being a wall is good?
        //this is assuming 4x8 = 32 total tiles, so 8 are obstacles
        generateHoles_Walls(holes, walls);
    }
Пример #27
0
        /// <summary>
        /// Transposes an array (turns rows to columns and columns to rows).
        /// </summary>
        /// <param name="boardArray">Original untransposed array.</param>
        /// <returns></returns>
        public BoardTile[,] Transpose2DArray(BoardTile[,] boardArray)
        {
            int w = boardArray.GetLength(0);
            int h = boardArray.GetLength(1);

            BoardTile[,] result = new BoardTile[h, w];

            for (int i = 0; i < w; i++)
            {
                for (int j = 0; j < h; j++)
                {
                    result[j, i] = boardArray[i, j];
                }
            }

            return(result);
        }
Пример #28
0
        public GeneratedMove(bool isHorizontal, int startIndex, int endIndex, int[] anchor, Dictionary <BoardTile, CharTile> tilesUsed, BoardTile[,] boardBeforeMove, Rack rack)
        {
            IsHorizontal             = isHorizontal;
            StartIndex               = startIndex;
            EndIndex                 = endIndex;
            Anchor                   = anchor;
            TilesUsed                = tilesUsed;
            Word                     = GetWord();
            BoardBeforeMove          = new BoardTile[boardBeforeMove.GetLength(0), boardBeforeMove.GetLength(1)];
            RackTilesUsedCoordinates = new List <int[]>();
            ExtraWordsPlayed         = new List <List <BoardTile> >();

            //Creates a copy of the original board before move generation
            //Used to get the scores of it and words connected.
            for (int i = 0; i < BoardBeforeMove.GetLength(0); i++)
            {
                for (int j = 0; j < BoardBeforeMove.GetLength(1); j++)
                {
                    BoardBeforeMove[i, j] = new BoardTile
                    {
                        BoardLocationX = boardBeforeMove[i, j].BoardLocationX,
                        BoardLocationY = boardBeforeMove[i, j].BoardLocationY,
                        BoardTileType  = boardBeforeMove[i, j].BoardTileType,
                        CharTile       = boardBeforeMove[i, j].CharTile,
                        IsFilled       = boardBeforeMove[i, j].IsFilled
                    };
                    foreach (var tileUsed in TilesUsed)
                    {
                        if (BoardBeforeMove[i, j].BoardLocationX == tileUsed.Key.BoardLocationX &&
                            BoardBeforeMove[i, j].BoardLocationY == tileUsed.Key.BoardLocationY &&
                            BoardBeforeMove[i, j].CharTile == null)
                        {
                            RackTilesUsedCoordinates.Add(new int[] { i, j });
                            BoardBeforeMove[i, j].CharTile = tileUsed.Value;
                        }
                    }
                }
            }
            BoardAfterMove = BoardBeforeMove;
            Score          = GetScore();
            Rack           = new Rack {
                Rack_CharTiles = new List <Rack_CharTile>(rack.Rack_CharTiles)
            };
            RackScore = GetRackScore(Rack);
        }
Пример #29
0
        public void LaySquareBoard(Vector2 dimensions, int tileSize)
        {
            boardShape = BoardShape.Square;
            MakeHitbox(new Vector2(0, 0), HitboxShape.Rectangle, new Vector3(dimensions.X * tileSize, dimensions.Y * tileSize, 0));
            boardTiles = new BoardTile[(int)dimensions.X, (int)dimensions.Y];
            int xPos = (int)((-dimensions.X / 2) * tileSize + tileSize / 2);

            for (int x = 0; x < dimensions.X; x++)
            {
                int yPos = (int)((-dimensions.Y / 2) * tileSize + tileSize / 2);
                for (int y = 0; y < dimensions.Y; y++)
                {
                    MakeBoardTileSquare(x, y, xPos, yPos, tileSize);
                    yPos += tileSize;
                }
                xPos += tileSize;
            }
        }
Пример #30
0
    void Awake()
    {
        //construct board if there is no board
        if (tileBoard == null)
        {
            tileBoard = new BoardTile[sizeY, sizeX];

            for (int y = 0; y < sizeY; ++y)
            {
                for (int x = 0; x < sizeX; ++x)
                {
                    tileBoard[y, x] = Instantiate(TilePrefab, new Vector3(this.transform.position.x + x, this.transform.position.y + y), transform.rotation, this.transform).GetComponent <BoardTile>();
                    tileBoard[y, x].setBoard(this);
                    tileBoard[y, x].name = (string)(x + "_" + y);
                }
            }
        }
    }
Пример #31
0
        // --------------------------------------------------------------------------------------------
        public Board(Game game, int width, int height) : base("Board")
        {
            _game       = game;
            this.width  = width;
            this.height = height;

            _tiles = new BoardTile[width, height];
            for (int x = 0; x < width; x++)
            {
                for (int y = 0; y < height; y++)
                {
                    BoardTile boardTile = new BoardTile(x, y);
                    AddChild(boardTile);
                    _tiles[x, y] = boardTile;
                }
            }

            _groundPlane = new Plane(Vector3.up, Vector3.zero);
        }
Пример #32
0
    // Use this for initialization
    void Start()
    {
        baselineX = GameBoardTile.transform.position.x;
        baselineY = GameBoardTile.transform.position.y;

        boardTiles = new BoardTile[BOARD_HEIGHT, BOARD_WIDTH];

        boardTileWidth  = (GameBoardSpriteDull.bounds.max - GameBoardSpriteDull.bounds.min).x;
        boardTileHeight = (GameBoardSpriteDull.bounds.max - GameBoardSpriteDull.bounds.min).y;
        //Create starting tile
        for (int i = 0; i < BOARD_WIDTH; i++)
        {
            for (int j = 0; j < BOARD_HEIGHT; j++)
            {
                GetTile(i, j);
            }
        }
        highlightedPosition   = new XYPair();
        highlightedPosition.x = BOARD_WIDTH / 2;
        highlightedPosition.y = BOARD_HEIGHT / 2;

        blankTile       = (Instantiate(GameBoardTile, new Vector3(1000f, 1000f), Quaternion.identity) as GameObject).GetComponent <BoardTile>();
        players         = new MageController[4];
        playerLocations = new XYPair[4];
        currentPlayer   = 0;
        for (int i = 0; i < numPlayers; i++)
        {
            XYPair playerLocation = GetStartingPosition(i);
            playerLocations[i] = playerLocation;
            print("player " + i + " Location" + "x: " + playerLocation.x + "y: " + playerLocation.y);
            GameObject tempPlayer = Instantiate(Player, ComputePosition(playerLocation.x, playerLocation.y), Quaternion.identity) as GameObject;
            tempPlayer.SetActive(true);
            players[i] = tempPlayer.GetComponent <MageController>();
            if (i == 0)
            {
                players[0].SetPlayerName("Aaron");
            }
            players[i].PlayerID = i;
            players[i].Mana     = 1;
        }
        PlayerInputHandler.GameState = PlayerInputHandler.GameStateType.PLAYING;
    }
Пример #33
0
 public static void Initialize()
 {
     s_board = ConvertTilemapToLevelData(SaveManager.Load());
 }
Пример #34
0
 //Use this for preinitialization
 public void Awake()
 {
     //Initalize the gridOutline
     gridOutline = new BoardTile[boardSize, boardSize];
     boardGen = new int[boardSize, boardSize];
 }