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

public class sliderControl : MonoBehaviour
{
    public Transform slider;
    public SpriteRenderer Outliner;
    public Sprite Lvl_1_OutLine;
    public Sprite Lvl_2_OutLine;
    public Sprite Lvl_3_OutLine;
    Color normalColor;
    public Color downColor;
    float m_ratio = 0;

    private void Start()
    {
        normalColor = slider.gameObject.GetComponent<SpriteRenderer>().color;
    }
    public void SetSliderValue(float ratio, int lvl)
    {
        if (ratio > m_ratio )
        {
            slider.gameObject.GetComponent<SpriteRenderer>().color = normalColor;
        }
        else
        {
            slider.gameObject.GetComponent<SpriteRenderer>().color = downColor;
        }
        m_ratio = ratio;


        switch (lvl)
        {
            case 1:
                Outliner.sprite = Lvl_1_OutLine;
                break;
            case 2:
                Outliner.sprite = Lvl_2_OutLine;
                break;
            case 3:
            default:
                Outliner.sprite = Lvl_3_OutLine;
                break;
        }
        float newNum = 7.8f / 3.0f;
        slider.localScale = new Vector3(slider.localScale.x, lvl * ratio * newNum, 1);
    }
}
