private void OnDisable()
 {
     if (PlayerSettings.GetInstance() != null)
     {
         PlayerSettings.GetInstance().OnFundsChangeEvent -= OnFundsChange;
     }
 }
Exemplo n.º 2
0
 protected override void OnZeroHP()
 {
     // When AI zero get's to be 0 or under, reward the player and re-pool this object.
     PlayerSettings.GetInstance().Funds += data.FundGiveAmount;
     PlayerSettings.GetInstance().Score += data.ScoreGiveAmount;
     EnemyPool.GetInstance().Enqueue(this);
 }
 private void Initialize(ShopObject shopObject)
 {
     CheckForSpawnable(shopObject, out IShopSpawnable spawnableObject);
     // Deduct funds from player.
     PlayerSettings.GetInstance().Funds -= shopObject.Cost;
     if (spawnableObject != null)
     {
         AmountOfFollowers++;
         // Instantiate the object and set it's position.
         spawnableObject.SpawnItem(spawnRange: shopObjectSpawnRange);
     }
 }
 private void OnSceneLoad(Scene scene, LoadSceneMode mode)
 {
     if (scene.name == levelSceneString && LoadPlayerSettings)
     {
         // If user pressed load button, update the sensitivity and load the player.
         UpdateSensitivity();
         PlayerSettings.GetInstance().LoadPlayer();
     }
     else if (scene.name == levelSceneString)
     {
         // Otherwise only update sensitivity.
         UpdateSensitivity();
     }
 }
 public void SpawnObject(ShopObject shopObject)
 {
     if (shopObject.Cost > PlayerSettings.GetInstance().Funds)
     {
         NoFundsEventHandler.TriggerFundsOutPopUp(notEnoughFunds);
     }
     else if (maxAmountOfFollowers > AmountOfFollowers && shopObject.Prefab.TryGetComponent(out IShopSpawnable _))
     {
         NoFundsEventHandler.TriggerFundsOutPopUp(maxFollowersAchieved);
     }
     else
     {
         Initialize(shopObject);
     }
 }
 public void HealthButton()
 {
     // Make sure the playersettings exists and there are enough funds.
     if (PlayerSettings.GetInstance() != null && PlayerSettings.GetInstance().Funds >= fundCost)
     {
         // Apply healthpotion to the objective and player.
         PlayerSettings.GetInstance().Funds    -= fundCost;
         PlayerSettings.GetInstance().HitPoints = amountToHeal;
         Objective.GetInstance().HitPoints      = originalObjectiveHitPoints;
     }
     else
     {
         #if UNITY_EDITOR
         Debug.Log($"You don't have the required amount of funds.");
         #endif
         if (!isFundsCoroutineRunning)
         {
             isFundsCoroutineRunning = true;
             StartCoroutine(FundsOutText());
         }
     }
 }
Exemplo n.º 7
0
 protected override void Awake()
 {
     base.Awake();
     scoreText = GetComponent <TextMeshProUGUI>();
     PlayerSettings.GetInstance().OnScoreChangeEvent += OnScoreChange;
 }
 private void UpdateSensitivity()
 {
     PlayerSettings.GetInstance().PlayerSensitivityMultiplier = sensitivitySliderValue;
 }