void Die() { if (m_Dead) { return; } GlobalData.DispatchHeroDied(); m_Dead = true; m_CanMove = false; m_CanJump = false; m_Rigidbody2D.freezeRotation = false; var velocity = m_Rigidbody2D.velocity; velocity.y = m_DeathVelocity; m_Rigidbody2D.velocity = velocity; var angularVelocity = m_FacingLeft ? m_DeathAngularVelocity : -m_DeathAngularVelocity; m_Rigidbody2D.angularVelocity = angularVelocity; if (m_Boosting) { EndBoosting(); } m_DeathSequence.Cancel(); m_DeathSequence = ActionMaster.Actions.Sequence(); m_DeathSequence.SpriteAlpha(m_BodySpriteRenderer.gameObject, 0, m_DeathPreDelay, new Ease(Ease.Quad.Out)); m_DeathSequence.Call(Return, gameObject); m_DeathSequence.Delay(m_DeathPostDelay); m_DeathSequence.Call(RegainControl, gameObject); }
public void OnDied(HealthEventData eventData) { if (!enabled) { return; } enabled = false; if (m_IsTheHero) { GlobalData.DispatchHeroDied(); } m_Rigidbody.freezeRotation = false; var velocity = m_Rigidbody.velocity; velocity.y = m_DeathSpeed; var angularVelocity = Random.Range(-m_DeathAngularVelocity, m_DeathAngularVelocity); m_Rigidbody.velocity = velocity; m_Rigidbody.angularVelocity = angularVelocity; m_DeathSequence.Cancel(); m_DeathSequence = ActionMaster.Actions.Sequence(); m_DeathSequence.SpriteAlpha(m_BodySpriteRenderer.gameObject, 0, m_DeathDuration, new Ease(Ease.Quad.Out)); m_DeathSequence.Call(SequenceEnd, gameObject); }