/// <summary> /// Updates the health bar width. /// </summary> private void UpdateHealthBar(HealthChangeInfo healthChangeInfo) { Damageable damageable = healthChangeInfo.damageable; float healthBarWidth = originHealthBarWidth * damageable.currentHealth / damageable.startingHealth; healthBar.localScale = new Vector2(healthBarWidth, healthBar.localScale.y); }
/// <summary> /// The callback for when the attached object "dies". /// Add <see cref="lootDropped"/> to current currency /// </summary> protected virtual void OnDeath(HealthChangeInfo info) { m_DamageableBehaviour.configuration.died -= OnDeath; if (info.damageAlignment == null || !info.damageAlignment.CanHarm(m_DamageableBehaviour.configuration.alignmentProvider)) { return; } XEventBus.Instance.Post(EventId.AddCurrency, new XEventArgs(lootDropped)); }
/// <summary> /// Plays <see cref="attackPfx"/> if assigned /// </summary> protected virtual void OnDamaged(HealthChangeInfo obj) { if (attackPfx != null) { attackPfx.Play(); } if (attackSound != null) { attackSound.PlayRandomClip(); } }
/// <summary> /// Play a clip when certain health change requirements are met /// </summary> /// <param name="info">Uses <see cref="HealthChangeInfo"/> to determine what clip to play</param> public virtual void PlayHealthChangeSound(HealthChangeInfo info) { if (soundSelector != null && soundSelector.isSetUp) { AudioClip newClip = soundSelector.GetClipFromHealthChangeInfo(info); if (newClip != null) { m_Source.clip = newClip; } } m_Source.Play(); }
/// <summary> /// Plays <see cref="attackPfx"/> if assigned /// </summary> protected virtual void OnDamaged(HealthChangeInfo obj) { if (attackPfx != null) { attackPfx.Play(); } if (attackSound != null) { attackSound.PlayRandomClip(); //WWiseEventPlayer myEventPlayer = gameObject.AddComponent(typeof(WWiseEventPlayer)) as WWiseEventPlayer; //myEventPlayer.PlayWwiseEvent("ui_objectAttackSound"); } }
/// <summary> /// Subscribes to the player base health died event /// </summary> /// <param name="info"> /// The associated health change information /// </param> protected virtual void OnBaseDamaged(HealthChangeInfo info) { UpdateDisplay(); GameObject WwiseGlobal; WwiseGlobal = GameObject.Find("WwiseGlobal"); AkSoundEngine.PostEvent("ui_baseHit", WwiseGlobal); LevelManager levelManager = LevelManager.instance; Damageable baseConfig = levelManager.playerHomeBases[0].configuration; float currentHealth = baseConfig.currentHealth * 10.0f; Debug.Log("currentHealth = " + currentHealth); AkSoundEngine.SetRTPCValue("health", currentHealth, WwiseGlobal); }
/// <summary> /// The callback for when the attached object "dies". /// Add <see cref="lootDropped"/> to current currency /// </summary> protected virtual void OnDeath(HealthChangeInfo info) { m_DamageableBehaviour.configuration.died -= OnDeath; if (info.damageAlignment == null || !info.damageAlignment.CanHarm(m_DamageableBehaviour.configuration.alignmentProvider)) { return; } LevelManager levelManager = LevelManager.instance; if (levelManager == null) { return; } levelManager.currency.AddCurrency(lootDropped); }
/// <summary> /// Gets the clip from health change info. /// </summary> /// <returns>The clip from health change info.</returns> /// <param name="info">The HealthChangeInfo</param> public virtual AudioClip GetClipFromHealthChangeInfo(HealthChangeInfo info) { int count = healthChangeSounds.Count; for (int i = 0; i < count; i++) { HealthChangeSound sound = healthChangeSounds[i]; // if the absolute health change is less than the sound health change // then this is the sound clip to use if (info.absHealthDifference <= sound.healthChange) { return(sound.sound); } } Debug.LogFormat("Could not find sound for healthChange of {0}", info.absHealthDifference); return(null); }
/// <summary> /// Subscribes to the player base health died event /// </summary> /// <param name="info"> /// The associated health change information /// </param> protected virtual void OnBaseDamaged(HealthChangeInfo info) { UpdateDisplay(); }
/// <summary> /// Initializes a new instance of the <see cref="HitInfo" /> struct. /// </summary> /// <param name="info">The health change info</param> /// <param name="damageLocation">Damage point.</param> public HitInfo(HealthChangeInfo info, Vector3 damageLocation) { m_DamagePoint = damageLocation; m_HealthChangeInfo = info; }
protected virtual void OnDamaged(HealthChangeInfo obj) { }
public void OnHealthChanged(HealthChangeInfo healthChangeInfo) { UpdateHealthBar(healthChangeInfo); StartCoroutine(DisplayDamage()); }