Пример #1
0
    public GameObject CreateWallGameObject(Board.ROOM_TYPE roomType, GameObject gPrefab)
    {
        GameObject g = GameObject.Instantiate(gPrefab, new Vector3(0, tileDatabase.boardPropHeight, 0), Quaternion.identity);

        //g.transform.localScale = tileDatabase.propScale;
        return(g);
    }
Пример #2
0
    public GameObject RandomWallProp(Board.ROOM_TYPE roomType)
    {
        if (prefabWallProps.Count <= 0)
        {
            return(null);
        }
        if (prefabWallProps.ContainsKey(roomType) == false)
        {
            return(null);
        }

        List <GameObject> props = prefabWallProps[roomType].prefabs;

        if (props.Count == 0)
        {
            return(null);
        }

        if (Random.Range(0.0f, 100.0f) > prefabWallProps[roomType].chance)
        {
            return(null);
        }

        return(props[Random.Range(0, props.Count)]);
    }
Пример #3
0
    /// <summary>
    /// Create the GameObject Visual representation to be used by other methods (board or playblocks)
    /// </summary>
    /// <param name="roomType"></param>
    /// <returns></returns>
    public GameObject CreateTileGameObject(Board.ROOM_TYPE room_type, bool connected, int playerId)
    {
        GameObject g = GameObject.Instantiate(tileDatabase.prefabTileFloor, new Vector3(0, tileDatabase.boardHeight, 0), Quaternion.identity);

        g.transform.localScale = tileDatabase.tileScale;
        Material mat;

        if (connected)
        {
            if (room_type == Board.ROOM_TYPE.EMPTY || room_type == Board.ROOM_TYPE.WALL)
            {
                mat = tileDatabase.tileMaterials[room_type];
            }
            else
            {
                mat = tileDatabase.tileMaterialsPlayers[playerId];
            }
        }
        else
        {
            if (room_type == Board.ROOM_TYPE.EMPTY || room_type == Board.ROOM_TYPE.WALL)
            {
                mat = tileDatabase.tileMaterialsDisconnected[room_type];
            }
            else
            {
                mat = tileDatabase.tileMaterialsPlayersDc[playerId];
            }
        }
        g.GetComponent <MeshRenderer>().material = mat;
        return(g);
    }
Пример #4
0
 /// <summary>
 /// Places a Tile by setting the board logical state, and placing the visual representation.
 /// </summary>
 /// <param name="x"></param>
 /// <param name="y"></param>
 /// <param name="tileState"></param>
 public void PlaceTile(int x, int y, Board.ROOM_TYPE roomState, int player_id, int block_id)
 {
     Board.Tile tile = board.GetTile(x, y);
     tile.data.roomType = roomState;
     tile.data.player   = player_id;
     tile.block_id      = block_id;
     PlaceTileGameObject(tile);
 }
Пример #5
0
 public void SetData(Block b, Board.ROOM_TYPE s, int p)
 {
     blockBlueprint = b;
     for (int i = 0; i < 16; ++i)
     {
         block.blockBoard[i] = blockBlueprint.blockBoard[i];
     }
     roomType = s;
     player   = p;
 }
Пример #6
0
    /// <summary>
    /// Places a block if it fits
    /// </summary>
    /// <returns><c>true</c>, if play block was placed, <c>false</c> otherwise.</returns>
    /// <param name="playBlock">Play block.</param>
    public bool PlacePlayBlock(PlayBlock playBlock, bool erase = false)
    {
        if (CheckPlacePlayBlock(playBlock) == false && !erase)
        {
            return(false);
        }

        int block_id = last_block_id++;
        int startX   = (int)playBlock.transform.position.x;
        int startY   = (int)playBlock.transform.position.z;

        for (int i = 0; i < 4; i++)
        {
            for (int j = 0; j < 4; j++)
            {
                if (playBlock.block.GetValue(i, j) == 0)
                {
                    continue;
                }

                Board.ROOM_TYPE type = playBlock.roomType;
                if (erase)
                {
                    type = Board.ROOM_TYPE.EMPTY;
                }

                PlaceTile(startX + i, startY + j, type, currentPlayerId, block_id);

                //conquer neightbours
                if (mode == GAME_MODE.CONQUEST && !erase)
                {
                    for (int k = 0; k < 4; ++k)
                    {
                        Vector2    offset = offsets[k];
                        Board.Tile next   = board.GetTile(startX + i + (int)offset.x, startY + j + (int)offset.y);
                        if (next == null)
                        {
                            continue;
                        }
                        if (next.data.roomType != Board.ROOM_TYPE.WALL &&
                            next.data.roomType != Board.ROOM_TYPE.EMPTY &&
                            next.data.roomType != Board.ROOM_TYPE.START)
                        {
                            next.data.player   = currentPlayerId;
                            next.data.roomType = type;
                        }
                    }
                }
            }
        }

        GetComponent <AudioSource>().PlayOneShot(clipFall);

        return(true);
    }
Пример #7
0
    public void NewBlock()
    {
        Board.ROOM_TYPE roomType = Board.GetRandomRoomType();

        //if(GameManager.Instance.mode == GameManager.GAME_MODE.CONQUEST)
        //    roomType = (Board.ROOM_TYPE)(playerId + (int)Board.ROOM_TYPE.KITCHEN);
        //else if(GameManager.Instance.mode == GameManager.GAME_MODE.HOME && GameManager.Instance.turn == 0)
        //    roomType = Board.ROOM_TYPE.CORRIDOR;
        playBlock.SetData(GameManager.Instance.blockDatabase.GetRandomBlock(), Board.GetRandomRoomType(), GameManager.Instance.currentPlayerId);
        playBlock.Populate(playerId);
    }