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


C# GameClient.Send方法代码示例

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


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

示例1: OnCharacterCreate

        public static void OnCharacterCreate(GameClient client, ClientHeroCreatePacket packet)
        {
            Logger.Instance.Info("Attempting to create hero with name {0}", packet.Name);
            bool heroExists;

            using (var context = new GameDatabaseContext())
            {
                // We try to load a hero with a similar name to see if they exist
                heroExists = context.Characters.Any(x => x.Name.ToUpper() == packet.Name.ToUpper());
            }

            if (heroExists)
            {
                client.Send(new ServerHeroCreateResponsePacket(HeroStatus.Invalid));
                return;
            }

            // Create a hero and attach it if it dosen't exist yet

            var hero = new UserHero(client.Account, 0, 0, 0, packet.Name);

            // Save our hero into the database
            using (var context = new GameDatabaseContext())
            {
                context.Accounts.Attach(client.Account);
                context.Entry(client.Account).Collection(a => a.Heroes).Load();
                client.Account.Heroes.Add(hero);
                context.SaveChanges();
            }

            client.Send(new ServerHeroCreateResponsePacket(HeroStatus.OK));

            SendHeroList(client);
        }
开发者ID:gitter-badger,项目名称:OpenORPG,代码行数:34,代码来源:HeroSelectionHandler.cs

示例2: Finish

 public static void Finish(GameClient Client)
 {
     NpcDialog* Packet = PacketHelper.NpcPacket();
     Packet->OptionType = NpcOptionType.Finish;
     Client.Send(Packet, Packet->Size);
     Memory.Free(Packet);
 }
开发者ID:uvbs,项目名称:conquerserver,代码行数:7,代码来源:NpcDialogBuilder.cs

示例3: Text

 public static void Text(GameClient Client, string Text)
 {
     NpcDialog* Packet = PacketHelper.NpcPacket(Text);
     Packet->OptionType = NpcOptionType.Dialogue;
     Client.Send(Packet, Packet->Size);
     Memory.Free(Packet);
 }
开发者ID:uvbs,项目名称:conquerserver,代码行数:7,代码来源:NpcDialogBuilder.cs

示例4: Option

 public static void Option(GameClient Client, byte OptionID, string Text)
 {
     NpcDialog* Packet = PacketHelper.NpcPacket(Text);
     Packet->OptionType = NpcOptionType.Option;
     Packet->OptionID = OptionID;
     Client.Send(Packet, Packet->Size);
     Memory.Free(Packet);
 }
开发者ID:uvbs,项目名称:conquerserver,代码行数:8,代码来源:NpcDialogBuilder.cs

示例5: Avatar

 public static void Avatar(GameClient Client, ushort ID)
 {
     NpcDialog* Packet = PacketHelper.NpcPacket();
     Packet->OptionType = NpcOptionType.Avatar;
     Packet->Extra = ID;
     Client.Send(Packet, Packet->Size);
     Memory.Free(Packet);
 }
开发者ID:uvbs,项目名称:conquerserver,代码行数:8,代码来源:NpcDialogBuilder.cs

示例6: OnStorageDropRequest

        public static void OnStorageDropRequest(GameClient client, ClientDropStorageRequestPacket packet)
        {
            var hero = client.HeroEntity;

            for (int i = 0; i < packet.Amount; i++)
                hero.Backpack.RemoveSingleAt(packet.SlotId);

            var outboundPacket = new ServerSendHeroStoragePacket(hero.Backpack, StorageType.Inventory);
            client.Send(outboundPacket);
        }
开发者ID:gitter-badger,项目名称:OpenORPG,代码行数:10,代码来源:StorageHandler.cs

示例7: OnCharacterSelect

        public static void OnCharacterSelect(GameClient client, ClientHeroSelectPacket packet)
        {
            // Get the hero the user wanted
            var hero = client.Account.Heroes.FirstOrDefault(x => x.Id == packet.HeroId);

            if (hero == null)
            {
                var response = new ServerHeroSelectResponsePacket(HeroStatus.Invalid);
                client.Send(response);
            }
            else
            {
                client.SelectedHero = hero; //TODO: remove and use gameobject hero

                var response = new ServerHeroSelectResponsePacket(HeroStatus.OK);
                client.Send(response);

                var zone = ZoneManager.Current.FindZone(hero.ZoneName);

                zone.OnClientEnter(client, hero);
            }
        }
开发者ID:GrindFest,项目名称:GrindFest,代码行数:22,代码来源:HeroSelectionHandler.cs

示例8: OnLoginRequest

        public static void OnLoginRequest(GameClient client, ClientLoginRequestPacket packet)
        {
            Logger.Instance.Info("LoginHandler.OnLoginRequest", client, packet);

            UserAccount account;

            bool loginSuccessful = AuthenticationProvider.Authenticate(packet.Username, packet.Password, out account);

            if (!loginSuccessful)
            {
                client.Send(new ServerLoginResponsePacket(LoginStatus.InvalidCredentials));
                return;
            }

            if (account.IsOnline)
            {
                client.Send(new ServerLoginResponsePacket(LoginStatus.AlreadyLoggedIn));
                return;
            }

            client.Account = account;

            using (var context = new GameDatabaseContext())
            {
                context.Accounts.Attach(account);

                account.IsOnline = true;

                context.SaveChanges();

                // Load heroes
                context.Entry(account).Collection(a => a.Heroes).Load();
            }

            client.Send(new ServerLoginResponsePacket(LoginStatus.OK));

            HeroSelectionHandler.SendHeroList(client);
        }
开发者ID:gitter-badger,项目名称:OpenORPG,代码行数:38,代码来源:LoginHandler.cs

示例9: OnPlayerDialogLinkSelection

        public static void OnPlayerDialogLinkSelection(GameClient client, ClientDialogLinkSelectionPacket packet)
        {
            var player = client.HeroEntity;

            if (player == null)
                return;

            // You have to be near the NPC to actually interact with it
            var interactable = GetNearestInteractable(player);

            if(interactable != null)
                player.Zone.GetGameSystem<DialogService>().AdvanceDialog(player, interactable, packet.LinkId);
            else
                client.Send(new ServerSendGameMessagePacket(GameMessage.InteractableTooFar));
        }
开发者ID:gitter-badger,项目名称:OpenORPG,代码行数:15,代码来源:InteractionHandler.cs

示例10: OnStorageSlotMoveRequest

        public static void OnStorageSlotMoveRequest(GameClient client, ClientStorageMoveSlotPacket packet)
        {
            var hero = client.HeroEntity;

            bool moveSuccessful = false;

            switch (packet.StorageType)
            {
                case StorageType.Inventory:
                    moveSuccessful = hero.Backpack.MoveTo(packet.SourceSlot, packet.DestSlot);
                    break;
            }

            // Send a full inventory update to the client
            var outboundPacket = new ServerSendHeroStoragePacket(hero.Backpack, packet.StorageType);
            client.Send(outboundPacket);
        }
开发者ID:gitter-badger,项目名称:OpenORPG,代码行数:17,代码来源:StorageHandler.cs

示例11: OnPlayerAcceptQuest

        public static void OnPlayerAcceptQuest(GameClient client, ClientAcceptQuestPacket packet)
        {
            var player = client.HeroEntity;
            var result = new ServerQuestAcceptResultPacket(false);

            // We need to query the surrounding NPCs to see if they can give us the quest we need
            var quest = FindQuestInZoneOrReturnNull(player.Zone, packet.QuestId);

            if (quest != null)
            {
                // Give the player the quest if it's at all possible
                if (QuestManager.Instance.CanPlayerGetQuest(quest, player))
                {
                    QuestManager.Instance.GivePlayerQuest(quest, player);
                    result.Succeeded = true;
                }
            }

            // Notify the client
            client.Send(result);
        }
开发者ID:gitter-badger,项目名称:OpenORPG,代码行数:21,代码来源:QuestHandler.cs

示例12: InternalProcess

        private void InternalProcess(GameClient Client, byte[] Packet)
        {
            fixed (byte* pPacket = Packet)
            {
                ushort *Size = (ushort*)(pPacket + 0);
                ushort* Type = (ushort*)(pPacket + 2);

                if (*Size != Packet.Length)
                {
                    SizeMismatch(Client, *Size, Packet);
                    return;
                }

                Kernel.HexDump(Packet, "Client -> Server");

                IPacketProcessor processor = null;
                switch (*Type)
                {
                    case 0x3E9: processor = new CreateCharacterProcessor(Database); break;
                    case 0x3EC: processor = new ChatProcessor(Database, CommandProcessor, NpcScriptEngine); break;
                    case 0x3ED: processor = new MovementProcessor(Database); break;
                    case 0x3F1: processor = new ItemUsageProcessor(Database); break;
                    case 0x3F2: processor = new GeneralDataProcessor(Database); break;
                    case 0x3FE: processor = new AttackProcessor(Database); break;
                    case 0x41C: processor = new LoginTransferProcessor(Database); break;
                    case 0x7EF:
                    case 0x7F0:
                        processor = new NpcProcessor(Database, NpcScriptEngine);
                        break;
                    default:
                        Client.Send(Packet);
                        break;
                }

                if (processor != null)
                {
                    processor.Execute(Client, pPacket);
                }
            }
        }
开发者ID:uvbs,项目名称:conquerserver,代码行数:40,代码来源:PacketProcessor.cs

示例13: OnCharacterSelect

        public static void OnCharacterSelect(GameClient client, ClientHeroSelectPacket packet)
        {
            // Ensure this is a valid action
            bool actionCanBePerformed = client.Account.IsOnline && client.HeroEntity == null;

            if (!actionCanBePerformed)
                return;

            // Get the hero the user wanted
            UserHero hero = client.Account.Heroes.FirstOrDefault();

            if (hero == null)
            {
                var response = new ServerHeroSelectResponsePacket(HeroStatus.Invalid);
                client.Send(response);
            }
            else
            {

                using (var context = new GameDatabaseContext())
                {
                    context.Characters.Attach(hero);
                    context.Entry(hero).Collection(a => a.Skills).Load();
                    context.Entry(hero).Collection(a => a.Inventory).Load();
                    context.Entry(hero).Collection(a => a.QuestInfo).Load();
                    context.Entry(hero).Collection(a => a.Flags).Load();

                    // Load up our set of requirements from the table
                    foreach (var x in hero.QuestInfo)
                        context.Entry(x).Collection(a => a.RequirementProgress).Load();

                    context.Entry(hero).Collection(a => a.Equipment).Load();
                }

                // Create an object and assign it the world if everything is okay
                var heroObject = GameObjectFactory.CreateHero(hero, client);
                client.HeroEntity = heroObject;

                var zone = ZoneManager.Instance.FindZone(hero.ZoneId);

                if (zone != null)
                {
                    // Create a response and alert the client that their selection is okay
                    var response = new ServerHeroSelectResponsePacket(HeroStatus.OK);
                    client.Send(response);

                    // Here, we should queue the player for login

                    Logger.Instance.Info("{0} has entered the game.", hero.Name);
                    zone.QueueLogin(heroObject);

                    // Add to global manager
                    ChatManager.Current.Global.Join(client);

                }
                else
                {
                    var response = new ServerHeroSelectResponsePacket(HeroStatus.Unavailable);
                    client.Send(response);

                    Logger.Instance.Error("{0} attempted to enter the game but could not be loaded.", hero.Name);
                }

            }
        }
开发者ID:gitter-badger,项目名称:OpenORPG,代码行数:65,代码来源:HeroSelectionHandler.cs

示例14: Join

 public void Join(GameClient client)
 {
     client.Send(new ServerJoinChannelPacket(Id, Type, null));
     Clients.Add(client);
 }
开发者ID:gitter-badger,项目名称:OpenORPG,代码行数:5,代码来源:ChatManager.cs

示例15: SendHeroList

        public static void SendHeroList(GameClient client)
        {
            var list = new List<HeroInfo>();

            foreach (UserHero hero in client.Account.Heroes)
            {
                var info = new HeroInfo();
                info.HeroId = hero.UserHeroId;
                info.Name = hero.Name;
                list.Add(info);
            }

            client.Send(new ServerHeroListPacket(list));
        }
开发者ID:gitter-badger,项目名称:OpenORPG,代码行数:14,代码来源:HeroSelectionHandler.cs


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