コード例 #1
0
    public void GenerateBlocks(ChunkBiomeCheck CBC)
    {
        // Gets Biome
        float        f = (float)Math.Round(GetComponent <SpriteRenderer>().color.grayscale, 1);
        BiomeProfile B = CBC.GetBiome(f);

        // Do Biome Logic Generation
        var Biome = B.BiomeGeneration.GetComponent <IBiomeGeneration>();

        if (Biome != null)
        {
            T    = Biome.GenerateMap(5, 5, B);
            BARR = Biome.BlockToGenerate(B.Pallete, B.BlockHights, T);
        }
        else
        {
            Debug.LogError("Generation Type not of .IBiomeGeneration -- The class does not Impliment the Interface and a problem occurred");
        }

        // Instantiate Blocks
        for (int i = 0; i < BARR.Length; i++)
        {
            if (BARR[i] != null)
            {
                GameObject G = Instantiate(BARR[i].PreCoExistingEffects);
                G.transform.parent        = transform;
                G.transform.localPosition = BlockPos[i];
                G.AddComponent <SpriteRenderer>();
                G.GetComponent <SpriteRenderer>().sprite = BARR[i].BlockSprite;
            }
        }

        // Hide Chunk
        gameObject.GetComponent <SpriteRenderer>().enabled = false;
    }
コード例 #2
0
    public Texture2D GenerateMap(int width, int length, BiomeProfile Biome)
    {
        Texture2D T = new Texture2D(width, length);

        for (int i = 0; i < width; i++)
        {
            for (int j = 0; j < length; j++)
            {
                T.SetPixel(i, j, new Color(1, 1, 1));
            }
        }
        T.Apply();
        return(T);
    }