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


C# PacketIn.ReadByte方法代码示例

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


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

示例1: BuyNpcItem

        public static void BuyNpcItem(Client client, PacketIn packet)
        {
            int npcWorldId = (int)packet.ReadUInt32();
            byte v1     = packet.ReadByte();
            byte amount = packet.ReadByte();

            int totalPrice = 0;

            ushort[] items   = new ushort[amount];
            ushort[] amounts = new ushort[amount];
            for(int i=0;i<amount;i++)
            {
                items[i]   = packet.ReadUShort();
                amounts[i] = packet.ReadUShort();

                // TODO, calculate correct price
                totalPrice += 100 * amounts[i];
            }

            // TODO, add geon amount check
            for(int i=0;i<amount;i++)
            {
                // should be items, not player items
                PlayerItem item = PlayerItem.Get((int)items[i]);
                client.Character.Player.Inventory.Items.Add(item);
                // update AddToInventory with generic item-object
                client.Send(new Packets.AddToInventory((int)items[i],(int)amounts[i]),"Buy Item");
                // update amout of geons !
            }
        }
开发者ID:KalOnline,项目名称:KaLua,代码行数:30,代码来源:PT_Npc.cs

示例2: SkillExecute

        public static void SkillExecute(Client client, PacketIn packet)
        {
            byte skillId  = packet.ReadByte();
            byte skillLvl = packet.ReadByte();

            client.SkillHandler.Execute(skillId,skillLvl);

            if(packet.PacketSize < 9) {
                client.Send(new Packets.SkillExecute(client.Character,skillId,skillLvl));
                return;
            }
        }
开发者ID:KalOnline,项目名称:KaLua,代码行数:12,代码来源:PT_Skill.cs

示例3: LearnSkill

        public static void LearnSkill(Client client, PacketIn packet)
        {
            byte skillId = packet.ReadByte();
            if(client.Character.Player.SkillPoints >= 1)
            {
                if(!client.Character.Skills.ContainsKey(skillId))
                {
                    using(ISession session = Server.Factory.OpenSession())
                    {
                        PlayerSkill skill = new PlayerSkill();
                        skill.Level       = 1;
                        skill.PlayerId    = client.Character.Player.PlayerId;
                        skill.SkillIndex  = (int)skillId;

                        client.Character.Skills[skillId] = skill;
                        client.Send(new Packets.SkillSet(skillId,(byte)1));

                        using(ITransaction transaction = session.BeginTransaction())
                        {
                            session.Save(skill);
                            transaction.Commit();
                        }
                    }
                    client.Character.Player.SkillPoints--;
                    client.Send(new Packets.ValueChange(0x18,(byte)client.Character.Player.SkillPoints));
                }
            }
        }
开发者ID:KalOnline,项目名称:KaLua,代码行数:28,代码来源:PT_Skill.cs

示例4: SkillRequest

        public static void SkillRequest(Client client,PacketIn packet)
        {
            byte skillId  = packet.ReadByte();
            uint playerId = packet.ReadUInt32();

            client.SkillHandler.Request(skillId,playerId);

            client.Send(new Packets.SkillExecute(client.Character,skillId,1));
        }
开发者ID:KalOnline,项目名称:KaLua,代码行数:9,代码来源:PT_Skill.cs

示例5: PlayerChange

 public static void PlayerChange(Client client, PacketIn packet)
 {
     byte b = packet.ReadByte();
     if(b == 1) {
         client.Send(new Packets.AcceptChange());
         client.UnspawnPlayer();
         client.SendPlayerList();
         return;
     }
 }
开发者ID:BeshoyFD,项目名称:kalsharp,代码行数:10,代码来源:PT_Character.cs

示例6: UpgradeSkill

        public static void UpgradeSkill(Client client, PacketIn packet)
        {
            byte skillId = packet.ReadByte();
            if(client.Character.Player.SkillPoints >= 1)
            {
                if(client.Character.Skills.ContainsKey(skillId))
                {
                    client.Character.Skills[skillId].Level += 1;
                    client.Send(new Packets.SkillSet(skillId,(byte)client.Character.Skills[skillId].Level));
                    using(ISession session = Server.Factory.OpenSession())
                    using(ITransaction transaction = session.BeginTransaction())
                    {
                        session.SaveOrUpdate(client.Character.Skills[skillId]);
                        transaction.Commit();
                    }

                    client.Character.Player.SkillPoints--;
                    client.Send(new Packets.ValueChange(0x18,(byte)client.Character.Player.SkillPoints));
                }
            }
        }
开发者ID:KalOnline,项目名称:KaLua,代码行数:21,代码来源:PT_Skill.cs

示例7: CreatePlayer

        public static void CreatePlayer(Client client, PacketIn packet)
        {
            string name       = packet.ReadString();
            byte type         = packet.ReadByte();
            byte strength     = packet.ReadByte();
            byte health       = packet.ReadByte();
            byte intelligence = packet.ReadByte();
            byte wisdom       = packet.ReadByte();
            byte agility      = packet.ReadByte();
            byte face         = packet.ReadByte();
            byte hair         = packet.ReadByte();

            if((strength + health + intelligence + wisdom + agility) != 5)
            {
                client.Send(new Packets.CharacterCreationError(Packets.CHARACTER_CREATION_ERROR.SHARING_POINTS_ERROR));
                Hackshield.AddOffense(client, OffenseSeverity.IncorrectPacketDetails);
                return;
            }

            //check if name is valid
            if (!Utilities.IsAlnum(name))
            {
                client.Send(new Packets.CharacterError(Packets.CHARACTER_ERROR.INVALID_CHARS));
                return;
            }

            //check if player name is taken
            if (Player.GetPlayer(name) != null)
            {
                client.Send(new Packets.CharacterCreationError(Packets.CHARACTER_CREATION_ERROR.NAME_TAKEN));
                return;
            }

            int playerId = client.CreatePlayer(name, type, strength, health, intelligence, wisdom, agility, face, hair);
            client.SendPlayerList();
        }
开发者ID:BeshoyFD,项目名称:kalsharp,代码行数:36,代码来源:PT_Character.cs

示例8: SessionRequest

 public static void SessionRequest(Client client,PacketIn packet)
 {
     if(packet.ReadByte() == 0) {
         client.Send(new Packets.SessionRequest(),"Session Request");
     }
 }
开发者ID:BeshoyFD,项目名称:kalsharp,代码行数:6,代码来源:PT_SessionRequest.cs

示例9: SetStats

        public static void SetStats(Client client, PacketIn packet)
        {
            int start;
            byte value;

            switch(packet.ReadByte())
            {
                // Strength
                case 0:
                {
                    start = (client.Character.Player.ClassId == 0) ? 60 : 50;
                    value = client.Character.Stats.Strength;

                    _UpdateStats(client,start,value);

                    client.Character.Stats.Strength += 1;
                    client.Send(new Packets.StatPacket.Strength(client.Character.Stats));

                    break;
                }
                // Health
                case 1:
                {
                    start = 50;
                    value = client.Character.Stats.Health;

                    _UpdateStats(client,start,value);

                    client.Character.Stats.Health += 1;
                    client.Send(new Packets.StatPacket.Health(client.Character.Stats));

                    break;
                }
                // Intelligence
                case 2:
                {
                    start = (client.Character.Player.ClassId == 1) ? 60 : 50;
                    value = client.Character.Stats.Intelligence;

                    _UpdateStats(client,start,value);

                    client.Character.Stats.Intelligence += 1;
                    client.Send(new Packets.StatPacket.Intelligence(client.Character.Stats));

                    break;
                }
                // Wisdom
                case 3:
                {
                    start = 50;
                    value = client.Character.Stats.Wisdom;

                    _UpdateStats(client,start,value);

                    client.Character.Stats.Wisdom += 1;
                    client.Send(new Packets.StatPacket.Wisdom(client.Character.Stats));

                    break;
                }
                // Agility
                case 4:
                {
                    start = (client.Character.Player.ClassId == 2) ? 60 : 50;
                    value = client.Character.Stats.Agility;

                    _UpdateStats(client,start,value);

                    client.Character.Stats.Agility += 1;
                    client.Send(new Packets.StatPacket.Agility(client.Character.Stats));

                    break;
                }
            }
        }
开发者ID:KalOnline,项目名称:KaLua,代码行数:74,代码来源:PT_Stats.cs

示例10: SetStats

        public static void SetStats(Client Client, PacketIn packet)
        {
            int Start;
            int Value;

            switch(packet.ReadByte())
            {
                // Strength
                case 0:
                {
                    Start = (Client.Character.Player.Class == 0) ? 60 : 50;
                    Value = Client.Character.Stats.BaseStats.Strength;

                    _UpdateStats(Client,Start,Value);

                    Client.Character.Stats.BaseStats.Strength += 1;
                    Client.Send(new Packets.StatPacket.Strength(Client.Character));

                    break;
                }
                // Health
                case 1:
                {
                    Start = 50;
                    Value = Client.Character.Stats.Health;

                    _UpdateStats(Client,Start,Value);

                    Client.Character.Stats.BaseStats.Health += 1;
                    Client.Send(new Packets.StatPacket.Health(Client.Character));

                    break;
                }
                // Intelligence
                case 2:
                {
                    Start = (Client.Character.Player.Class == 1) ? 60 : 50;
                    Value = Client.Character.Stats.Intelligence;

                    _UpdateStats(Client,Start,Value);

                    Client.Character.Stats.BaseStats.Intelligence += 1;
                    Client.Send(new Packets.StatPacket.Intelligence(Client.Character));

                    break;
                }
                // Wisdom
                case 3:
                {
                    Start = 50;
                    Value = Client.Character.Stats.Wisdom;

                    _UpdateStats(Client,Start,Value);

                    Client.Character.Stats.BaseStats.Wisdom += 1;
                    Client.Send(new Packets.StatPacket.Wisdom(Client.Character));

                    break;
                }
                // Agility
                case 4:
                {
                    Start = (Client.Character.Player.Class == 2) ? 60 : 50;
                    Value = Client.Character.Stats.Dexterity;

                    _UpdateStats(Client,Start,Value);

                    Client.Character.Stats.BaseStats.Dexterity += 1;
                    Client.Send(new Packets.StatPacket.Agility(Client.Character));

                    break;
                }
            }
        }
开发者ID:BeshoyFD,项目名称:kalsharp,代码行数:74,代码来源:PT_Stats.cs


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