Example #1
0
 /// <summary>
 /// This method is called after skills are upgraded and changes the player to reflect the skill upgrades.
 /// It first switches on skill type and then calls player methods to handle changes.
 /// </summary>
 /// <param name="upgradedSkill"></param>
 private void ApplyUpgrade(Skill upgradedSkill)
 {
     if (upgradedSkill.type == SkillType.DMG)
     {
         player.FlatDmgIncrease(upgradedSkill.currentStatIncrease);
     }
     else if (upgradedSkill.type == SkillType.ATTKSPEED)
     {
         player.PctAttackSpeedUpgrade(upgradedSkill.currentStatIncrease);
     }
     else if (upgradedSkill.type == SkillType.KILLREWARD)
     {
         playerMoneyMult = upgradedSkill.currentStatIncrease;
         dataSavingManager.SetOtherValue("MoneyMultiplier", playerMoneyMult);
         dataSavingManager.Save();
     }
     else if (upgradedSkill.type == SkillType.SPAWNSPEED)
     {
         blockSpawner.PctSpawnSpeedUpgrade(upgradedSkill.currentStatIncrease);
     }
     else if (upgradedSkill.type == SkillType.MOVEMENTSPEED)
     {
         player.FlatMovementSpeedIncrease(upgradedSkill.currentStatIncrease);
     }
     else if (upgradedSkill.type == SkillType.HELPER)
     {
         if (upgradedSkill.level == 2)
         {
             Vector2 randPos = new Vector2(UnityEngine.Random.Range(-2f, 2f), UnityEngine.Random.Range(-4f, 4f));
             var helper = Instantiate(helperPrefab, randPos, Quaternion.identity);
             helper.gameObject.GetComponent<Helper>().Init(upgradedSkill.name);
         }
     }
     else if (upgradedSkill.type == SkillType.ABILITY)
     {
         if (upgradedSkill.level == 1)
         {
             EventManager.TriggerEvent("PurchasedAbility", upgradedSkill as Ability);
         }
     }
     else if (upgradedSkill.type == SkillType.BLOCKSPERLEVEL)
     {
         dataSavingManager.SetOtherValue("BlocksPerLevel", (int)dataSavingManager.GetOtherValue("BlocksPerLevel") - (int)upgradedSkill.currentStatIncrease);
         dataSavingManager.Save();
     }
     else if (upgradedSkill.type == SkillType.DAMAGEMULTIPLIER)
     {
         player.PrestigeDamageUpgrade(upgradedSkill.currentStatIncrease);
     }
     else if (upgradedSkill.type == SkillType.AUTOMOVESPEED)
     {
         dataSavingManager.SetOtherValue("AutoMoveSpeedMultiplier", (double)dataSavingManager.GetOtherValue("AutoMoveSpeedMultiplier") * upgradedSkill.currentStatIncrease);
         dataSavingManager.Save();
     }
 }