コード例 #1
0
    public void paintLandTilesBySettings(List <GameTile> tiles, TileTypeSettings settings)
    {
        Dictionary <TileType, int>      availableLandPieces = settings.getAvailableLandPiecesDictionary();
        Dictionary <TileType, Material> materials           = settings.getMaterialsDictionary();
        List <GameTile> gameTiles = new List <GameTile> (landTiles);

        Debug.Log("GAMETILES.COUNT = " + gameTiles.Count);
        int randomNum;
        int maxMapDimension = Mathf.Max(mapWidth, mapHeight);
        int difference      = maxMapDimension - hexSettings.oceanLayers;

        bool canBeLake;

        do
        {
            randomNum = Random.Range(0, gameTiles.Count);
            canBeLake = (Mathf.Abs(gameTiles[randomNum].index.x) + Mathf.Abs(gameTiles[randomNum].index.y) + Mathf.Abs(gameTiles[randomNum].index.z)) < (difference * 2);
        } while(!canBeLake);

        Renderer renderer = gameTiles [randomNum].GetComponent <Renderer> ();

        renderer.material = materials [TileType.Desert];

        gameTiles[randomNum].tileType = TileType.Desert;
        gameTiles [randomNum].transform.FindChild("Dice Value").gameObject.SetActive(false);
        gameTiles [randomNum].transform.FindChild("Dice Values").gameObject.SetActive(true);
        desertTile = gameTiles[randomNum];

        gameTiles.RemoveAt(randomNum);
        availableLandPieces [TileType.Desert]--;

        foreach (var pair in availableLandPieces)
        {
            for (int i = 0; i < pair.Value; i++)
            {
                randomNum         = Random.Range(0, gameTiles.Count);
                renderer          = gameTiles [randomNum].GetComponent <Renderer> ();
                renderer.material = materials [pair.Key];

                gameTiles[randomNum].tileType = pair.Key;
                gameTiles [randomNum].transform.FindChild("Dice Value").gameObject.SetActive(true);
                gameTiles.RemoveAt(randomNum);

                if (gameTiles.Count == 0)
                {
                    return;
                }
            }
        }
    }
コード例 #2
0
 public void setSettings(TileTypeSettings settings)
 {
     boardSettings = settings;
     materials     = boardSettings.getMaterialsDictionary();
 }