using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.Tilemaps;

public class test : MonoBehaviour
{
    public Tile dirt;
    public Tile dirt2;
    public Tile underground;
    public Tile underground2;
    public Tile sand;
    public Tile sand2;
    public Tile sanderground;
    public Tile sanderground2;
    public Tile ice;
    public Tile ice2;
    public Tile iceground;
    public Tile iceground2;


    private Tile use;
    private Tile use2;
    private Tile useground;
    private Tile useground2;

    private Tilemap map;

    void SetWorld()
    {
        int rand = (int)(Random.value * 3);

        switch (rand)
        {
            case 0:
                use = dirt;
                use2 = dirt2;
                useground = underground;
                useground2 = underground2;
                break;
            case 1:
                use = sand;
                use2 = sand2;
                useground = sanderground;
                useground2 = sanderground2;
                break;
            case 2:
                use = ice;
                use2 = ice2;
                useground = iceground;
                useground2 = iceground2;
                break;
            default:
                use = ice;
                use2 = ice2;
                useground = iceground;
                useground2 = iceground2;
                break;
        }
    }
    void Awake()
    {
        map = gameObject.GetComponent<Tilemap>();

        SetWorld();
        int rand = (int)(Random.value * 3);
        for (int i = 0; i < 350; ++i)
        {
            Vector3Int vector = new Vector3Int(i, 0 + rand, 0);
            Vector3Int vector2 = new Vector3Int(0, 0, 1);
            if (i % 2 == 0)
            {
                map.SetTile(vector, use);
                for (int j = rand + 1; j > 0; j--)
                {
                    map.SetTile(vector + (Vector3Int.down * j), useground);
                }
            }
            else
            {
                map.SetTile(vector + vector2, use2);
                for (int j = rand + 1; j > 0; j--)
                {
                    map.SetTile(vector + (Vector3Int.down * j) + vector2, useground2);
                }
            }
            if (i % 5 == 0)
            {
                rand = (int)(Random.value * 3);
            }
        }
    }
}
