예제 #1
0
    private void Update()
    {
        if (inBattle)
        {
            for (int index = messageCantainer.Count - 1; index >= 0; --index)
            {
                MessageEffect effect   = messageCantainer[index];
                MapField      mapField = GameRoot.GetInstance().MapField;
                //Debug.Log("duration " + effect.duration);
                if (effect.duration <= 0)
                {
                    messageCantainer.RemoveAt(index);
                    Destroy(effect.effect);
                    continue;
                }


                Canvas        canvas    = GameRoot.GetInstance().battleTextUI.GetComponent <Canvas>();
                CamaraManager camara    = GameRoot.GetInstance().CameraMng;
                Vector2       screenPos = Camera.main.WorldToScreenPoint(effect.pos);

                float scale = camara.GetViewSize();
                float hight = Screen.height / 10 * scale;

                effect.effect.transform.position = new Vector3(screenPos.x, screenPos.y + Mathf.Clamp((1.1f - effect.duration) * 0.2f, 0, 0.2f) * hight, 0);
                if (effect.canvas == BattleUICanvas.BattleText)
                {
                    Text text = effect.effect.GetComponentInChildren <Text>();
                    if (text != null)
                    {
                        text.gameObject.transform.localScale = Vector3.one * scale * 1.3f;
                    }
                }


                messageCantainer[index].duration = effect.duration - Time.deltaTime;
            }
        }
    }
예제 #2
0
        public void UpdateHpBar()
        {
            if (hpBar != null && hpBar.activeSelf == true)
            {
                hpBarCacheTime += Time.deltaTime;
                if (hpBarCacheTime > 5)
                {
                    hpBar.SetActive(false);
                    hpBarCacheTime = 0;
                    return;
                }
                Canvas        canvas    = GameRoot.GetInstance().battleUI.GetComponent <Canvas>();
                CamaraManager camara    = GameRoot.GetInstance().CameraMng;
                Vector2       screenPos = Camera.main.WorldToScreenPoint(GetSocketPos("S_Hp"));
                //Vector2 uiPos = Vector2.zero;
                //RectTransformUtility.ScreenPointToLocalPointInRectangle(canvas.transform as RectTransform, screenPos, canvas.worldCamera, out uiPos);
                //uiPos.x = screenPos.x - (Screen.width / 2);
                //uiPos.y = screenPos.y - (Screen.height / 2);
                //hpBar.GetComponent<RectTransform>().position = new Vector3(0, 0, 0);
                hpBar.transform.position = new Vector3(screenPos.x, screenPos.y, 0);

                hpBar.transform.localScale = new Vector3(0.9f + ((float)radius - 4) / 16f, 1f, 1) * 0.8f * camara.GetViewSize();
            }
        }