예제 #1
0
        public static void AddMonsterAbilities(GameObject p_parent, List <MonsterAbilityBase> p_abilities, List <MonsterBuffView> p_buffViews, GameObject p_buffViewPrefab, EventHandler p_onTooltip)
        {
            if (p_buffViews.Count > 0)
            {
                return;
            }
            if (p_abilities.Count == 0)
            {
                return;
            }
            Int32 num = 0;

            foreach (MonsterAbilityBase p_ability in p_abilities)
            {
                GameObject gameObject = NGUITools.AddChild(p_parent, p_buffViewPrefab);
                gameObject.transform.localPosition = new Vector3(num * 72f, 130f, 0f);
                MonsterBuffView component = gameObject.GetComponent <MonsterBuffView>();
                component.IsAbility       = true;
                component.OnTooltipEvent += p_onTooltip;
                p_buffViews.Add(component);
                p_buffViews[num].Init(null, false);
                p_buffViews[num].UpdateAbility(p_ability);
                NGUITools.SetActive(p_buffViews[num].gameObject, true);
                num++;
            }
            Vector3       pos           = new Vector3((-(Single)num * 72f + 80f) / 2f, -132f, 0f);
            TweenPosition tweenPosition = TweenPosition.Begin(p_parent, 0.3f, pos);

            tweenPosition.method        = UITweener.Method.EaseOut;
            tweenPosition.steeperCurves = true;
        }
예제 #2
0
        private void OnTooltip(Object p_sender, EventArgs p_args)
        {
            MonsterBuffView monsterBuffView = p_sender as MonsterBuffView;

            if (monsterBuffView != null)
            {
                StringEventArgs stringEventArgs = p_args as StringEventArgs;
                if (stringEventArgs != null)
                {
                    TooltipManager.Instance.Show(this, ((StringEventArgs)p_args).text, monsterBuffView.collider.transform.position, monsterBuffView.collider.transform.localScale * 0.5f);
                }
                if (p_args == EventArgs.Empty)
                {
                    TooltipManager.Instance.Hide(this);
                }
            }
        }
예제 #3
0
        public static void UpdateMonsterBuffs(GameObject p_parent, Boolean p_barIsVisible, List <MonsterBuff> p_buffs, List <MonsterBuffView> p_buffViews, GameObject p_buffViewPrefab, EventHandler p_onTooltip, Int32 p_offset)
        {
            if (p_offset < 0)
            {
                p_offset = 0;
            }
            Int32   num  = p_offset;
            Boolean flag = false;

            foreach (MonsterBuffView monsterBuffView in p_buffViews)
            {
                monsterBuffView.UpdateDurationLabel();
            }
            foreach (MonsterBuff monsterBuff in p_buffs)
            {
                if (!monsterBuff.IsExpired || !monsterBuff.IsDebuff)
                {
                    Boolean flag2 = false;
                    foreach (MonsterBuffView monsterBuffView2 in p_buffViews)
                    {
                        if (monsterBuffView2.MonsterBuff != null && monsterBuffView2.MonsterBuff.StaticID == monsterBuff.StaticID && monsterBuffView2.gameObject.activeSelf)
                        {
                            flag2 = true;
                            monsterBuffView2.UpdateDurationLabel();
                            break;
                        }
                    }
                    if (flag2)
                    {
                        num++;
                    }
                    else
                    {
                        if (p_buffViews.Count <= num)
                        {
                            flag = true;
                            GameObject gameObject = NGUITools.AddChild(p_parent, p_buffViewPrefab);
                            gameObject.transform.localPosition = new Vector3(num * 72f, 130f, 0f);
                            MonsterBuffView component = gameObject.GetComponent <MonsterBuffView>();
                            component.OnTooltipEvent += p_onTooltip;
                            p_buffViews.Add(component);
                            p_buffViews[num].Init(monsterBuff, p_barIsVisible);
                            p_buffViews[num].UpdateBuff(monsterBuff);
                            NGUITools.SetActive(p_buffViews[num].gameObject, false);
                        }
                        p_buffViews[num].UpdateBuff(monsterBuff);
                        if (!p_buffViews[num].gameObject.activeSelf)
                        {
                            if (p_buffViews[num].IsWaitTimeDone())
                            {
                                NGUITools.SetActive(p_buffViews[num].gameObject, true);
                            }
                            else
                            {
                                NGUITools.SetActive(p_buffViews[num].gameObject, false);
                            }
                        }
                        num++;
                    }
                }
            }
            Boolean flag3 = false;
            List <MonsterBuffView> list = new List <MonsterBuffView>();

            if (p_buffs.Count < p_buffViews.Count - p_offset)
            {
                flag3 = true;
                for (Int32 i = p_buffViews.Count - 1; i >= p_offset; i--)
                {
                    if (!p_buffs.Contains(p_buffViews[i].MonsterBuff))
                    {
                        if (!p_buffViews[i].SetDestroyTime)
                        {
                            p_buffViews[i].SetDisabled(p_barIsVisible);
                        }
                        else
                        {
                            list.Add(p_buffViews[i]);
                            p_buffViews.RemoveAt(i);
                        }
                    }
                }
            }
            for (Int32 j = list.Count - 1; j >= 0; j--)
            {
                UnityEngine.Object.Destroy(list[j].gameObject, list[j].TimeTillDestroy);
            }
            list.Clear();
            if ((p_buffs != null && p_buffs.Count > 0) || flag3)
            {
                Vector3 pos = new Vector3((-(Single)p_buffViews.Count * 72f + 80f) / 2f, -132f, 0f);
                if (flag || flag3)
                {
                    if (flag3)
                    {
                        for (Int32 k = p_offset; k < p_buffViews.Count; k++)
                        {
                            p_buffViews[k].transform.localPosition = new Vector3(k * 72f, 130f, 0f);
                        }
                    }
                    TweenPosition tweenPosition = TweenPosition.Begin(p_parent, 0.3f, pos);
                    tweenPosition.method        = UITweener.Method.EaseOut;
                    tweenPosition.steeperCurves = true;
                }
            }
        }