public void AddHealth(float amount) { m_CurrentHealth += amount; if (m_CurrentHealth > maxHealth) { m_CurrentHealth = maxHealth; } HealthChanged?.Invoke(m_CurrentHealth / maxHealth); if (m_CurrentHealth <= 1 && !dead) { dead = true; // if (destroyOnDeath) // { Died?.Invoke(); // } if (dyingAnimations.Length > 0) { // If there is death animations for this object m_Animator.SetBool(dyingAnimations.AnyItem(), true); // TODO: not rly useful if destroyed ... (maybe should add death delay idk) } } }
// Deselect NPC from Target public virtual void Deselect() { // Remove HealthChanged EventListener healthChanged -= new HealthChanged(UIDirector.MyInstance.UpdateTargetFrame); // Remove CharacterRemoved EventListener characterRemoved -= new CharacterRemoved(UIDirector.MyInstance.HideTargetFrame); }
void Regen() { float remainingHealth = originalHealth - currentHealth; //adds health currentHealth += regenAmount; //if health is maxxed out set to max and cancel regeneration if (currentHealth >= originalHealth) { currentHealth = originalHealth; CancelInvoke("Regen"); } //Send message for script to update UI if (HealthChanged != null && showHealth) { float amount; if (remainingHealth < regenAmount) { amount = remainingHealth; } else { amount = regenAmount; } if (HealthChanged != null) { HealthChanged.Invoke(amount); } } }
public void ChangeHealth(float amount) { m_CurrentHealth += amount; if (m_CurrentHealth > maxHealth) { m_CurrentHealth = maxHealth; } HealthChanged?.Invoke(m_CurrentHealth / maxHealth); if (m_CurrentHealth <= 0 && !dead) { dead = true; if (destroyOnDeath) { Died?.Invoke(); if (deathEffects.Length > 0) // Unused, prob not ready for working { var p = transform.position; Pool.Despawn( Pool.Spawn(deathEffects.AnyItem(), new Vector3(p.x, p.y, p.z), new Quaternion(0, 0, 0, 0)), 3); } } if (dyingAnimations.Length > 0) { // If there is death animations for this object m_Animator.SetBool(dyingAnimations.AnyItem(), true); // TODO: not rly useful if destroyed ... (maybe should add death delay idk) } } }
private void OnHealthChanged(float newHealth) { if (HealthChanged != null) { HealthChanged.Invoke(newHealth); } }
public void DeSelect() { healthGroup.alpha = 0; healthChanged -= new HealthChanged(UIManager.MyInstance.UpdateTargetFrame); characterRemoved -= new CharacterRemoved(UIManager.MyInstance.hideTargetFrame); }
public void LoadPlayer() { PlayerData data = SaveSystem.LoadPlayer(); currentHealth = data.health; HealthChanged.Invoke(currentHealth); }
private void Start() { _currenthealth = _maxHealth; StartCoroutine(ShootWithDelay(_shootPoint, _secondsBetweenShoot)); HealthChanged?.Invoke(_currenthealth); }
public void TakeDamage() { if (_curentHealth - _variableValue >= 0) { _curentHealth -= _variableValue; HealthChanged?.Invoke(); } }
public void Healing() { if (_curentHealth + _variableValue <= _maxHealth) { _curentHealth += _variableValue; HealthChanged?.Invoke(); } }
public void Heal(int heal) { if (hp < maxHp) { hp += heal; HealthChanged?.Invoke(this, hp); } }
public void ReduceHealth(int damage) { _health = Math.Max(0, _health - damage); HealthChanged?.Invoke(_health); if (_health == 0) { HealthIsZero?.Invoke(); } }
public void Heal(int healthAmount) { health += healthAmount; if (health >= maxHealth) { health = maxHealth; } HealthChanged?.Invoke(); }
private void UpdateHealth() { HealthChanged?.Invoke(_currentHealth); if (_currentHealth <= 0) { GameOver(); } }
public void ApplyDamage(int damage) { _currentHealth -= damage; HealthChanged?.Invoke(_currentHealth, _health); if (_currentHealth <= 0) { Destroy(gameObject); } }
public void ApplyDamage(int damage) { _health -= damage; HealthChanged?.Invoke(_health); if (_health <= 0) { Die(); } }
// Use this for initialization void Start() { currentHealth = originalHealth; //Send message for script to update UI if (HealthChanged != null && showHealth) { HealthChanged.Invoke(0); } }
private void OnHealthChanged(HealthChanged evt) { int index = evt.PlayerIndex; int newHealth = evt.NewHealth; HealthBar healthBar = healthBars[index].GetComponent <HealthBar>(); healthBar.UpdateHealth(newHealth); //get the other player index int opponentIndex = 0; for (int i = 0; i < playerHealthCached.Length; i++) { if (i != index) { opponentIndex = i; } } //Cache health in case we time out playerHealthCached[index] = newHealth; //when a player lose if (newHealth <= 0) { GameObject result = null; //if opponent already has 2 point(gonna win) if (playerWins[opponentIndex] >= TotalRounds - 1) { result = Instantiate(Resources.Load("Prefabs/PalmmyEffect/MatchEnd"), uiCanvas.transform) as GameObject; } else //if they are still not gonna win { if (playerHealthCached[opponentIndex] >= 6) { result = Instantiate(Resources.Load("Prefabs/PalmmyEffect/Perfect"), uiCanvas.transform) as GameObject; LightManager.Instance.ChangeLightColor(Color.green, 0.2f); AudioManager.Instance.PlayAudio(AudioManager.Instance.PerfectAudioClips); } else if (playerHealthCached[opponentIndex] < 6) { result = Instantiate(Resources.Load("Prefabs/PalmmyEffect/KO"), uiCanvas.transform) as GameObject; LightManager.Instance.ChangeLightColor(Color.white, 0.2f); AudioManager.Instance.PlayAudio(AudioManager.Instance.KOAudioClips); } } StartCoroutine(WhooshAudio()); result.GetComponent <EndRound>().winningPlayer = opponentIndex; playerHealthCached[index] = 6; playerHealthCached[opponentIndex] = 6; EventManager.Instance.Fire(new RoundEnd(opponentIndex, index, false, false)); CurrentManagerState = ManagerState.End; } }
public void ApplyDamage(int value) { if (_currentHealth + value >= 0 && _currentHealth + value <= _health) { _currentHealth += value; HealthChanged?.Invoke(_currentHealth, _health); SetAnimation(value); } }
private void Start() { _audioSource = GetComponent <AudioSource>(); RescaleStats(); _currentHealth = _maxHealth; HealthChanged?.Invoke(_currentHealth, _maxHealth); }
public void TakeDamage(int damage) { _currentHealth -= damage; HealthChanged?.Invoke(_currentHealth); if (_currentHealth <= 0) { Die(); } }
private void EnemyFinished(GameObject enemy) { var enemyComp = enemy.GetComponent <Enemy>(); Health -= enemyComp.Damage; HealthChanged?.Invoke(Health); enemyComp.OnDied -= EnemyDied; CheckIfLastEnemyDiedOrFinished(); }
private void OnHealth() { health--; if (health == 0) { // ads.StartCoroutine("ShowAd"); menuController.LoseGame(); } HealthChanged?.Invoke(health); }
public void GeDamage(float hp) { if (_currentHealth - hp < 0) { return; } _currentHealth -= hp; HealthChanged.Invoke(_currentHealth); }
public void TakeDamage(int damage) { _currentHealth -= damage; HealthChanged?.Invoke(_currentHealth, _health); if (_currentHealth <= 0) { Debug.Log("Defete"); } }
public void Reset() { currentHealth = originalHealth; isDead = false; //Send message for script to update UI if (HealthChanged != null && showHealth) { HealthChanged.Invoke(0); } }
public void TakeDamage(float damage) { if (_currentHealth > 0) { _currentHealth -= damage; PlayAnimation(); PlayEffect(); HealthChanged?.Invoke(_currentHealth, _maxHealth); } }
public void TakeDamage(int damage) { _health -= damage; if (_health <= 0) { Die(); } HealthChanged?.Invoke(_health); }
private void ApplyDamage() { _health--; HealthChanged?.Invoke(_health); if (_health <= 0) { Died?.Invoke(); gameObject.SetActive(false); } }
public void TakeDamage(int damage) { currentHealth -= damage; HealthChanged.Invoke(currentHealth); PlayerDamaged.Play(); if (currentHealth <= 0) { SceneManager.LoadScene(SceneManager.GetActiveScene().buildIndex); } }