Exemple #1
0
    void Update()
    {
        if (!generated)
        {
            generated = generateMap.Generate();
            return;
        }

        if (!isAwake)
        {
            if (finishBlackPanel.color.a >= 0f)
            {
                finishBlackPanel.color -= new Color(0, 0, 0, 0.03f);
            }
            else
            {
                finishBlackPanel.enabled = false;
                isAwake = true;
            }
        }

        if (Input.GetKeyDown(KeyCode.Escape))
        {
            finishTimer = 3f;
            isFinish    = true;
        }

        if (!isFinish)
        {
            return;
        }

        finishTimer += Time.deltaTime;

        if (finishTimer >= 4.5f)
        {
            SceneManager.LoadScene(0);
        }
        else if (finishTimer >= 3f)
        {
            finishBlackPanel.enabled = true;
            if (finishBlackPanel.color.a <= 1f)
            {
                finishBlackPanel.color += new Color(0, 0, 0, 0.03f);
            }
        }
    }
    // generates the whole map
    public void Create()
    {
        Random.InitState(generations);
        GenerateMap map = new GenerateMap();

        mapData = map.Generate(parameters, generations, cellType, islandFunction, heightFactor, heightMap, regionCount, relaxationCount, radius);
        GenerateMesh meshData = map.GenerateMeshData();

        meshFilter.mesh = meshData.CreateMesh();

        meshRenderer.sharedMaterials = new Material[mapData.biomes.Count];
        Material[] materials = new Material[mapData.biomes.Count];
        for (int i = 0; i < mapData.biomes.Count; i++)
        {
            Material material = new Material(baseMaterial);
            ColorUtility.TryParseHtmlString(CheckingScript.displayColors[mapData.biomes[i]], out Color biome);
            material.color = biome;
            material.name  = mapData.biomes[i];
            materials[i]   = material;
        }

        meshRenderer.sharedMaterials = materials;
    }