Beispiel #1
0
    private void AssignRewards()
    {
        User.Instance.Achievements.NumericAchievementCollection[NumericAchievementType.QuestsCompleted]++;

        foreach (var materialRewardPattern in QuestRewardPatterns.Where(x => x.QuestRewardType == RewardType.Material))
        {
            var material = GameAssets.Materials.FirstOrDefault(x => x.Id == materialRewardPattern.QuestRewardId);
            material.AddItem(materialRewardPattern.Quantity);
        }

        foreach (var artifactRewardPattern in QuestRewardPatterns.Where(x => x.QuestRewardType == RewardType.Artifact))
        {
            var artifact = GameAssets.Artifacts.FirstOrDefault(x => x.Id == artifactRewardPattern.QuestRewardId);
            artifact.AddItem(artifactRewardPattern.Quantity);
        }

        foreach (var recipeRewardPattern in QuestRewardPatterns.Where(x => x.QuestRewardType == RewardType.Recipe))
        {
            var recipe = GameAssets.Recipes.FirstOrDefault(x => x.Id == recipeRewardPattern.QuestRewardId);
            recipe.AddItem(recipeRewardPattern.Quantity);
        }

        foreach (var ingotRewardPattern in QuestRewardPatterns.Where(x => x.QuestRewardType == RewardType.Ingot))
        {
            var ingot = GameAssets.Ingots.FirstOrDefault(x => x.Id == ingotRewardPattern.QuestRewardId);
            ingot.AddItem(ingotRewardPattern.Quantity);
        }

        foreach (var blessingRewardPattern in QuestRewardPatterns.Where(x => x.QuestRewardType == RewardType.Blessing))
        {
            Blessing.AskUserAndSwapBlessing(blessingRewardPattern.QuestRewardId);
        }

        var experienceReward = ExperienceHelper.CalculateQuestXpReward(Duration);

        User.Instance.CurrentHero.GainExperience(experienceReward);

        InterfaceHelper.RefreshCurrentEquipmentPanelTabOnCurrentPage();
        InterfaceHelper.RefreshQuestInterfaceOnCurrentPage();
    }
Beispiel #2
0
    private void BuyButton_Click(object sender, RoutedEventArgs e)
    {
        var b = sender as Button;
        var blessingBlueprint = b.CommandParameter as Blessing;

        if (User.Instance.Gold >= blessingBlueprint.Value)
        {
            var buyInlines = new List <Inline>
            {
                new Run("Are you sure you want to buy "),
                new Run($"{blessingBlueprint.Name}")
                {
                    FontFamily = (FontFamily)FindResource("FontRegularDemiBold")
                },
                new Run(" for "),
                new Run($"{blessingBlueprint.Value} gold")
                {
                    Foreground = (SolidColorBrush)FindResource("BrushGold"),
                    FontFamily = (FontFamily)FindResource("FontRegularDemiBold")
                },
                new Run("?")
            };

            var result = AlertBox.Show(buyInlines);

            if (result == MessageBoxResult.No)
            {
                return;
            }

            var hasBlessingActive = User.Instance.CurrentHero.Blessing != null;

            if (hasBlessingActive)
            {
                var doesUserWantToSwap = Blessing.AskUserAndSwapBlessing(blessingBlueprint.Id);

                if (doesUserWantToSwap == false)
                {
                    return;
                }
            }
            else
            {
                Blessing.AddOrReplaceBlessing(blessingBlueprint.Id);
            }

            (Application.Current.MainWindow as GameWindow).CreateFloatingTextUtility($"-{blessingBlueprint.Value}", (SolidColorBrush)FindResource("BrushGold"), FloatingTextHelper.GoldPositionPoint);

            User.Instance.Gold -= blessingBlueprint.Value;

            UpdatePriest();
        }
        else
        {
            var notEnoughGoldInlines = new List <Inline>
            {
                new Run("You do not have enough gold to buy this blessing.\nIt costs "),
                new Run($"{blessingBlueprint.Value} gold")
                {
                    Foreground = (SolidColorBrush)FindResource("BrushGold"),
                    FontFamily = (FontFamily)FindResource("FontRegularDemiBold")
                },
                new Run(".\nYou can get more gold by completing quests and selling loot from monsters and bosses.")
            };

            AlertBox.Show(notEnoughGoldInlines, MessageBoxButton.OK);
        }
    }