using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using UnityEngine;
using UnityEngine.UI;

public class ToolsController : MonoBehaviour
{
    public GameObject Cursor;
    public int Rounding = 1;
    
    enum Tools { Wall, Room, Del, Cursor};
   // Tools tools = Tools.Cursor;


    // Start is called before the first frame update
    void Start()
    {
        
    }

    // Update is called once per frame
    void Update()
    {
       
    }

    public void CursorOff()
    {
        Cursor.SetActive(false);
        SelectButton(transform.GetChild(0).gameObject);
        WallCreate.mode = WallCreate.Mode.Cursor;
    }

    public void WallEdit()
    {
        Cursor.SetActive(true);
        SelectButton(transform.GetChild(2).gameObject);
        WallCreate.mode = WallCreate.Mode.Wall;
    }


    public void RoomEdit()
    {
        Cursor.SetActive(true);
        SelectButton(transform.GetChild(1).gameObject);
        WallCreate.mode = WallCreate.Mode.Room;
    }

    public void ZoneEdit()  
    {
        Cursor.SetActive(true);
        SelectButton(transform.GetChild(3).gameObject);
        WallCreate.mode = WallCreate.Mode.Zone;
    }

    public void Delete()
    {
        //tools = Tools.Del;
    }

    public void SelectButton(GameObject button)
    {
        var color = new Color();
        ColorUtility.TryParseHtmlString("#C8C8C8", out color);
        GameObject old_button = null;
        switch (WallCreate.mode)
        {
            case WallCreate.Mode.Cursor:
                old_button = transform.GetChild(0).gameObject;
                break;
            case WallCreate.Mode.Room:
                old_button = transform.GetChild(1).gameObject;
                break;           
            case WallCreate.Mode.Wall:
                old_button = transform.GetChild(2).gameObject;
                break; 
            case WallCreate.Mode.Zone:
                old_button = transform.GetChild(3).gameObject;
                break;
        }

        if (old_button != null) old_button.GetComponent<Image>().color = Color.white;
        button.GetComponent<Image>().color = color;
    }
}
