protected override void OnHandleEvent(IEventMessage msg) { if (msg is BattleEvent.DamageHurt) { if (CharData.IsDead == false) { BattleEvent.DamageHurt message = msg as BattleEvent.DamageHurt; CharData.DamageHurt(message.Damage); CharAnim.Play("getHit"); // 随机播放角色受击音效 string soundName = Avatar.GetRandomGetHitSound(); if (string.IsNullOrEmpty(soundName) == false) { AudioManager.Instance.PlaySound(soundName); } } } else if (msg is BattleEvent.CharacterDead) { CharSkill.ForbidAll(); CharAnim.Play("die"); // 播放角色死亡音效 string soundName = Avatar.GetDeadSound(); if (string.IsNullOrEmpty(soundName) == false) { AudioManager.Instance.PlaySound(soundName); } } }
protected override void OnUpdateAvatar(float deltaTime) { if (CharSkill.IsAnyLife()) { return; } if (CharMove.IsMoving) { float animSpeed = CharData.MoveSpeed / Avatar.GetRunAnimationSpeed(); CharAnim.SetSpeed(CharData.CurrentRunAnimName, animSpeed); if (CharAnim.IsPlaying(CharData.CurrentRunAnimName) == false) { CharAnim.Play(CharData.CurrentRunAnimName, 0.15f); } } else { if (CharAnim.IsPlaying(CharData.CurrentIdleAnimName) == false) { CharAnim.Play(CharData.CurrentIdleAnimName, 0.15f); } } }