Exemplo n.º 1
0
    void Update()
    {
        if (m_player.GetComponent <PlayerHealth>().IsDie)
        {
            if (!isDieCheck)
            {
                m_uiCanvas.SetActive(false);
                m_dieCanvas.SetActive(true);
                isDieCheck = true;
            }
            return;
        }

        FindPotion();
        if (m_potion != null)
        {
            m_potionImg.enabled = true;
            m_potionCount.text  = m_potion.itemValue.ToString();
        }
        else
        {
            m_potionImg.enabled = false;
            m_potionCount.text  = string.Empty;
        }

        if (coolDownCheck)
        {
            m_potionBtn.enabled = false;
            coolTime           -= Time.deltaTime;
            Text text     = m_coolTimeImg.transform.GetComponentInChildren <Text>();
            int  timeText = (int)coolTime + 1;
            m_coolTimeImg.fillAmount = coolTime / 2.0f;
            if (coolTime <= 0.0f)
            {
                m_coolTimeImg.fillAmount = 0.0f;
                coolDownCheck            = false;
                m_potionBtn.enabled      = true;
                coolTime = 2.0f;
            }
        }
        else
        {
            m_coolTimeImg.fillAmount = 0.0f;
        }
        m_player.InputFunc(m_joyStick.Dir, m_joyStick.GetmoveCheck);
        m_player.UpdateAttack(m_joyStick.GetmoveCheck);

        Plane[] planes = GeometryUtility.CalculateFrustumPlanes(Camera.main);

        MonsterHealth[] monsters = GameObject.FindObjectsOfType <MonsterHealth>();
        for (int i = 0; i < monsters.Length; ++i)
        {
            Collider collider = monsters[i].GetComponent <Collider>();
            if (GeometryUtility.TestPlanesAABB(planes, collider.bounds))
            {
                monsters[i].SetActiveHp(true);
            }
            else
            {
                monsters[i].SetActiveHp(false);
            }
        }

        Collider col = m_player.GetCollider;

        if (col != null)
        {
            if (col.GetComponent <MonsterHealth>().IsDie || !col.gameObject.activeSelf)
            {
                col = null;
                m_bossUI.SetActive(false);
                m_targetUI.SetActive(false);
            }
            else
            {
                if (col.tag == "Boss")
                {
                    m_bossUI.SetActive(true);
                    m_bossSlider.value = col.GetComponent <MonsterHealth>().GetHp / col.GetComponent <MonsterHealth>().GetOriHp;
                    m_bossHpValue.text = ((int)(m_bossSlider.value * 100)).ToString() + "%";
                }
                else if (col.tag == "Monster")
                {
                    m_targetUI.SetActive(true);
                    m_targetSlider.value = col.GetComponent <MonsterHealth>().m_slider.value;
                    m_targetLevel.text   = "Lv." + col.GetComponent <MonsterController>().GetLevel.ToString();
                    m_targetName.text    = col.GetComponent <MonsterController>().GetName;
                    m_targetValue.text   = ((int)(m_targetSlider.value * 100)).ToString() + "%";
                }
            }
        }
        else
        {
            col = null;
            m_bossUI.SetActive(false);
            m_targetUI.SetActive(false);
        }
    }