private void AnimationFinishedCallback(AnimationInstance animation) { PlayerAnimations.Id id = (PlayerAnimations.Id)animation.id; switch (id) { case PlayerAnimations.Id.Die: { Debug.Assert(!IsAlive); RemoveFromField(); break; } case PlayerAnimations.Id.PunchBomb: { IsPunchingBomb = false; break; } case PlayerAnimations.Id.PickupBomb: { IsPickingUpBomb = false; break; } } }
private void UpdateAnimation() { PlayerAnimations.Id id; PlayerAnimations.Id currentId = (PlayerAnimations.Id)m_currentAnimation.id; AnimationInstance.Mode mode = AnimationInstance.Mode.Looped; if (IsAlive) { if (IsPunchingBomb) { if (currentId == PlayerAnimations.Id.PunchBomb) { return; // don't play animation again } id = PlayerAnimations.Id.PunchBomb; mode = AnimationInstance.Mode.Normal; } else if (IsPickingUpBomb) { id = PlayerAnimations.Id.PickupBomb; mode = AnimationInstance.Mode.Normal; } else if (IsHoldingBomb()) { id = IsMoving() ? PlayerAnimations.Id.WalkBomb : PlayerAnimations.Id.StandBomb; mode = AnimationInstance.Mode.Normal; } else if (IsMoving()) { id = PlayerAnimations.Id.Walk; Animation newAnimation = m_animations.Find(id, direction); if (m_currentAnimation.Animation == newAnimation) { return; } } else { id = PlayerAnimations.Id.Stand; } } else { id = PlayerAnimations.Id.Die; mode = AnimationInstance.Mode.Normal; } Animation animation = m_animations.Find(id, direction); m_currentAnimation.Init(animation, mode); m_currentAnimation.id = (int)id; m_currentAnimation.animationDelegate = AnimationFinishedCallback; }