Пример #1
0
        private void HandleCharacterSelectionMessage(String address, AbstractMessage message)
        {
            CharacterSelectionMessage characterSelectionMessage = (CharacterSelectionMessage)message;

            Player currentPlayer = controller.GetPlayer(IPAddress.Parse(address));

            currentPlayer.ClearCharacters();
            foreach (String rootName in characterSelectionMessage.SelectedCharacters)
            {
                currentPlayer.AddCharacter(Bundle.Characters[rootName]);
            }

            foreach (Player player in controller.GetPlayers())
            {
                if (player.GetCharacters().Count == 0)
                {
                    controller.Server.SendData(currentPlayer.IPAddress, new WaitingOponentMessage());
                    return;
                }
            }

            BattleEngine.Initialize(controller.GetLocalPlayer(), controller.GetRemotePlayer());
            StartGameMessage startGameMessage = new StartGameMessage();

            serverStatus = ServerStatus.WaitingCharacterPosition;

            controller.Server.SendToAll(startGameMessage);
        }
Пример #2
0
 public static void HandleCharacterSelection(CharacterSelectionMessage message, WorldClient client)
 {
     if (!client.InGame)
     {
         client.Character = new Character(client, client.GetAccountCharacter((long)message.id), false);
         ProcessSelection(client);
     }
 }
Пример #3
0
        public void HandleSelectionCharacter(CharactersListMessage message)
        {
            var character = message.characters[0];
            CharacterSelectionMessage reponse = new CharacterSelectionMessage(character.id);

            client.Network.Send(reponse);
            new ChatFrame(client);
            Optimus.Common.Log.Logger.GetInstance("PlayerD{Debug}").Debug(string.Format("Character : {0} level : {1} selected.", character.name, character.level));
        }
        public static void HandleCharacterSelectionMessage(WorldClient client, CharacterSelectionMessage message)
        {
            CharacterRecord characterRecord = client.Characters.First((CharacterRecord entry) => entry.Id == message.id);

            if (characterRecord == null)
            {
                client.Send(new CharacterSelectedErrorMessage());
            }
            else
            {
                CharacterHandler.CommonCharacterSelection(client, characterRecord);
            }
        }
Пример #5
0
        private void HandleCharacterSelectionMessage(String address, AbstractMessage message)
        {
            CharacterSelectionMessage characterSelectionMessage = (CharacterSelectionMessage)message;

            clientStatus = ClientStatus.CharacterSelection;

            controller.SupressUpdate();

            ScreenManager.GetInstance().RemoveLastScreen();
            ScreenManager.GetInstance().AddScreen(new CharacterSelectionScreen());

            controller.ReleaseUpdate();
        }
Пример #6
0
        public static void HandleCharacterSelectionMessage(WorldClient client, CharacterSelectionMessage message)
        {
            var character = client.Characters.Where(x => !x.IsDeleted).First(entry => entry.Id == message.id);

            /* Check null */
            if (character == null)
            {
                client.Send(new CharacterSelectedErrorMessage());
                return;
            }

            /* Common selection */
            CommonCharacterSelection(client, character);
        }
Пример #7
0
        public void CharacterSelectionMessageFrame(WorldClient client, CharacterSelectionMessage characterSelectionMessage)
        {
            var character = CharacterRepository.Instance.GetCharacterById((int)characterSelectionMessage.id);

            if (character == null)
            {
                client.SendPacket(new CharacterSelectedErrorMessage());
                return;
            }

            client.ActiveCharacter = character;

            this.SendCharacterListMessage(client);
            this.SendCharacterSelectionSuccess(client);
        }
Пример #8
0
        public static void OnCharacterSelection(INetworkClient client, CharacterSelectionMessage csm)
        {
            var loginEntity     = client.GetEntity();
            var characterEntity = EntityManager.Instance.Get((uint)csm.CharacterId);

            characterEntity.AddComponent <AccountComponent>();
            characterEntity.AddComponent <NetworkComponent>();
            characterEntity.AddComponent <MapComponent>();
            characterEntity.AddComponent <GameContextComponent>();
            characterEntity.Account().AccountId = loginEntity.Account().AccountId;
            characterEntity.Network().Client    = loginEntity.Network().Client;
            characterEntity.RefId = loginEntity.RefId;
            EntityManager.Instance.Delete(loginEntity.Id);

            client.Send(new CharacterSelectedSuccessMessage(characterEntity));
            client.Send(new CharacterLoadingCompleteMessage());
            characterEntity.Notify(new ClientEnteringGameEventArgs());
        }
Пример #9
0
        public static void CharactersListMessageTreatment(Message message, byte[] packetDatas, AccountUC account)
        {
            CharactersListMessage charactersListMessage = (CharactersListMessage)message;

            using (BigEndianReader reader = new BigEndianReader(packetDatas))
            {
                charactersListMessage.Deserialize(reader);
            }

            account.CharacterBaseInformations = charactersListMessage.characters[0];

            //MainForm.ActualMainForm.ActualizeAccountInformations();

            if (!account.IsMITM)
            {
                CharacterSelectionMessage characterSelectionMessage = new CharacterSelectionMessage(account.CharacterBaseInformations.id);
                account.SocketManager.Send(characterSelectionMessage);
            }
        }
Пример #10
0
        public static void CharactersListMessageTreatment(Message message, byte[] packetDatas, AccountUC account)
        {
            CharactersListMessage charactersListMessage = (CharactersListMessage)message;

            //packetDatas = packetDatas.ToList().SkipWhile(a => a == 0).ToArray();

            using (BigEndianReader reader = new BigEndianReader(packetDatas))
            {
                charactersListMessage.Deserialize(reader);
            }

            account.CharacterBaseInformations = charactersListMessage.Characters[0];

            //MainForm.ActualMainForm.ActualizeAccountInformations();

            if (!account.IsMITM)
            {
                CharacterSelectionMessage characterSelectionMessage = new CharacterSelectionMessage((ulong)account.CharacterBaseInformations.ObjectID);
                account.SocketManager.Send(characterSelectionMessage);
            }
        }
 public static void HandleCharacterSelection(CharacterSelectionMessage message, WorldClient client)
 {
     client.Character = new Character(CharacterRecord.GetCharacterRecordById(message.id), client);
     ProcessSelection(client);
 }
Пример #12
0
 public void CharacterSelectionMessageFrame(GameClient client,
                                            CharacterSelectionMessage characterSelectionMessage)
 {
     Container.Instance().Resolve <ICharacterManager>()
     .CharacterSelection(client, characterSelectionMessage.id);
 }
Пример #13
0
        public override void Update(float passedTime)
        {
            characterPointer.Update(passedTime);
            pointer.Update(passedTime);

            if (KeyboardManager.Manager.TypedKeys.Contains(Keys.Escape))
            {
                Controller.GetInstance().StopClient();
                Controller.GetInstance().StopServer();

                ScreenManager.GetInstance().RemoveLastScreen(true);
                AudioManager.PlaySound("menu_accept");
            }

            if (KeyboardManager.Manager.TypedKeys.Contains(Keys.Enter))
            {
                if (Selection < 10)
                {
                    if (selectedCharacters.Contains(characters[Selection].RootName))
                    {
                        selectedCharacters.Remove(characters[Selection].RootName);
                        AudioManager.PlaySound("menu_select");
                    }
                    else if (selectedCharacters.Count < Constants.MAX_CHARACTERS)
                    {
                        selectedCharacters.Add(characters[Selection].RootName);
                        AudioManager.PlaySound("menu_select");
                    }
                }

                else if (selectedCharacters.Count == Constants.MAX_CHARACTERS && Selection == 10)
                {
                    CharacterSelectionMessage message = new CharacterSelectionMessage();
                    Player localPlayer = Controller.GetInstance().GetLocalPlayer();

                    localPlayer.ClearCharacters();
                    foreach (String characterName in selectedCharacters)
                    {
                        if (!Controller.GetInstance().IsServer)
                        {
                            localPlayer.AddCharacter(Bundle.Characters[characterName]);
                        }

                        message.SelectedCharacters.Add(characterName);
                    }

                    Controller.GetInstance().Client.SendData(message);

                    AudioManager.PlaySound("menu_accept");
                }

                else if (Selection == 11)
                {
                    Controller.GetInstance().QuitGame(true, true);
                    Controller.GetInstance().StopServer();
                    Controller.GetInstance().StopClient();
                    AudioManager.PlaySound("menu_accept");
                }
            }

            if (KeyboardManager.Manager.TypedKeys.Contains(Keys.Down))
            {
                if (selection < 5)
                {
                    Selection += 5;
                }
                else if (selection < 10)
                {
                    if (selectedCharacters.Count == Constants.MAX_CHARACTERS)
                    {
                        Selection = 10;
                    }
                    else
                    {
                        Selection = 11;
                    }
                }
            }

            if (KeyboardManager.Manager.TypedKeys.Contains(Keys.Up))
            {
                if (selection >= 10)
                {
                    Selection = characterPointer.Selection;
                }
                else if (selection >= 5)
                {
                    Selection -= 5;
                }
            }

            if (KeyboardManager.Manager.TypedKeys.Contains(Keys.Left))
            {
                if (selection > 0 && selection < 10)
                {
                    Selection--;
                }
                else if (selection == 0)
                {
                    Selection = 9;
                }
                else if (selection == 11 && selectedCharacters.Count == Constants.MAX_CHARACTERS)
                {
                    Selection = 10;
                }
            }

            if (KeyboardManager.Manager.TypedKeys.Contains(Keys.Right))
            {
                if (selection < 9)
                {
                    Selection++;
                }
                else if (selection == 9)
                {
                    Selection = 0;
                }
                else
                {
                    Selection = 11;
                }
            }

            foreach (IMenuItem menuItem in menuItems)
            {
                menuItem.Update(passedTime);
            }

            foreach (IMenuItem characterImage in characterItems)
            {
                characterImage.Update(passedTime);
            }
        }
Пример #14
0
 public static void HandleCharacterSelectionMessage(Client client, CharacterSelectionMessage message)
 {
     SelectCharacter(client, message.id);
 }