Hero.Update C# (CSharp) Method

Update() private method

private Update ( ) : void
return void
	void Update() {
    if(!_pause)
    {
      _lifeManager.regen(Time.deltaTime);
      _energy = _medium.getEnergy()/_maxMediumEnergy;

      if (GameStateController.isShortcutKey(_keyLife, true))
      {
		    _lifeManager.addVariation(1f);
      }
      if (GameStateController.isShortcutKey(_keyEnergy, true))
      {
        setEnergy(1f);
      }

      // dammage in case of low energy
      if (_energy <= 0.05f) {
                _lifeManager.addVariation(- Time.deltaTime * _lowEnergyDpt);
            }


		  // Life animation when life is reducing
		  if (_lifeManager.getVariation() < 0)
      {
        if(lifeAnimation.isPlaying == false){
				  lifeAnimation.Play();
			  }
		  }

		  // Energy animation when energy is reducing
		  if (_energy < _energyBefore) {
		    DisplayEnergyAnimation();
		  }
		  _energyBefore = _energy;


		  _lifeManager.applyVariation();
 		  if(_lifeManager.getLife() == 0f && (_isAlive))
		  {
			  _isAlive = false;
        
        RedMetricsManager.get ().sendEvent(TrackingEvent.DEATH, null, getLastCheckpointName());
			  StartCoroutine(RespawnCoroutine());
		  }
    }
	}

Usage Example

示例#1
0
        public void UseConsumableItem_2()
        {
            IEffect insta = new InstantEffect(EffectTarget.Character, StatType.Health, -40f);

            Assert.AreEqual(100f, hero.GetStat(StatType.Health).Value);
            hero.AddEffect(insta);

            IEffect        restoreHealth = new TimeEffect(EffectTarget.Character, StatType.Health, +10f, 3, 1);
            ConsumableItem potion        = new ConsumableItem(99, "Health of Potion", "Get 40hp", restoreHealth);

            Assert.AreEqual(60f, hero.GetStat(StatType.Health).Value);

            hero.UseItem(potion); //+10hp/stack x3

            Assert.AreEqual(70f, hero.GetStat(StatType.Health).Value);
            hero.Update();
            Assert.AreEqual(80f, hero.GetStat(StatType.Health).Value);
            hero.Update();
            Assert.AreEqual(90f, hero.GetStat(StatType.Health).Value);
            hero.Update();
            Assert.AreEqual(90f, hero.GetStat(StatType.Health).Value);

            ((TimeEffect)potion.Effect).Refill();
            hero.UseItem(potion);
            Assert.AreEqual(100f, hero.GetStat(StatType.Health).Value);
            hero.Update();
            Assert.AreEqual(100f, hero.GetStat(StatType.Health).Value);
            hero.Update();
            Assert.AreEqual(100f, hero.GetStat(StatType.Health).Value);
        }
All Usage Examples Of Hero::Update