/// <summary>
        /// Override this to send parameters to the character's animator. This is called once per cycle, by the Character
        /// class, after Early, normal and Late process().
        /// </summary>
        public override void UpdateAnimator()
        {
            if (CurrentWeapon == null)
            {
                return;
            }

            MMAnimator.UpdateAnimatorBool(_animator, CurrentWeapon.IdleAnimationParameter, (CurrentWeapon.WeaponState.CurrentState == Weapon.WeaponStates.WeaponIdle), _character._animatorParameters);
            MMAnimator.UpdateAnimatorBool(_animator, CurrentWeapon.StartAnimationParameter, (CurrentWeapon.WeaponState.CurrentState == Weapon.WeaponStates.WeaponStart), _character._animatorParameters);
            MMAnimator.UpdateAnimatorBool(_animator, CurrentWeapon.DelayBeforeUseAnimationParameter, (CurrentWeapon.WeaponState.CurrentState == Weapon.WeaponStates.WeaponDelayBeforeUse), _character._animatorParameters);
            MMAnimator.UpdateAnimatorBool(_animator, CurrentWeapon.UseAnimationParameter, (CurrentWeapon.WeaponState.CurrentState == Weapon.WeaponStates.WeaponDelayBeforeUse || CurrentWeapon.WeaponState.CurrentState == Weapon.WeaponStates.WeaponUse || CurrentWeapon.WeaponState.CurrentState == Weapon.WeaponStates.WeaponDelayBetweenUses), _character._animatorParameters);
            MMAnimator.UpdateAnimatorBool(_animator, CurrentWeapon.SingleUseAnimationParameter, (CurrentWeapon.WeaponState.CurrentState == Weapon.WeaponStates.WeaponUse), _character._animatorParameters);
            MMAnimator.UpdateAnimatorBool(_animator, CurrentWeapon.DelayBetweenUsesAnimationParameter, (CurrentWeapon.WeaponState.CurrentState == Weapon.WeaponStates.WeaponDelayBetweenUses), _character._animatorParameters);
            MMAnimator.UpdateAnimatorBool(_animator, CurrentWeapon.StopAnimationParameter, (CurrentWeapon.WeaponState.CurrentState == Weapon.WeaponStates.WeaponStop), _character._animatorParameters);
            MMAnimator.UpdateAnimatorBool(_animator, CurrentWeapon.ReloadStartAnimationParameter, (CurrentWeapon.WeaponState.CurrentState == Weapon.WeaponStates.WeaponReloadStart), _character._animatorParameters);
            MMAnimator.UpdateAnimatorBool(_animator, CurrentWeapon.ReloadAnimationParameter, (CurrentWeapon.WeaponState.CurrentState == Weapon.WeaponStates.WeaponReload), _character._animatorParameters);
            MMAnimator.UpdateAnimatorBool(_animator, CurrentWeapon.ReloadStopAnimationParameter, (CurrentWeapon.WeaponState.CurrentState == Weapon.WeaponStates.WeaponReloadStop), _character._animatorParameters);
            MMAnimator.UpdateAnimatorBool(_animator, CurrentWeapon.EquippedAnimationParameter, true, _character._animatorParameters);

            if (_aimableWeapon != null)
            {
                MMAnimator.UpdateAnimatorFloat(_animator, CurrentWeapon.WeaponAngleAnimationParameter, _aimableWeapon.CurrentAngle, _character._animatorParameters);
                MMAnimator.UpdateAnimatorFloat(_animator, CurrentWeapon.WeaponAngleRelativeAnimationParameter, _aimableWeapon.CurrentAngleRelative, _character._animatorParameters);
            }
            else
            {
                MMAnimator.UpdateAnimatorFloat(_animator, CurrentWeapon.WeaponAngleAnimationParameter, 0f, _character._animatorParameters);
                MMAnimator.UpdateAnimatorFloat(_animator, CurrentWeapon.WeaponAngleRelativeAnimationParameter, 0f, _character._animatorParameters);
            }
        }
Exemplo n.º 2
0
 protected virtual void UpdateAnimators()
 {
     if (_animator != null)
     {
         MMAnimator.UpdateAnimatorFloat(_animator, "Speed", _currentSpeed, _animatorParameters);
     }
 }
Exemplo n.º 3
0
 /// <summary>
 /// Updates the animator's parameters
 /// </summary>
 protected virtual void UpdateAnimator()
 {
     if (_animator != null)
     {
         MMAnimator.UpdateAnimatorFloat(_animator, "Speed", _rigidBody2D.velocity.magnitude);
         MMAnimator.UpdateAnimatorInteger(_animator, "Armor", _currentArmor);
     }
 }
 public override void UpdateAnimator()
 {
     if (GetComponent <InputManager>() != null)
     {
         MMAnimator.UpdateAnimatorFloat(_animator, "Speed", Mathf.Abs(_normalizedHorizontalSpeed), _character._animatorParameters);
         MMAnimator.UpdateAnimatorBool(_animator, "Walking", (_movement.CurrentState == CharacterStates.MovementStates.Walking),
                                       _character._animatorParameters);
     }
 }
Exemplo n.º 5
0
        /// <summary>
        /// Override this to send parameters to the character's animator. This is called once per cycle, by the Character
        /// class, after Early, normal and Late process().
        /// </summary>
        public virtual void UpdateAnimator()
        {
            for (int i = 0; i < Animators.Count; i++)
            {
                MMAnimator.UpdateAnimatorBool(Animators[i], IdleAnimationParameter, (WeaponState.CurrentState == Weapon.WeaponStates.WeaponIdle), _animatorParameters[i]);
                MMAnimator.UpdateAnimatorBool(Animators[i], StartAnimationParameter, (WeaponState.CurrentState == Weapon.WeaponStates.WeaponStart), _animatorParameters[i]);
                MMAnimator.UpdateAnimatorBool(Animators[i], DelayBeforeUseAnimationParameter, (WeaponState.CurrentState == Weapon.WeaponStates.WeaponDelayBeforeUse), _animatorParameters[i]);
                MMAnimator.UpdateAnimatorBool(Animators[i], UseAnimationParameter, (WeaponState.CurrentState == Weapon.WeaponStates.WeaponDelayBeforeUse || WeaponState.CurrentState == Weapon.WeaponStates.WeaponUse || WeaponState.CurrentState == Weapon.WeaponStates.WeaponDelayBetweenUses), _animatorParameters[i]);
                MMAnimator.UpdateAnimatorBool(Animators[i], SingleUseAnimationParameter, (WeaponState.CurrentState == Weapon.WeaponStates.WeaponUse), _animatorParameters[i]);
                MMAnimator.UpdateAnimatorBool(Animators[i], DelayBetweenUsesAnimationParameter, (WeaponState.CurrentState == Weapon.WeaponStates.WeaponDelayBetweenUses), _animatorParameters[i]);
                MMAnimator.UpdateAnimatorBool(Animators[i], StopAnimationParameter, (WeaponState.CurrentState == Weapon.WeaponStates.WeaponStop), _animatorParameters[i]);
                MMAnimator.UpdateAnimatorBool(Animators[i], ReloadStartAnimationParameter, (WeaponState.CurrentState == Weapon.WeaponStates.WeaponReloadStart), _animatorParameters[i]);
                MMAnimator.UpdateAnimatorBool(Animators[i], ReloadAnimationParameter, (WeaponState.CurrentState == Weapon.WeaponStates.WeaponReload), _animatorParameters[i]);
                MMAnimator.UpdateAnimatorBool(Animators[i], ReloadStopAnimationParameter, (WeaponState.CurrentState == Weapon.WeaponStates.WeaponReloadStop), _animatorParameters[i]);

                if (_aimableWeapon != null)
                {
                    MMAnimator.UpdateAnimatorFloat(Animators[i], WeaponAngleAnimationParameter, _aimableWeapon.CurrentAngle, _animatorParameters[i]);
                    MMAnimator.UpdateAnimatorFloat(Animators[i], WeaponAngleRelativeAnimationParameter, _aimableWeapon.CurrentAngleRelative, _animatorParameters[i]);
                }
                else
                {
                    MMAnimator.UpdateAnimatorFloat(Animators[i], WeaponAngleAnimationParameter, 0f, _animatorParameters[i]);
                    MMAnimator.UpdateAnimatorFloat(Animators[i], WeaponAngleRelativeAnimationParameter, 0f, _animatorParameters[i]);
                }
            }

            if (_ownerAnimator != null)
            {
                MMAnimator.UpdateAnimatorBool(_ownerAnimator, IdleAnimationParameter, (WeaponState.CurrentState == Weapon.WeaponStates.WeaponIdle), _ownerAnimatorParameters);
                MMAnimator.UpdateAnimatorBool(_ownerAnimator, StartAnimationParameter, (WeaponState.CurrentState == Weapon.WeaponStates.WeaponStart), _ownerAnimatorParameters);
                MMAnimator.UpdateAnimatorBool(_ownerAnimator, DelayBeforeUseAnimationParameter, (WeaponState.CurrentState == Weapon.WeaponStates.WeaponDelayBeforeUse), _ownerAnimatorParameters);
                MMAnimator.UpdateAnimatorBool(_ownerAnimator, UseAnimationParameter, (WeaponState.CurrentState == Weapon.WeaponStates.WeaponDelayBeforeUse || WeaponState.CurrentState == Weapon.WeaponStates.WeaponUse || WeaponState.CurrentState == Weapon.WeaponStates.WeaponDelayBetweenUses), _ownerAnimatorParameters);
                MMAnimator.UpdateAnimatorBool(_ownerAnimator, SingleUseAnimationParameter, (WeaponState.CurrentState == Weapon.WeaponStates.WeaponUse), _ownerAnimatorParameters);
                MMAnimator.UpdateAnimatorBool(_ownerAnimator, DelayBetweenUsesAnimationParameter, (WeaponState.CurrentState == Weapon.WeaponStates.WeaponDelayBetweenUses), _ownerAnimatorParameters);
                MMAnimator.UpdateAnimatorBool(_ownerAnimator, StopAnimationParameter, (WeaponState.CurrentState == Weapon.WeaponStates.WeaponStop), _ownerAnimatorParameters);
                MMAnimator.UpdateAnimatorBool(_ownerAnimator, ReloadStartAnimationParameter, (WeaponState.CurrentState == Weapon.WeaponStates.WeaponReloadStart), _ownerAnimatorParameters);
                MMAnimator.UpdateAnimatorBool(_ownerAnimator, ReloadAnimationParameter, (WeaponState.CurrentState == Weapon.WeaponStates.WeaponReload), _ownerAnimatorParameters);
                MMAnimator.UpdateAnimatorBool(_ownerAnimator, ReloadStopAnimationParameter, (WeaponState.CurrentState == Weapon.WeaponStates.WeaponReloadStop), _ownerAnimatorParameters);

                if (_aimableWeapon != null)
                {
                    MMAnimator.UpdateAnimatorFloat(_ownerAnimator, WeaponAngleAnimationParameter, _aimableWeapon.CurrentAngle, _ownerAnimatorParameters);
                    MMAnimator.UpdateAnimatorFloat(_ownerAnimator, WeaponAngleRelativeAnimationParameter, _aimableWeapon.CurrentAngleRelative, _ownerAnimatorParameters);
                }
                else
                {
                    MMAnimator.UpdateAnimatorFloat(_ownerAnimator, WeaponAngleAnimationParameter, 0f, _ownerAnimatorParameters);
                    MMAnimator.UpdateAnimatorFloat(_ownerAnimator, WeaponAngleRelativeAnimationParameter, 0f, _ownerAnimatorParameters);
                }
            }
        }
Exemplo n.º 6
0
 /// <summary>
 /// This is called at Update() and sets each of the animators parameters to their corresponding State values
 /// </summary>
 protected virtual void UpdateAnimators()
 {
     if (_animator != null)
     {
         MMAnimator.UpdateAnimatorBool(_animator, "Grounded", true, _animatorParameters);
         MMAnimator.UpdateAnimatorFloat(_animator, "ForwardSpeed", _currentSpeed, _animatorParameters);
         MMAnimator.UpdateAnimatorFloat(_animator, "RotationSpeed", _currentRotationSpeed, _animatorParameters);
         MMAnimator.UpdateAnimatorBool(_animator, "Goal", Goal, _animatorParameters);
         MMAnimator.UpdateAnimatorBool(_animator, "GoalInProgress", GoalInProgress, _animatorParameters);
         MMAnimator.UpdateAnimatorBool(_animator, "RobotDance", RobotDance, _animatorParameters);
         MMAnimator.UpdateAnimatorBool(_animator, "Dead", Dead, _animatorParameters);
     }
 }
        /// <summary>
        /// Animates the character if it has an animator set
        /// Also flips the character if needed
        /// </summary>
        public virtual void AnimateCharacter()
        {
            if (_destination == null)
            {
                return;
            }

            if (_destination.transform.position.x - _offset.x < transform.position.x)
            {
                if (CharacterIsFacingRight)
                {
                    Flip();
                }
            }
            if (_destination.transform.position.x - _offset.x > transform.position.x)
            {
                if (!CharacterIsFacingRight)
                {
                    Flip();
                }
            }

            // if we have an animator we'll want to let it know if our character is moving or not
            if (_animator != null)
            {
                // if we've moved since last frame, we haven't reached our destination yet, so we set our current speed at 1
                if (_positionLastFrame != transform.position)
                {
                    _currentSpeed = 1f;
                }
                else
                {
                    // if we haven't moved last frame, we're static
                    _currentSpeed = 0f;
                }
                // we pass that parameter to our animator
                MMAnimator.UpdateAnimatorFloat(_animator, "Speed", _currentSpeed);
            }

            _positionLastFrame = transform.position;
        }
Exemplo n.º 8
0
        /// <summary>
        /// This is called at Update() and sets each of the animators parameters to their corresponding State values
        /// </summary>
        protected virtual void UpdateAnimators()
        {
            if ((UseDefaultMecanim) && (_animator != null))
            {
                MMAnimator.UpdateAnimatorBool(_animator, "Grounded", _controller.State.IsGrounded, _animatorParameters);
                MMAnimator.UpdateAnimatorBool(_animator, "Alive", (ConditionState.CurrentState != CharacterStates.CharacterConditions.Dead), _animatorParameters);
                MMAnimator.UpdateAnimatorFloat(_animator, "xSpeed", _controller.Speed.x, _animatorParameters);
                MMAnimator.UpdateAnimatorFloat(_animator, "ySpeed", _controller.Speed.y, _animatorParameters);
                MMAnimator.UpdateAnimatorBool(_animator, "CollidingLeft", _controller.State.IsCollidingLeft, _animatorParameters);
                MMAnimator.UpdateAnimatorBool(_animator, "CollidingRight", _controller.State.IsCollidingRight, _animatorParameters);
                MMAnimator.UpdateAnimatorBool(_animator, "CollidingBelow", _controller.State.IsCollidingBelow, _animatorParameters);
                MMAnimator.UpdateAnimatorBool(_animator, "CollidingAbove", _controller.State.IsCollidingAbove, _animatorParameters);
                MMAnimator.UpdateAnimatorBool(_animator, "Idle", (MovementState.CurrentState == CharacterStates.MovementStates.Idle), _animatorParameters);
                MMAnimator.UpdateAnimatorBool(_animator, "FacingRight", IsFacingRight, _animatorParameters);

                foreach (CharacterAbility ability in _characterAbilities)
                {
                    if (ability.enabled && ability.AbilityInitialized)
                    {
                        ability.UpdateAnimator();
                    }
                }
            }
        }
Exemplo n.º 9
0
 /// <summary>
 /// At the end of each cycle, we send our character's animator the current following status
 /// </summary>
 public override void UpdateAnimator()
 {
     MMAnimator.UpdateAnimatorBool(_animator, "FollowingPath", (_movement.CurrentState == CharacterStates.MovementStates.FollowingPath), _character._animatorParameters);
     MMAnimator.UpdateAnimatorFloat(_animator, "FollowingPathSpeed", Mathf.Abs(_mmPathMovement.CurrentSpeed.magnitude), _character._animatorParameters);
 }
Exemplo n.º 10
0
 /// <summary>
 /// At the end of each cycle, we send our character's animator the current flying status
 /// </summary>
 public override void UpdateAnimator()
 {
     MMAnimator.UpdateAnimatorBool(_animator, "Flying", (_movement.CurrentState == CharacterStates.MovementStates.Flying), _character._animatorParameters);
     MMAnimator.UpdateAnimatorFloat(_animator, "FlySpeed", Mathf.Abs(_controller.Speed.magnitude), _character._animatorParameters);
 }
Exemplo n.º 11
0
 /// <summary>
 /// At the end of each cycle, we update our animator with our various states
 /// </summary>
 public override void UpdateAnimator()
 {
     MMAnimator.UpdateAnimatorBool(_animator, "LadderClimbing", (_movement.CurrentState == CharacterStates.MovementStates.LadderClimbing), _character._animatorParameters);
     MMAnimator.UpdateAnimatorFloat(_animator, "LadderClimbingSpeedX", CurrentLadderClimbingSpeed.x, _character._animatorParameters);
     MMAnimator.UpdateAnimatorFloat(_animator, "LadderClimbingSpeedY", CurrentLadderClimbingSpeed.y, _character._animatorParameters);
 }
Exemplo n.º 12
0
 /// <summary>
 /// Sends the current speed and the current value of the Walking state to the animator
 /// </summary>
 public override void UpdateAnimator()
 {
     MMAnimator.UpdateAnimatorFloat(_animator, "Speed", Mathf.Abs(_normalizedHorizontalSpeed), _character._animatorParameters);
     MMAnimator.UpdateAnimatorBool(_animator, "Walking", (_movement.CurrentState == CharacterStates.MovementStates.Walking), _character._animatorParameters);
     MMAnimator.UpdateAnimatorBool(_animator, "AimLocked", (_inputManager.AimLockButton.State.CurrentState == MMInput.ButtonStates.ButtonPressed), _character._animatorParameters);
 }