Ejemplo n.º 1
0
    private void SpawnPiece(Piece.Piece_Types type, Vector3 position, int boardIndexX, int boardIndexY)
    {
        GameObject PieceObject = null;

        switch (type)
        {
        case 0:
            break;

        case Piece.Piece_Types.RED:
            PieceObject = Instantiate(RedPiecePrefab, position, Quaternion.identity);
            break;

        case Piece.Piece_Types.YELLOW:
            PieceObject = Instantiate(YellowPiecePrefab, position, Quaternion.identity);
            break;
        }

        if (PieceObject != null)
        {
            board.BoardPieces[boardIndexX, boardIndexY]      = PieceObject.GetComponent <Piece>();
            board.BoardTiles[boardIndexX, boardIndexY].piece = board.BoardPieces[boardIndexX, boardIndexY];
            board.BoardPieces[boardIndexX, boardIndexY].Setup(type);
        }
    }
Ejemplo n.º 2
0
    //Incl. a list of all gameobjects spawned from the board, for easy despawning

    public void Spawn()
    {
        Debug.Log("SPAWN BOARD");

        board.BoardPieces = new Piece[board.BoardPiecesID.GetLength(0), board.BoardPiecesID.GetLength(1)];

        for (int i = 0; i < board.BoardPiecesID.GetLength(0); i++)
        {
            for (int j = 0; j < board.BoardPiecesID.GetLength(1); j++)
            {
                Vector3 TileSpawnPos = new Vector3((-board.columns / 2 * tileSize) + j * tileSize, 0, (board.rows / 2 * tileSize) - i * tileSize);

                SpawnTile(TileSpawnPos, i, j);

                Piece.Piece_Types type          = LevelDataConverter.ToPieceTypeFromID(board.BoardPiecesID[i, j]);
                Vector3           PieceSpawnPos = new Vector3(TileSpawnPos.x, TileSpawnPos.y + pieceOffsetY, TileSpawnPos.z);

                SpawnPiece(type, PieceSpawnPos, i, j);
            }
        }
    }
Ejemplo n.º 3
0
 public void Setup(Piece_Types _type)
 {
     stateHandler = new PieceStateHandler(this);
     type         = _type;
 }