Exemplo n.º 1
0
        public static void LearnSkill(int skillId)
        {
            var pinfo    = ServerData.Instance.playerInfo;
            var allSkill = pinfo.Skill;
            var skInfo   = SkillInfo.CreateBuilder();

            skInfo.SkillInfoId = skillId;
            skInfo.Level       = 1;
            skInfo.Pos         = 0;
            allSkill.SkillInfosList.Add(skInfo.Build());
            var skData = Util.GetSkillData(skillId, 1);

            SendNotify("恭喜学会技能 [ff1010]" + skData.SkillName + "[-]");
        }
Exemplo n.º 2
0
        /// <summary>
        /// 初始化右下角的技能快捷栏
        /// 初始化技能列表
        /// </summary>
        /// <returns>The from network.</returns>
        public IEnumerator InitFromNetwork()
        {
            Log.Net("Init Skill slots");
            CGLoadShortcutsInfo.Builder b = CGLoadShortcutsInfo.CreateBuilder();
            KBEngine.PacketHolder       p = new KBEngine.PacketHolder();
            yield return(StartCoroutine(KBEngine.Bundle.sendSimple(this, b, p)));

            var shortData = p.packet.protoBody as GCLoadShortcutsInfo;

            skillSlots = new List <SkillFullInfo>();
            foreach (ShortCutInfo s in shortData.ShortCutInfoList)
            {
                var full = new SkillFullInfo(s);
                skillSlots.Add(full);
            }
            Log.Net("Init Skill slots over " + skillSlots.Count);
            MyEventSystem.myEventSystem.PushEvent(MyEvent.EventType.UpdateShortCut);


            Log.Sys("LoadSkillPanel");
            //获取特定技能面板的技能点 所有面板公用这些技能点
            CGLoadSkillPanel.Builder ls = CGLoadSkillPanel.CreateBuilder();
            ls.SkillSort = SkillSort.ACTIVE_SKILL;
            KBEngine.PacketHolder p2 = new KBEngine.PacketHolder();
            yield return(StartCoroutine(KBEngine.Bundle.sendSimple(this, ls, p2)));

            Log.Net("FinishLoad");
            var data = p2.packet.protoBody as GCLoadSkillPanel;

            //distributedSkillPoint = data.Distributed;
            if (data.HasTotalPoint)
            {
                totalSkillPoint = data.TotalPoint;
            }
            else
            {
                totalSkillPoint = 0;
            }
            Dictionary <int, SkillInfo> skIdToInfo = new Dictionary <int, SkillInfo>();

            Log.GUI("SkillInfoList " + data.SkillInfosList.Count + " totalPoint " + totalSkillPoint);

            foreach (SkillInfo sk in data.SkillInfosList)
            {
                skIdToInfo [sk.SkillInfoId] = sk;
            }

            var myJob = ChuMeng.ObjectManager.objectManager.GetMyJob();

            Log.Sys("SkillMyJob AndList " + myJob);
            //从服务器加载对应的技能数据 两部分: 配置的职业技能 服务器加载的技能
            foreach (var s in GameData.SkillConfig)
            {
                if (s.job == myJob)
                {
                    if (skIdToInfo.ContainsKey(s.id))
                    {
                        activeSkill.Add(new SkillFullInfo(skIdToInfo [s.id]));
                    }
                    else
                    {
                        var skInfo = SkillInfo.CreateBuilder();
                        skInfo.SkillInfoId = s.id;
                        skInfo.Level       = 0;
                        skInfo.Pos         = 0;
                        activeSkill.Add(new SkillFullInfo(skInfo.Build()));
                    }
                }
            }

            var learnedSkill = PlayerData.GetLearnedSkill();

            foreach (var s in learnedSkill.SkillInfosList)
            {
                var old = activeSkill.Find(item => item.skillId == s.SkillInfoId);
                if (old != null)
                {
                    //old.Pos = s.Pos;
                }
                else
                {
                    var skInfo = SkillInfo.CreateBuilder(s);
                    activeSkill.Add(new SkillFullInfo(skInfo.Build()));
                }
            }
            Log.Sys("MySkillCount " + activeSkill.Count);
        }
Exemplo n.º 3
0
        public static void LevelUpSkill(int skId)
        {
            Debug.Log("LevelUpSkill: " + skId);
            var pinfo      = ServerData.Instance.playerInfo;
            int totalSP    = 0;
            int skillLevel = 0;

            if (pinfo.HasSkill)
            {
                totalSP = pinfo.Skill.TotalPoint;
                foreach (var s in pinfo.Skill.SkillInfosList)
                {
                    if (s.SkillInfoId == skId)
                    {
                        skillLevel = s.Level;
                        break;
                    }
                }
            }
            var skData    = Util.GetSkillData(skId, skillLevel);
            var maxLev    = skData.MaxLevel;
            var playerLev = pinfo.Roles.Level;
            var next      = Util.GetSkillData(skId, skillLevel + 1);
            var needLev   = next.LevelRequired;

            if (totalSP > 0 && skillLevel < maxLev && playerLev >= needLev)
            {
                Log.Sys("LearnSkill");
                AddSkillPoint(-1);

                bool find = false;
                foreach (var sk in pinfo.Skill.SkillInfosList)
                {
                    if (sk.SkillInfoId == skId)
                    {
                        sk.Level++;
                        find = true;
                        break;
                    }
                }
                if (!find)
                {
                    var newinfo = SkillInfo.CreateBuilder();
                    newinfo.SkillInfoId = skId;
                    newinfo.Level       = 1;
                    pinfo.Skill.SkillInfosList.Add(newinfo.Build());
                }

                //pinfo.Skill = newSk.Build();

                var activeSkill = GCPushActivateSkill.CreateBuilder();
                activeSkill.SkillId = skId;
                activeSkill.Level   = skillLevel + 1;
                ServerBundle.SendImmediatePush(activeSkill);
            }
            else if (totalSP <= 0)
            {
                SendNotify("剩余技能点不足");
            }
            else if (playerLev < needLev)
            {
                SendNotify("等级不足");
            }
            else
            {
                SendNotify("技能已经升到满级");
            }
            PushSkillShortcutsInfo();
        }