public void AdjustCurrentHealth(int value) { if (value < 0 && flashSprite != null) //If damage taken is >1. Flash Sprite. { flashSprite.Flash(Color.white); } if (shield) { curHealth = curHealth + (int)(value * shieldRatio); //for mole shielding } else { curHealth += value; } if (curHealth < 1) { curHealth = 0; //CharacterController cc = GetComponent(typeof(CharacterController)) as CharacterController; //cc.enabled = false; // Turn off the component Die(); } if (curHealth > maxHealth) { curHealth = maxHealth; } healthBarLength = (Screen.width / 3) * (curHealth / (float)(maxHealth)); }
public void AdjustCurrentHealth(int value) { if (value < 0 && flashSprite != null) //If damage taken is >1. Flash Sprite. { flashSprite.Flash(Color.white); } if (shield) { curHealth = curHealth + (int)(value * shieldRatio); //for mole shielding } else { curHealth += value; } if (curHealth < 1) { curHealth = 0; Die(); } if (curHealth > maxHealth) { curHealth = maxHealth; } healthBarLength = (Screen.width / 3) * (curHealth / (float)(maxHealth)); }
void Update() { if (active) { if (_explodeTimer > 0) { _explodeTimer -= Time.deltaTime; } else { Explode(); } if (_flashTimer > 0) { _flashTimer -= Time.deltaTime; } else { flashSprite.Flash(); _flashTimer = flashFrequencyCurve.Evaluate(_explodeTimer); } } }
void Flash(Color flashColor) { flashSprite.Flash(flashColor); }