コード例 #1
0
        public _Status Purchase(bool useRsc = true)
        {
            if (useRsc)
            {
                if (PerkManager.UseRscManagerForCost())
                {
                    RscManager.SpendRsc(GetPurchaseCostRsc());
                }
                else
                {
                    PerkManager.SpendRsc(GetPurchaseCost());
                }
            }
            status = _Status.Purchased;

            if (PerkManager.InGameScene())
            {
                if (type == _PerkType.NewTower)
                {
                    TowerManager.AddBuildable(newTowerPID, replaceTowerPID);
                }
                if (type == _PerkType.NewAbility)
                {
                    AbilityManager.AddAbility(newAbilityPID, replaceAbilityPID);
                }
                else if (type == _PerkType.ModifyTower)              // || type==_PerkType.TowerAll){
                {
                    PerkManager.AddUnitPerkID(prefabID);            SetupCallback();
                }
                else if (type == _PerkType.ModifyAbility)              // || type==_PerkType.AbilityAll){
                {
                    PerkManager.AddAbilityPerkID(prefabID); SetupCallback();
                }
                else if (type == _PerkType.ModifyEffect)
                {
                    PerkManager.AddEffectPerkID(prefabID);  SetupCallback();
                }
                else if (type == _PerkType.ModifyPerkCost)
                {
                    PerkManager.AddPerkPerkID(prefabID);
                }
                else if (type == _PerkType.LifeCap)
                {
                    GameControl.ModifyLifeCap((int)gain);
                }
                else if (type == _PerkType.GainLife)
                {
                    GameControl.GainLife((int)gain);
                }
                else if (type == _PerkType.LifeRegen)
                {
                    if (!IsMultiplier())
                    {
                        GameControl.ModifyLifeRegen(gain);
                    }
                    else
                    {
                        GameControl.ModifyLifeRegenMultiplier(gain);
                    }
                }
                else if (type == _PerkType.LifeGainWaveCleared)
                {
                    if (!IsMultiplier())
                    {
                        PerkManager.lifeGainOnWaveClearedMod += (int)Mathf.Round(gain);
                    }
                    else
                    {
                        PerkManager.lifeGainOnWaveClearedMul *= gain;
                    }
                }
                else if (type == _PerkType.GainRsc)
                {
                    RscManager.GainRsc(gainList);
                }
                else if (type == _PerkType.RscRegen)
                {
                    if (!IsMultiplier())
                    {
                        RscManager.ModifyRegenModRate(gainList);
                    }
                    else
                    {
                        RscManager.ModifyRegenMulRate(gainList);
                    }
                }
                else if (type == _PerkType.RscGain)
                {
                    if (!IsMultiplier())
                    {
                        PerkManager.AddRscGainMod((int)gain);
                        PerkManager.AddRscGainModList(gainList);
                    }
                    else
                    {
                        PerkManager.AddRscGainMul(gain);
                        PerkManager.AddRscGainMulList(gainList);
                    }
                }
                else if (type == _PerkType.RscGainCreepDestroyed)
                {
                    if (!IsMultiplier())
                    {
                        PerkManager.AddRscGainModCreepKilled((int)gain);
                        PerkManager.AddRscGainModCreepKilledList(gainList);
                    }
                    else
                    {
                        PerkManager.AddRscGainMulCreepKilled(gain);
                        PerkManager.AddRscGainMulCreepKilledList(gainList);
                    }
                }
                else if (type == _PerkType.RscGainWaveCleared)
                {
                    if (!IsMultiplier())
                    {
                        PerkManager.AddRscGainModWaveCleared((int)gain);
                        PerkManager.AddRscGainModWaveClearedList(gainList);
                    }
                    else
                    {
                        PerkManager.AddRscGainMulWaveCleared(gain);
                        PerkManager.AddRscGainMulWaveClearedList(gainList);
                    }
                }
                else if (type == _PerkType.RscGainResourceTower)
                {
                    if (!IsMultiplier())
                    {
                        PerkManager.AddRscGainModRscTower((int)gain);
                        PerkManager.AddRscGainModRscTowerList(gainList);
                    }
                    else
                    {
                        PerkManager.AddRscGainMulRscTower(gain);
                        PerkManager.AddRscGainMulRscTowerList(gainList);
                    }
                }
                else if (type == _PerkType.AbilityRscCap)
                {
                    if (!IsMultiplier())
                    {
                        AbilityManager.MultiplyRscCap((int)Mathf.Round(gain));
                    }
                    else
                    {
                        AbilityManager.ModifyRscCap((int)Mathf.Round(gain));
                    }
                }
                else if (type == _PerkType.AbilityRscRegen)
                {
                    if (!IsMultiplier())
                    {
                        AbilityManager.ModifyRscRegen(gain);
                    }
                    else
                    {
                        AbilityManager.ModifyRscRegenMultiplier(gain);
                    }
                }
                else if (type == _PerkType.AbilityRscGainWaveCleared)
                {
                    if (!IsMultiplier())
                    {
                        PerkManager.abRscGainOnWaveClearedMod += (int)Mathf.Round(gain);
                    }
                    else
                    {
                        PerkManager.abRscGainOnWaveClearedMul *= gain;
                    }
                }
            }

            return(status);
        }