Exemple #1
0
    private void Update()
    {
        if (mTarget != null)
        {
            mname.text = mTarget.name;
            var screenPos = Camera.main.WorldToScreenPoint(mTarget.transform.position + new Vector3(0.0f, 4f, 0.0f));

            transform.parent.position = screenPos;

            float max  = mTarget.MaximumHP;
            float curr = mTarget.CurrentHP.Value;
            float size = (curr / max);

            GetComponent <RectTransform>().sizeDelta = new Vector2(size * 200f, GetComponent <RectTransform>().sizeDelta.y);

            ShowingTime[mTarget] -= Time.deltaTime;
            if ((ShowingTime[mTarget] < 0) || mTarget.isDead)
            {
                ShowingTime[mTarget] = -1;
                transform.parent.gameObject.SetActive(false);
                nOUI_HPBars.Enqueue(this);
                mTarget = null;
            }
        }
    }
    public void Updater(GameObject Obj)
    {
        int       id        = Obj.GetComponent <oNetworkIdentity>().id;
        oCreature oCreature = Obj.GetComponent <oCreature>();


        var fbb = new FlatBufferBuilder(1);

        if (Obj.GetComponent <oNetworkIdentity>().type == oNetworkIdentity.ObjType.monster)
        {
            fbb.Finish(MonsterStat.CreateMonsterStat(fbb, Class.MonsterStat, fbb.CreateString(""),
                                                     oCreature.CurrentHP.Value, 0,
                                                     id
                                                     ).Value);
        }
        else if (Obj.GetComponent <oNetworkIdentity>().type == oNetworkIdentity.ObjType.player)
        {
            if (id != BPlayer.MainPlayer.GetComponent <NetworkObject>().id)
            {
                fbb.Finish(PlayerStat.CreatePlayerStat(fbb, Class.PlayerStat,
                                                       oCreature.CurrentHP.Value,
                                                       oCreature.MaximumHP,
                                                       oCreature.CurrentSP,
                                                       oCreature.MaximumSP,
                                                       0,
                                                       0,
                                                       oCreature.Lv,
                                                       id
                                                       ).Value);
            }
            else
            {
                var player = BPlayer.MainPlayer.GetComponent <NetworkObject>();

                fbb.Finish(PlayerStat.CreatePlayerStat(
                               fbb,
                               Class.PlayerStat,
                               player.m_CurrentHP.Value,
                               MaxStatManager.MAX_HP,
                               player.m_CurrentMP.Value,
                               MaxStatManager.MAX_MP,
                               player.m_CurrentEXP.Value,
                               player.m_CurrentATK.Value,
                               oCreature.Lv,
                               id
                               ).Value);
            }
        }

        TCPClient.Instance.Send(fbb.SizedByteArray());
    }
Exemple #3
0
    public static void ShowHPBar(oCreature target, float time = 3f)
    {
        System.Action act = () =>
        {
            GameObject newHPBar;

            if (nOUI_HPBars.Count > 0)
            {
                newHPBar = nOUI_HPBars.Dequeue().gameObject;
                newHPBar.transform.parent.gameObject.SetActive(true);
            }
            else
            {
                newHPBar = NOUI_Manager.instance.NewHPBar();
            }

            newHPBar.GetComponentInChildren <NOUI_HPBar>().mTarget = target;
        };


        if (ShowingTime.ContainsKey(target))
        {
            if ((ShowingTime[target] < 0))
            {
                act();
            }
        }
        else
        {
            act();
        }



        ShowingTime[target] = time;
    }