Ejemplo n.º 1
0
 public void RefreshHeroExperience()
 {
     // Updates hero experience to make sure panels are updated at startup.
     ExperienceToNextLvl      = ExperienceHelper.CalculateXpToNextLvl(this);
     ExperienceToNextLvlTotal = Experience + ExperienceToNextLvl;
     ExperienceProgress       = ExperienceHelper.CalculateXpProgress(this);
 }
Ejemplo n.º 2
0
        /// <summary>
        /// Gives the player their paycheck(s) w/ multipliers applied, also send paycheck notifications.
        /// </summary>
        /// <param name="player"></param>
        public void GivePaycheck(UnturnedPlayer player)
        {
            var paychecks = GetAvailablePaychecks(player);

            if (paychecks.Count == 0)
            {
                return;
            }
            if (!Config.AllowPaychecksWhenDead && player.Dead)
            {
                ShowNotification(player, Translate("paycheck_dead"), Color.yellow);
                return;
            }
            if (!Config.AllowPaychecksInSafezone && player.Player.movement.isSafe)
            {
                ShowNotification(player, Translate("paycheck_safezone"), Color.yellow);
                return;
            }
            if (Config.MinimumMovementBetweenPaychecks > 0.0f)
            {
                if (_playerPositions.ContainsKey(player.CSteamID))
                {
                    var distance = (player.Position - _playerPositions[player.CSteamID]).sqrMagnitude;
                    if (distance <= Mathf.Pow(Config.MinimumMovementBetweenPaychecks, 2))
                    {
                        ShowNotification(player, Translate("paycheck_stationary"), Color.yellow);
                        return;
                    }
                }
                _playerPositions[player.CSteamID] = player.Position;
            }

            var experience = GetPaycheckExperienceSum(paychecks);
            var multiplier = GetPaycheckMultiplier(player.Position, paychecks);

            if (Mathf.Abs(multiplier) > 0.0001f)
            {
                var change          = (int)(experience * multiplier);
                var experienceGiven = ExperienceHelper.ChangeExperience(player, change);
                if (experienceGiven != 0)
                {
                    ShowNotification(player, Translate("paycheck_given", experienceGiven), Color.green);
                }
                else if (change != 0)
                {
                    ShowNotification(player, Translate("paycheck_notgiven", change), Color.yellow);
                }
            }
            else
            {
                ShowNotification(player, Translate("paycheck_zero_multiplier"), Color.yellow);
            }
        }
Ejemplo n.º 3
0
    public void GainExperience(int experienceGained)
    {
        foreach (var artifact in User.Instance.CurrentHero.EquippedArtifacts)
        {
            artifact.ArtifactFunctionality.OnExperienceGained(ref experienceGained);
        }

        if (ExperienceToNextLvl != 0)
        {
            User.Instance.Achievements.IncreaseAchievementValue(NumericAchievementType.ExperienceGained, experienceGained);
        }

        (Application.Current.MainWindow as GameWindow).CreateFloatingTextUtility($"+{experienceGained}", (SolidColorBrush)Application.Current.FindResource("BrushExperienceRelated"), FloatingTextHelper.ExperiencePositionPoint);

        Experience += experienceGained;
        ExperienceHelper.CheckIfLeveledUpAndGrantBonuses(this);
        ExperienceToNextLvl      = ExperienceHelper.CalculateXpToNextLvl(this);
        ExperienceToNextLvlTotal = Experience + ExperienceToNextLvl;
        ExperienceProgress       = ExperienceHelper.CalculateXpProgress(this);
    }
Ejemplo n.º 4
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();
    }
Ejemplo n.º 5
0
 public static int GetXp(int cr)
 {
     return(ExperienceHelper.GetXp(EncounterType.Mob, cr, 1f, (IntEvaluator)null));
 }