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

public class UIPower : MonoBehaviour
{
    Slider powerBar;
    public float powerSpeed = 100f;
    public GameManager gm;
    // Start is called before the first frame update
    void Start()
    {
        powerBar = GetComponentInChildren<Slider>();
    }

    // Update is called once per frame
    void Update()
    {
        if (gm.levelStatus == LevelStatus.Playing)
        {
            //按下蓄力，松开释放
            if (Input.GetKey(KeyCode.S))
            {
                powerBar.value += powerSpeed * Time.deltaTime;
            }
            if (Input.GetKey(KeyCode.B))
            {
                powerBar.value -= powerSpeed * Time.deltaTime;
            }

            if (Input.GetKeyUp(KeyCode.S) || Input.GetKeyUp(KeyCode.B))
            {
                if (gm.pipe.isInWater)
                {
                    gm.DragBubble(powerBar.value - 50);
                }

                powerBar.value = 50f;
            }
        }

    }
}
