Ejemplo n.º 1
0
        private void InitItem()
        {
            ActiveSkillData[] activeSkillDataList = new ActiveSkillData[SkillLogic.GetInstance().ActiveSkillDict.Count];
            SkillLogic.GetInstance().ActiveSkillDict.Values.CopyTo(activeSkillDataList, 0);

            items = new ActiveSkillItem[SKILL_ITEM_COUNT];                      //建立数组
            for (int i = 0; i < SKILL_ITEM_COUNT; i++)
            {
                items[i] = NGUITools.AddChild <ActiveSkillItem>(gameObject);
                ActiveSkillItem item = items[i];

                if (i < SkillLogic.GetInstance().ActiveSkillDict.Count)
                {
                    item.SkillData = activeSkillDataList[i];

                    if (item.gameObject.collider == null)
                    {
                        NGUITools.AddWidgetCollider(item.gameObject);
                    }
                    UIEventListener.Get(item.gameObject).onClick += OnClickItem;
                }
                else
                {
                    item.SkillData = null;
                }
                item.gameObject.transform.localPosition = new Vector3(-223 + i * 88, 104, 0);
            }
            //显示第一个
            if (SkillLogic.GetInstance().ActiveSkillDict.Count > 1)
            {
                OnClickItem(items[0].gameObject);
            }
        }
Ejemplo n.º 2
0
        private void OnClickItem(GameObject go)
        {
            ActiveSkillItem item = go.GetComponent <ActiveSkillItem>();

            if (item == null)
            {
                return;
            }
            UpdateSkillDesc(item.SkillData);
            currentItem = item;
            ShowSelectedSkillEffect();
        }