Ejemplo n.º 1
0
        private CharacterCreation GetCharacterCreation()
        {
            if (!CbCreateCharacter.IsChecked.Value)
            {
                return(new CharacterCreation());
            }

            return(new CharacterCreation()
            {
                Create = true,
                Name = TxtName.Text,
                Server = CmbServerCC.Text,
                Breed = CbRandomBreed.IsChecked.Value ? -1 : (CmbRace.SelectedItem as Breeds).Id,
                Sex = CbRandomSex.IsChecked.Value ? -1 : CmbSex.SelectedIndex,
                Head = CbRandomHead.IsChecked.Value ? -1 : CmbHead.SelectedIndex,
                Colors = new List <int>(5)
                {
                    BreedsUtility.GetIndexedColor(1, (RectColor1.Fill as SolidColorBrush).Color),
                    BreedsUtility.GetIndexedColor(2, (RectColor2.Fill as SolidColorBrush).Color),
                    BreedsUtility.GetIndexedColor(3, (RectColor3.Fill as SolidColorBrush).Color),
                    BreedsUtility.GetIndexedColor(4, (RectColor4.Fill as SolidColorBrush).Color),
                    BreedsUtility.GetIndexedColor(5, (RectColor5.Fill as SolidColorBrush).Color),
                },
                ParametersToCopy = CmbParameters.SelectedIndex == 0 ? "" : CmbParameters.Text,
                FightsConfigurationToCopy = CmbFightsConfigurations.SelectedIndex == 0 ? "" : CmbFightsConfigurations.Text,
                CompleteTutorial = CmbCompleteTutorial.IsChecked.Value
            });
        }
Ejemplo n.º 2
0
        private void SetBreedBaseColors(Breeds breed)
        {
            var baseColors = BreedsUtility.GetBreedBaseColors(breed, CmbSex.SelectedIndex);

            RectColor1.Fill = new SolidColorBrush(baseColors[0]);
            RectColor2.Fill = new SolidColorBrush(baseColors[1]);
            RectColor3.Fill = new SolidColorBrush(baseColors[2]);
            RectColor4.Fill = new SolidColorBrush(baseColors[3]);
            RectColor5.Fill = new SolidColorBrush(baseColors[4]);
        }
Ejemplo n.º 3
0
        private void HandleFilesHashesMessage(FilesHashesMessage message)
        {
            Application.Current.Dispatcher.Invoke(async() =>
            {
                // Updater
                if (await this.ShowUpdatesAsync(message.FilesHashes))
                {
                    Environment.Exit(0);
                    return;
                }

                // Loading
                try
                {
                    var controller = await this.ShowProgressAsync(LanguageManager.Translate("483"), Randomize.GetRandomLoadingText());

                    await Task.Run(async() =>
                    {
                        Protocol.Messages.MessagesBuilder.Initialize();
                        controller.SetProgress(0.14);
                        await Task.Delay(200);

                        TypesBuilder.Initialize();
                        controller.SetProgress(0.28);
                        await Task.Delay(200);

                        DataManager.Initialize(DTConstants.AssetsVersion, GlobalConfiguration.Instance.Lang);
                        controller.SetProgress(0.42);
                        await Task.Delay(200);

                        MapsManager.Initialize(DTConstants.AssetsVersion);
                        controller.SetProgress(0.56);
                        await Task.Delay(200);

                        FramesManager.Initialize();
                        controller.SetProgress(0.70);
                        await Task.Delay(200);

                        CommandsHandler.Initialize();

                        BreedsUtility.Initialize();
                        controller.SetProgress(1);
                        await Task.Delay(200);

                        LuaScriptManager.Initialize();
                    });

                    await controller.CloseAsync();
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.ToString());
                }
            });
        }
Ejemplo n.º 4
0
        private void RefreshBreedInfos()
        {
            var breed = CmbRace.SelectedItem as Breeds;

            if (breed == null)
            {
                return;
            }

            // Heads
            CmbHead.ItemsSource   = BreedsUtility.GetBreedHeads(breed.Id, CmbSex.SelectedIndex);
            CmbHead.SelectedIndex = 0;

            // Colors
            SetBreedBaseColors(breed);
        }
Ejemplo n.º 5
0
        public async Task Update(CharactersListMessage message)
        {
            if (!_account.AccountConfig.CharacterCreation.Create)
            {
                return;
            }

            // If the character has been successfuly created
            if (_created)
            {
                // Set Create to false so that we don't create a character each time we connect
                _account.AccountConfig.CharacterCreation.Create = false;
                GlobalConfiguration.Instance.Save();

                // Copy configurations if asked for
                try
                {
                    if (!string.IsNullOrEmpty(_account.AccountConfig.CharacterCreation.ParametersToCopy))
                    {
                        File.Copy(Path.Combine(Configuration.ConfigurationsPath, _account.AccountConfig.CharacterCreation.ParametersToCopy),
                                  Path.Combine(Configuration.ConfigurationsPath, $"{_account.AccountConfig.Username}_{message.Characters[0].Name}.config"), overwrite: true);
                        _account.Logger.LogInfo(LanguageManager.Translate("516"), LanguageManager.Translate("519"));
                    }
                    if (!string.IsNullOrEmpty(_account.AccountConfig.CharacterCreation.FightsConfigurationToCopy))
                    {
                        File.Copy(Path.Combine(FightsConfiguration.ConfigurationsPath, _account.AccountConfig.CharacterCreation.FightsConfigurationToCopy),
                                  Path.Combine(FightsConfiguration.ConfigurationsPath, $"{_account.AccountConfig.Username}_{message.Characters[0].Name}.fconfig"), overwrite: true);
                        _account.Logger.LogInfo(LanguageManager.Translate("516"), LanguageManager.Translate("520"));
                    }
                }
                catch (Exception ex)
                {
                    _account.Logger.LogError(LanguageManager.Translate("516"), ex.ToString());
                }

                _account.Logger.LogDebug(LanguageManager.Translate("516"), LanguageManager.Translate("521", message.Characters[0].Name));
                _account.Network.SendMessage(new CharacterFirstSelectionMessage((int)message.Characters[0].Id, true));
                return;
            }

            _account.Logger.LogInfo(LanguageManager.Translate("516"), LanguageManager.Translate("522"));
            string name      = _account.AccountConfig.CharacterCreation.Name;
            int    breed     = _account.AccountConfig.CharacterCreation.Breed == -1 ? Randomize.GetRandomInt(1, BreedsUtility.Breeds.Max(b => b.Id) + 1) : _account.AccountConfig.CharacterCreation.Breed;
            bool   sex       = (_account.AccountConfig.CharacterCreation.Sex == -1 ? Randomize.GetRandomInt(0, 2) : _account.AccountConfig.CharacterCreation.Sex) == 1;
            int    headOrder = _account.AccountConfig.CharacterCreation.Head == -1 ? Randomize.GetRandomInt(0, 8) : _account.AccountConfig.CharacterCreation.Head;

            // If the user wanted a random name, use DT's random name generator
            if (name == "")
            {
                _account.Logger.LogDebug(LanguageManager.Translate("516"), LanguageManager.Translate("523"));
                _nameTcs = new TaskCompletionSource <string>();
                _account.Network.SendMessage(new CharacterNameSuggestionRequestMessage());
                _nameTcs.Task.Wait();
                name = _nameTcs.Task.Result;
                _account.Logger.LogInfo(LanguageManager.Translate("516"), LanguageManager.Translate("524", name));
            }

            await Task.Delay(1000);

            // Send the character creation request message, take in consideration random stuff to generate
            _account.Network.SendMessage(new CharacterCreationRequestMessage(name, breed, sex, (uint)BreedsUtility.GetCosmeticId(breed, sex, headOrder), _account.AccountConfig.CharacterCreation.Colors));
        }