Skip to content
Snippets Groups Projects
BiomeMaster.cs 1.56 KiB
Newer Older
using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
Ryan Chang's avatar
Ryan Chang committed
using NaughtyAttributes;

public class BiomeMaster : MonoBehaviour
{
Ryan Chang's avatar
Ryan Chang committed
    #region Variables
Ryan Chang's avatar
Ryan Chang committed
    [Header("Biome Parameters")]
    [InfoBox("Contains the parameters required for each biome.")]
    public List<BiomeParameter> parameters;

Ryan Chang's avatar
Ryan Chang committed
    [Header("Biome Data")]
    [InfoBox("Contains the actual biomes. Each biome targets one or more biome " +
        "parameters. Every point on the terrain will be assigned differing " +
        "proportions of each biome, depending on how close the calculated " +
        "parameters are to the target parameter of that biome.")]
    public List<BiomeData> datas;

Ryan Chang's avatar
Ryan Chang committed
    #region Debug
    [Header("Debug")]
    public int debugSize = 500;

    public float debugFrequency = 0.1f;
Ryan Chang's avatar
Ryan Chang committed
    #endregion
    #endregion
Ryan Chang's avatar
Ryan Chang committed
    #region Buttons
    [Button("Update Debug")]
    private void UpdateDebug()
Ryan Chang's avatar
Ryan Chang committed
        for (int i = -debugSize; i < debugSize; i++)
Ryan Chang's avatar
Ryan Chang committed
            for (int j = -debugSize; j < debugSize; j++)
Ryan Chang's avatar
Ryan Chang committed
                float x = i * debugFrequency;
                float y = j * debugFrequency;
Ryan Chang's avatar
Ryan Chang committed
                float mu = 0;
Ryan Chang's avatar
Ryan Chang committed
                foreach (var param in parameters)
                {
Ryan Chang's avatar
Ryan Chang committed
                    param.DrawDebug(x + mu, y + mu);
                    mu += debugFrequency / 10;
Ryan Chang's avatar
Ryan Chang committed

Ryan Chang's avatar
Ryan Chang committed
    [Button("Reseed Parameters")]
Ryan Chang's avatar
Ryan Chang committed
    private void ReseedParameters()
    {
        foreach (var param in parameters)
        {
            param.ReseedOctaves();
        }
    }
    #endregion
}