private void Awake()
 {
     m_StaminaUI      = FindObjectOfType <StaminaUI>();
     m_CurrentStamina = m_MaxStamina;
     SetShaderStamina();
     AudioManager.Initialize();
 }
示例#2
0
 public static void UpdateUIs(GameTime gameTime)
 {
     RuneSelectionUI?.Update(gameTime);
     MiscInputsUI?.Update(gameTime);
     StaminaUI?.Update(gameTime);
     InstrumentPlayUIState?.Update(gameTime);
 }
    private void TouchScreen()
    {
        if (!IsMoving)
        {
            IsAnimator.SetBool(IDLE, true);
            if (IsAnimator.GetBool(IDLE) && !IsAnimator.GetBool(MOVING))
            {
                IdleTimer += Time.deltaTime;
                // print(IdleTimer);
                if (IdleTimer >= MaxTouchWait)
                {
                    multiplier = 1;
                    IsAnimator.SetFloat("MoveMultiplier", multiplier);
                    IdleTimer = 0f;
                    if (!playerTimeMode)
                    {
                        if (multiplier.Equals(1))
                        {
                            Animator StmUI = StaminaUI.GetComponent <Animator>();
                            StmUI.SetBool("LimitReached", false);
                            Attention.GetComponent <Image>().enabled = false;
                            Stamina.fillAmount = 0;
                            StaminaUI.GetComponent <Canvas>().enabled = false;
                        }
                    }
                }
            }
            else
            {
                IdleTimer = 0f;
            }
            IsAnimator.SetBool(MOVING, false);
            IsAnimator.SetBool(STOP, false);
            MoveBoatSplash.Stop();
        }

        if (Input.GetMouseButton(0) || Input.touchCount > 0 &&
            !(EventSystem.current.IsPointerOverGameObject(Input.GetTouch(0).fingerId)))
        {
            if (Input.GetMouseButtonDown(0) || Input.touchCount > 0 && Input.GetTouch(0).phase == TouchPhase.Began)
            {
                one_click = true;
                timer_for_double_click = Time.time;
                //Debug.Log("Not Touched the UI");
                if (!is_hold)
                {
                    //movement pertama
                    if (!playerTimeMode)
                    {
                        StaminaUI.GetComponent <Canvas>().enabled = true;
                    }
                    IsAnimator.SetBool(STOP, false);
                    IsAnimator.SetBool(IDLE, false);
                    IsAnimator.SetBool(MOVING, true);
                    IsAnimator.SetTrigger("IsMove");
                    if (!speedLimiter(IsAnimator.GetFloat("MoveMultiplier")))
                    {
                        //print("jalan");
                        multiplier += 0.37f;
                        IsAnimator.SetFloat("MoveMultiplier", multiplier);
                        StartCoroutine(MovePlayer(MoveSpeedInWater));
                        if (!playerTimeMode)
                        {
                            Stamina.fillAmount = multiplier / maxmultiplier;
                        }
                    }
                    else
                    {
                        if (!playerTimeMode)
                        {
                            Animator StmUI = StaminaUI.GetComponent <Animator>();
                            StmUI.SetBool("LimitReached", true);
                            Attention.GetComponent <Image>().enabled = true;
                            TakeDamage(0.5f);
                        }
                        IsAnimator.SetFloat("MoveMultiplier", multiplier);
                        StartCoroutine(MovePlayer(MoveSpeedInWater));
                    }
                    //one_click = false;
                }
            }


            //if (Input.GetTouch(0).phase == TouchPhase.Ended)
            //{
            //    IsAnimator.SetBool(IDLE, true);
            //    IsAnimator.SetBool(MOVING, false);
            //    IsAnimator.SetBool(STOP, false);
            //    is_hold = false;
            //    acumTime = 0;
            //}
            //Double tap
            if (Input.GetMouseButton(0) || Input.touchCount == 1)
            {
                if (Application.platform == RuntimePlatform.Android)
                {
                    Touch touch = Input.GetTouch(0);
                    if (touch.phase == TouchPhase.Ended)
                    {
                        is_hold   = false;
                        TapCount += 1;
                    }

                    if (TapCount == 1)
                    {
                        NewTime = Time.time + MaxDubbleTapTime;
                        //jika terlalu lama hold / stop
                        if (one_click)
                        {
                            // if the time now is delay seconds more than when the first click started.
                            if ((Time.time - timer_for_double_click) < delay)
                            {
                                //print("One Hold Time Safe");
                                //movement kedua
                                IsAnimator.SetBool(STOP, false);
                                IsAnimator.SetBool(IDLE, false);
                                IsAnimator.SetBool(MOVING, true);
                                IsAnimator.SetTrigger("IsMove");
                                if (!speedLimiter(IsAnimator.GetFloat("MoveMultiplier")))
                                {
                                    multiplier += 0.25f;
                                    IsAnimator.SetFloat("MoveMultiplier", multiplier);
                                    StartCoroutine(MovePlayer(MoveSpeedInWater));
                                }
                                else
                                {
                                    Stamina.fillAmount = multiplier / maxmultiplier;
                                }
                                is_hold   = false;
                                one_click = false;
                            }
                        }
                        Hold_timer = 0f;
                    }
                    else if (TapCount == 2)
                    {
                        //Whatever you want after a dubble tap
                        //print("Dubble tap");
                        TapCount = 0;
                    }
                }
            }

            //hold
            if (Input.GetMouseButton(1) || Input.touchCount == 2)
            {
                bool moveIt = false;
                if (Application.platform == RuntimePlatform.Android)
                {
                    if (Input.GetTouch(0).phase != TouchPhase.Ended)
                    {
                        moveIt = true;
                    }
                    else
                    {
                        moveIt = false;
                    }
                }
                if (Application.platform == RuntimePlatform.WindowsPlayer)
                {
                    if (Input.GetMouseButtonDown(1))
                    {
                        moveIt = true;
                    }
                    else
                    {
                        moveIt = false;
                    }
                }
                if (Application.platform == RuntimePlatform.WindowsEditor)
                {
                    if (Input.GetMouseButtonDown(1))
                    {
                        moveIt = true;
                    }
                    else
                    {
                        moveIt = false;
                    }
                }
                if (moveIt)
                {
                    if (Application.platform == RuntimePlatform.Android)
                    {
                        acumTime += Input.GetTouch(0).deltaTime;
                    }
                    if (Application.platform == RuntimePlatform.WindowsPlayer)
                    {
                        acumTime += Time.deltaTime;
                        StartCoroutine(BreakPlayer(MoveSpeedInWater));
                    }
                    if (Application.platform == RuntimePlatform.WindowsEditor)
                    {
                        acumTime += Time.deltaTime;
                        StartCoroutine(BreakPlayer(MoveSpeedInWater));
                    }
                    if (acumTime >= holdTime)
                    {
                        //2 finger Long tap


                        is_hold = true;
                        StartCoroutine(BreakPlayer(MoveSpeedInWater));

                        if ((Time.time - timer_for_double_click) > delay)
                        {
                            // print("One Hold Time Reached");
                            StartCoroutine(MovePlayer(0.6f));
                            is_hold   = false;
                            one_click = false;
                            acumTime  = 0f;
                            //IsAnimator.SetBool(STOP, false);
                            //IsAnimator.SetBool(MOVING, false);
                        }
                    }
                }
                else
                {
                    IsAnimator.SetBool(IDLE, true);
                    IsAnimator.SetBool(MOVING, false);
                    IsAnimator.SetBool(STOP, false);
                    is_hold  = false;
                    acumTime = 0;
                }
            }
            if (Time.time > NewTime)
            {
                /*IsAnimator.SetBool(IDLE, true);
                 * IsAnimator.SetBool(MOVING, false);*/
                TapCount = 0;
                MoveBoatSplash.Stop();
            }
        }
    }