コード例 #1
0
ファイル: BoardManager.cs プロジェクト: cvance5/syphermia
    public static void GenerateBoard(int maxColumn, int maxHeight, int maxRow, BoardTopology topologyType = BoardTopology.Rolling)
    {
        Instance.gameObject.name = "Board";

        Rows    = maxRow;
        Columns = maxColumn;
        Height  = maxHeight;

        float[][] topology = GenerateTopologicalNoise(maxColumn, maxRow, topologyType);

        for (int column = 0; column < maxColumn; column++)
        {
            for (int row = 0; row < maxRow; row++)
            {
                int height = Mathf.RoundToInt(topology[column][row] * maxHeight);
                board.Add(new Vector3(column, height, row), GenerateHex(column, height, row));
                while (height > 0)
                {
                    height--;
                    board.Add(new Vector3(column, height, row), GenerateHex(column, height, row));
                }
            }
        }

        BoardCenter = new Vector3(Rows / 2, Height / 2, Columns / 2);
    }
コード例 #2
0
ファイル: BoardManager.cs プロジェクト: cvance5/syphermia
    private static float[][] GenerateTopologicalNoise(int width, int height, BoardTopology topologyType)
    {
        float[][] noise = PerlinNoise.GenerateWhiteNoise(width, height);

        switch (topologyType)
        {
        case BoardTopology.Rolling:
        {
            noise = PerlinNoise.GenerateSmoothNoise(noise, 1);
        }
        break;

        case BoardTopology.Jagged:
            break;
        }

        return(noise);
    }