internal void InvokePlayerDeathEvent(Player victim, Player killer, PlayerStats.HitInfo info) { var ev = new PlayerDeathEventArgs { HitInfo = info, Killer = killer, Victim = victim }; PlayerDeathEvent?.Invoke(ev); }
private void PlayerDeath() { //Debug.Log("Did you ever hear the tragedy of Darth Plagueis the Wise?"); if (PlayerDeathEvent != null) { PlayerDeathEvent.Invoke(); } }
public void Damaged(float damage) { if (Health > 0) { state.Damaged(damage); if (Health < 0) { PlayerDeathEvent?.Invoke(); } } }
internal void InvokePlayerDeathEvent(Player victim, Player killer, DamageType type, out bool allow) { var ev = new PlayerDeathEventArgs { Killer = killer, Victim = victim, DamageType = type, }; PlayerDeathEvent?.Invoke(ev); allow = ev.Allow; }
/// <summary> /// This method changes the players health value /// </summary> /// <param name="value"> value to change health by</param> void ChangeHealth(float value) { //testing code if (healthScalingValue - value >= playerHealth) { //Debug.Log("player health restored"); value = 0; healthScalingValue = playerHealth; } else if (healthScalingValue - value <= 0) { //Debug.Log("PlayerHealth Reduced"); value = healthScalingValue; // finished changing values so player can see their empty health after death. healthScalingValue -= value; //Debug.Log("Changing: health" + healthScalingValue); healthScalingVector.x = healthScalingValue / playerHealth; healthPanelRect.transform.localScale = healthScalingVector; healthpositionVector.x = healthScalingValue / 2 - (playerHealth + 100); healthPanelRect.transform.localPosition = healthpositionVector; // displays death screen playerDeathEvent.Invoke(Enumeration.playerState.playerState); // stops time since the player is dead Time.timeScale = 0; } //Debug.Log("healthscaling value: " + healthScalingValue); healthScalingValue -= value; //Debug.Log("healthscalingavalue: " + healthScalingValue); //Debug.Log("value: " + value); //Debug.Log("Changing: health" + healthScalingValue); healthScalingVector.x = healthScalingValue / playerHealth; healthPanelRect.transform.localScale = healthScalingVector; healthpositionVector.x = healthScalingValue / 2 - (playerHealth + 100); healthPanelRect.transform.localPosition = healthpositionVector; }
internal static void InvokePlayerDieEvent(Player player, Player killer, PlayerStats.HitInfo infos) { if (PlayerDeathEvent == null) { return; } var ev = new PlayerDeathEvent { Info = infos, Killer = killer, Player = player }; PlayerDeathEvent.Invoke(ev); }
/// <summary> /// used for player invunriblility /// </summary> private void Update() { //timer for invurnrability if (invunlnerabll) { timer += Time.deltaTime; if (timer > InvunlerabilityTIme) { invunlnerabll = false; } } //if this script is on a wall that is destroyed if (health <= 0 && gameObject.tag == "Wall") { Destroy(gameObject); } if (health <= 0 && gameObject.tag == "Player") { //AudioManager.Instance.Play(AudioClipName.player_Death); playerDeathEvent.Invoke(); //SceneManager.LoadScene(SceneManager.GetActiveScene().buildIndex); } }
private void OnDisable() { PlayerDeathEvent?.Invoke(); }