Exemplo n.º 1
0
 void onItemCollected(ItemCollectedEvent itemCollected)
 {
     if (itemCollected.PlayerUpgrade.GetHealth() > 0)
     {
         float healthIncrease = playerHealth.GetTotalHealth() * itemCollected.PlayerUpgrade.GetHealth();
         updateHealthbar(playerHealth.GetCurrentHealth() + healthIncrease);
     }
 }
Exemplo n.º 2
0
 // To upgrade when there are enough coins
 public void Upgrade()
 {
     if (!IsUpgradeable(GameObject.FindGameObjectWithTag("Human").GetComponent <Player>().GetNumCoins()))
     {
         return;
     }
     GameObject.FindGameObjectWithTag("Human").GetComponent <Player>().SpendCoins((int)upgradeCost);
     health.Upgrade(upgradeFactor);
     weapon.Upgrade();
     weapon.setProjectile(currentLevel);
     currentLevel++;
     NotifyHUD();
     ApplyMainTexture();
     ApplySmokeEffect();
     if (!upgrade.isPlaying)
     {
         upgrade.PlayOneShot(upgrade.clip);
     }
     Debug.Log("BUILDING UPGRADED, TOTAL HP: " + health.GetTotalHealth());
 }
Exemplo n.º 3
0
    public void NotifyHUD()
    {
        var updateInfo = new HUDInfo
        {
            CurrentHealth = health.GetCurrentHealth(),
            TotalHealth   = health.GetTotalHealth(),
            Damage        = weapon.getCurrentDamage().ToString(),
            Range         = weapon.getCurrentRange().ToString()
        };

        APIHUD.instance.notifyChange(this, updateInfo);
    }
    void updateHealthbar(float currentHealth)
    {
        float healthPercentage = currentHealth / coreHealth.GetTotalHealth();

        StartCoroutine(ImageSlider.ChangeSliderValueUsingEaseOut(imageSlider, healthPercentage, LerpTime));
    }