当前位置: 首页>>代码示例>>C#>>正文


C# GSPacketIn.Seek方法代码示例

本文整理汇总了C#中GSPacketIn.Seek方法的典型用法代码示例。如果您正苦于以下问题:C# GSPacketIn.Seek方法的具体用法?C# GSPacketIn.Seek怎么用?C# GSPacketIn.Seek使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在GSPacketIn的用法示例。


在下文中一共展示了GSPacketIn.Seek方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: HandlePacket

        public void HandlePacket(GameClient client, GSPacketIn packet)
        {
            // A trainer of the appropriate class must be around (or global trainer, with TrainedClass = eCharacterClass.Unknow
            GameTrainer trainer = client.Player.TargetObject as DOL.GS.GameTrainer;
            if (trainer == null || (trainer.CanTrain(client.Player) == false && trainer.CanTrainChampionLevels(client.Player) == false))
            {
                client.Out.SendMessage("You must select a valid trainer for your class.", eChatType.CT_Important, eChatLoc.CL_ChatWindow);
                return;
            }

            //Specializations - 8 trainable specs max
            uint size = 8;
            long position = packet.Position;
            IList<uint> skills = new List<uint>();
            Dictionary<uint, uint> amounts = new Dictionary<uint, uint>();
            bool stop = false;
            for (uint i = 0; i < size; i++)
            {
                uint code = packet.ReadInt();
                if (!stop)
                {
                    if (code == 0xFFFFFFFF) stop = true;
                    else
                    {
                        if (!skills.Contains(code))
                            skills.Add(code);
                    }
                }
            }

            foreach (uint code in skills)
            {
                uint val = packet.ReadInt();

                if (!amounts.ContainsKey(code) && val > 1)
                    amounts.Add(code, val);
            }

            IList specs = client.Player.GetSpecList();
            uint skillcount = 0;
            IList<string> done = new List<string>();
            bool trained = false;

            // Graveen: the trainline command is called
            foreach (Specialization spec in specs)
            {
                if (amounts.ContainsKey(skillcount))
                {
                    if (spec.Level < amounts[skillcount])
                    {
                        TrainCommandHandler train = new TrainCommandHandler(true);
                        train.OnCommand(client, new string[] { "&trainline", spec.KeyName, amounts[skillcount].ToString() });
                        trained = true;
                    }
                }
                skillcount++;
            }

            //RealmAbilities
            packet.Seek(position + 64, System.IO.SeekOrigin.Begin);
            size = 50;//50 RA's max?
            amounts.Clear();
            for (uint i = 0; i < size; i++)
            {
                uint val = packet.ReadInt();

                if (val > 0 && !amounts.ContainsKey(i))
                {
                    amounts.Add(i, val);
                }
            }
            uint index = 0;
            if (amounts != null && amounts.Count > 0)
            {
                List<RealmAbility> ras = SkillBase.GetClassRealmAbilities(client.Player.CharacterClass.ID);
                foreach (RealmAbility ra in ras)
                {
                    if (ra is RR5RealmAbility)
                        continue;

                    if (amounts.ContainsKey(index))
                    {
                        RealmAbility playerRA = (RealmAbility)client.Player.GetAbility(ra.KeyName);
                        if (playerRA != null
                            && (playerRA.Level >= ra.MaxLevel || playerRA.Level >= amounts[index]))
                        {
                            index++;
                            continue;
                        }

                        int cost = 0;
                        for (int i = playerRA != null ? playerRA.Level : 0; i < amounts[index]; i++)
                            cost += ra.CostForUpgrade(i);
                        if (client.Player.RealmSpecialtyPoints < cost)
                        {
                            client.Out.SendMessage(ra.Name + " costs " + (cost) + " realm ability points!", eChatType.CT_System, eChatLoc.CL_SystemWindow);
                            client.Out.SendMessage("You don't have that many realm ability points left to get this.", eChatType.CT_System, eChatLoc.CL_SystemWindow);
                            index++;
                            continue;
                        }
//.........这里部分代码省略.........
开发者ID:uvbs,项目名称:Dawn-of-Light-core,代码行数:101,代码来源:PlayerTrainRequestHandler.cs


注:本文中的GSPacketIn.Seek方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。