コード例 #1
0
    void Build()
    {
        Spaces = new Dictionary <Vector3Int, bool>();
        for (int x = -Size; x <= Size; x++)
        {
            for (int y = -Size; y <= Size; y++)
            {
                Vector2Int point = new Vector2Int(x, y);
                if (InMap(point, Size))
                {
                    HexTile hex = Instantiate(HexPrefab);
                    hex.GetComponent <SpriteRenderer>().color = Colour;
                    Vector3Int v3i = ConvertToVector3(point);
                    hex.transform.position = GetWorldPosition(v3i);
                    hex.Coordinates        = v3i;
                    Hexes[v3i]             = hex;

                    // Added bits around altitude and humidity
                    Vector2 v2       = new Vector2(x, y);
                    float   altitude = Noise.Generate2DNoiseValue(v2, altitudeSeed1) +
                                       Noise.Generate2DNoiseValue(v2, altitudeSeed2);
                    float humidity = Noise.Generate2DNoiseValue(v2, humiditySeed1) +
                                     Noise.Generate2DNoiseValue(v2, humiditySeed2);
                    hex.altitude = altitude;
                    if (altitude < mapPresets.seaLevel)
                    {
                        Spaces[v3i] = false;
                    }
                    else
                    {
                        Spaces[v3i] = true;
                    }
                    hex.humidity = humidity;
                    hex.ColourSwitch(mapPresets);
                }
            }
        }
        GenerateWitchBase(new Vector3Int(0, 0, 0));
    }