void Damage(float amount, int attackerId) { if (!Champion.invincible && !IsDead) { Champion.health = Mathf.Max(Champion.health - amount, 0f); // If the champion is the local player, update their UI to reflect the damage if (PhotonView.isMine) { // Get the attacker and store their damage in the champion PhotonView attacker = PhotonView.Find(attackerId); Champion.damage.Insert(0, new Damage(attacker, amount, gameUIHandler.TimeElapsed)); // Call the delegate for when the player is damaged if (onPlayerDamaged != null) { onPlayerDamaged(); } // Update the local health bar UI gameUIHandler.UpdateStats(Champion); // Does the player have any health left? if (Champion.health <= 0f) { GetComponent <PlayerMovement>().StopMovement(); GetComponent <PlayerAnimator>().PlayAnimation("Death"); PhotonView.RPC("OnDeath", PhotonTargets.All, Champion.GetKiller()); Champion.ResetDamage(); DeathHandler.Instance.OnDeath(this); } // Tell other players to update the UI which shows over the character's head PhotonView.RPC("UpdatePlayerHealth", PhotonTargets.All, Champion.health, Champion.maxHealth); } } }