Ejemplo n.º 1
0
        void InitSkill()
        {
            CurrSkillPage = 0;
            mSkillCollect = new List <List <SkillItemLink> >();

            for (int i = 0, max = 2; i < max; ++i)
            {
                List <SkillItemLink> tmpSkillPage = new List <SkillItemLink>();
                mSkillCollect.Add(tmpSkillPage);

                for (int j = 0, jmax = 6; j < jmax; ++j)
                {
                    SkillItemLink tmpSkillLink = new SkillItemLink();
                    tmpSkillPage.Add(tmpSkillLink);

                    string tmpStr = PlayerPrefs.GetString($"Skill{i}_{j}");
                    if (!string.IsNullOrEmpty(tmpStr))
                    {
                        string[] tmpStrs = tmpStr.Split('-');

                        for (int k = 0, kmax = tmpStrs.Length; k < kmax; ++k)
                        {
                            int tmpSkillID = 0;

                            if (int.TryParse(tmpStrs[k], out tmpSkillID))
                            {
                                SkillItem tmpSkillItem = new SkillItem();
                                tmpSkillItem.Init(tmpSkillID, 1);
                                tmpSkillLink.SkillItems.Add(tmpSkillItem);
                            }
                        }
                    }
                }
            }

            mExSkillLink = new SkillItemLink();
            UnitExtraBase tmpUnitExtraBase = UnitExtraBaseManager.instance.Find(UnitID);

            if (null != tmpUnitExtraBase)
            {
                SkillItem tmpSkillItem = new SkillItem();
                tmpSkillItem.Init(tmpUnitExtraBase.SkillEx, 1);
                mExSkillLink.SkillItems.Add(tmpSkillItem);
            }
        }
Ejemplo n.º 2
0
        private void InitSkillTree()
        {
            var           tmpPlayerCtrl    = Game.ControllerMgr.Get <PlayerController>();
            UnitExtraBase tmpUnitExtraBase = UnitExtraBaseManager.instance.Find(tmpPlayerCtrl.UnitID);
            Dictionary <int, List <SkillBase> > tmpTreeType2Skills = new Dictionary <int, List <SkillBase> >();

            for (int i = 0, max = tmpUnitExtraBase.Skills.data.Count; i < max; ++i)
            {
                SkillBase tmpSkillBase = SkillBaseManager.instance.Find(tmpUnitExtraBase.Skills.data[i]);

                if (null != tmpSkillBase)
                {
                    List <SkillBase> tmpSkills = null;

                    if (!tmpTreeType2Skills.TryGetValue(tmpSkillBase.TreeType, out tmpSkills))
                    {
                        tmpSkills = new List <SkillBase>();
                        tmpTreeType2Skills.Add(tmpSkillBase.TreeType, tmpSkills);
                    }

                    tmpSkills.Add(tmpSkillBase);
                }
            }

            int tmpMaxRow = 0;

            foreach (var elem in tmpTreeType2Skills)
            {
                if (elem.Value.Count > tmpMaxRow)
                {
                    tmpMaxRow = elem.Value.Count;
                }
            }

            mSkillTreeGT.GenerateElem(tmpMaxRow);

            for (int i = 0, max = 3; i < max; ++i)
            {
                List <SkillBase> tmpSkills = null;

                if (!tmpTreeType2Skills.TryGetValue(i, out tmpSkills))
                {
                    continue;
                }

                for (int j = 0, jmax = tmpMaxRow; j < jmax; ++j)
                {
                    GameObject  tmpRowGo    = mSkillTreeGT.Get(j);
                    SkillElem[] tmpRowElems = null;

                    if (j < mSkillTreeItems.Count)
                    {
                        tmpRowElems = mSkillTreeItems[j];
                    }
                    else
                    {
                        tmpRowElems = new SkillElem[3];
                        mSkillTreeItems.Add(tmpRowElems);
                    }

                    SkillElem tmpSkillElem = tmpRowElems[i];

                    if (null == tmpSkillElem)
                    {
                        tmpSkillElem = new SkillElem();
                        tmpSkillElem.Init(Find(tmpRowGo, $"SkillItem{i}"));
                        tmpRowElems[i] = tmpSkillElem;
                    }

                    if (j < tmpSkills.Count)
                    {
                        SetActive(tmpSkillElem.RootGo, true);
                        tmpSkillElem.Refresh(tmpSkills[j]);
                        SetActive(tmpSkillElem.LinkLineGo, j != tmpSkills.Count - 1);

                        RegistSkillTreeDragBegin(tmpSkillElem);
                        RegistSkillTreeDrag(tmpSkillElem);
                        RegistSkillTreeDragEnd(tmpSkillElem);
                        RegistSkillTreeClick(tmpSkillElem);
                    }
                    else
                    {
                        SetActive(tmpSkillElem.RootGo, false);
                    }
                }
            }
        }