Exemple #1
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))
            {
                MMAnimatorExtensions.UpdateAnimatorBool(_animator, _groundedAnimationParameter, _controller.State.IsGrounded, _animatorParameters);
                MMAnimatorExtensions.UpdateAnimatorBool(_animator, _airborneSpeedAnimationParameter, Airborne, _animatorParameters);
                MMAnimatorExtensions.UpdateAnimatorBool(_animator, _aliveAnimationParameter, (ConditionState.CurrentState != CharacterStates.CharacterConditions.Dead), _animatorParameters);
                MMAnimatorExtensions.UpdateAnimatorFloat(_animator, _xSpeedSpeedAnimationParameter, _controller.Speed.x, _animatorParameters);
                MMAnimatorExtensions.UpdateAnimatorFloat(_animator, _ySpeedSpeedAnimationParameter, _controller.Speed.y, _animatorParameters);
                MMAnimatorExtensions.UpdateAnimatorFloat(_animator, _worldXSpeedSpeedAnimationParameter, _controller.WorldSpeed.x, _animatorParameters);
                MMAnimatorExtensions.UpdateAnimatorFloat(_animator, _worldYSpeedSpeedAnimationParameter, _controller.WorldSpeed.y, _animatorParameters);
                MMAnimatorExtensions.UpdateAnimatorBool(_animator, _collidingLeftAnimationParameter, _controller.State.IsCollidingLeft, _animatorParameters);
                MMAnimatorExtensions.UpdateAnimatorBool(_animator, _collidingRightAnimationParameter, _controller.State.IsCollidingRight, _animatorParameters);
                MMAnimatorExtensions.UpdateAnimatorBool(_animator, _collidingBelowAnimationParameter, _controller.State.IsCollidingBelow, _animatorParameters);
                MMAnimatorExtensions.UpdateAnimatorBool(_animator, _collidingAboveAnimationParameter, _controller.State.IsCollidingAbove, _animatorParameters);
                MMAnimatorExtensions.UpdateAnimatorBool(_animator, _idleSpeedAnimationParameter, (MovementState.CurrentState == CharacterStates.MovementStates.Idle), _animatorParameters);
                MMAnimatorExtensions.UpdateAnimatorBool(_animator, _facingRightAnimationParameter, IsFacingRight, _animatorParameters);

                foreach (CharacterAbility ability in _characterAbilities)
                {
                    if (ability.enabled && ability.AbilityInitialized)
                    {
                        ability.UpdateAnimator();
                    }
                }
            }
        }
Exemple #2
0
        protected virtual void UpdateAnimator(Animator animator, List <int> list)
        {
            MMAnimatorExtensions.UpdateAnimatorBool(animator, _equippedAnimationParameter, true, list);
            MMAnimatorExtensions.UpdateAnimatorBool(animator, _idleAnimationParameter, (WeaponState.CurrentState == Weapon.WeaponStates.WeaponIdle), list);
            MMAnimatorExtensions.UpdateAnimatorBool(animator, _startAnimationParameter, (WeaponState.CurrentState == Weapon.WeaponStates.WeaponStart), list);
            MMAnimatorExtensions.UpdateAnimatorBool(animator, _delayBeforeUseAnimationParameter, (WeaponState.CurrentState == Weapon.WeaponStates.WeaponDelayBeforeUse), list);
            MMAnimatorExtensions.UpdateAnimatorBool(animator, _useAnimationParameter, (WeaponState.CurrentState == Weapon.WeaponStates.WeaponDelayBeforeUse || WeaponState.CurrentState == Weapon.WeaponStates.WeaponUse || WeaponState.CurrentState == Weapon.WeaponStates.WeaponDelayBetweenUses), list);
            MMAnimatorExtensions.UpdateAnimatorBool(animator, _singleUseAnimationParameter, (WeaponState.CurrentState == Weapon.WeaponStates.WeaponUse), list);
            MMAnimatorExtensions.UpdateAnimatorBool(animator, _delayBetweenUsesAnimationParameter, (WeaponState.CurrentState == Weapon.WeaponStates.WeaponDelayBetweenUses), list);
            MMAnimatorExtensions.UpdateAnimatorBool(animator, _stopAnimationParameter, (WeaponState.CurrentState == Weapon.WeaponStates.WeaponStop), list);
            MMAnimatorExtensions.UpdateAnimatorBool(animator, _reloadStartAnimationParameter, (WeaponState.CurrentState == Weapon.WeaponStates.WeaponReloadStart), list);
            MMAnimatorExtensions.UpdateAnimatorBool(animator, _reloadAnimationParameter, (WeaponState.CurrentState == Weapon.WeaponStates.WeaponReload), list);
            MMAnimatorExtensions.UpdateAnimatorBool(animator, _reloadStopAnimationParameter, (WeaponState.CurrentState == Weapon.WeaponStates.WeaponReloadStop), list);

            if (Owner != null)
            {
                MMAnimatorExtensions.UpdateAnimatorBool(animator, _aliveAnimationParameter, (Owner.ConditionState.CurrentState != CharacterStates.CharacterConditions.Dead), list);
            }

            if (_aimableWeapon != null)
            {
                MMAnimatorExtensions.UpdateAnimatorFloat(animator, _weaponAngleAnimationParameter, _aimableWeapon.CurrentAngle, list);
                MMAnimatorExtensions.UpdateAnimatorFloat(animator, _weaponAngleRelativeAnimationParameter, _aimableWeapon.CurrentAngleRelative, list);
            }
            else
            {
                MMAnimatorExtensions.UpdateAnimatorFloat(animator, _weaponAngleAnimationParameter, 0f, list);
                MMAnimatorExtensions.UpdateAnimatorFloat(animator, _weaponAngleRelativeAnimationParameter, 0f, list);
            }

            if (_comboWeapon != null)
            {
                MMAnimatorExtensions.UpdateAnimatorBool(animator, _comboInProgressAnimationParameter, _comboWeapon.ComboInProgress, list);
            }
        }
Exemple #3
0
        /// <summary>
        /// This coroutine handles the climb sequence
        /// </summary>
        /// <returns></returns>
        protected virtual IEnumerator Climb()
        {
            // we start to climb
            _movement.ChangeState(CharacterStates.MovementStates.LedgeClimbing);
            MMAnimatorExtensions.UpdateAnimatorBool(_animator, _ledgeClimbingAnimationParameter, true, _character._animatorParameters);
            // we prevent all other input
            _inputManager.InputDetectionActive = false;

            // we wait until the climb animation is complete
            yield return(_climbingAnimationDelay);

            // we restore input and go to idle
            _inputManager.InputDetectionActive = true;
            MMAnimatorExtensions.UpdateAnimatorBool(_animator, _ledgeClimbingAnimationParameter, false, _character._animatorParameters);
            MMAnimatorExtensions.UpdateAnimatorBool(_animator, _idleAnimationParameter, true, _character._animatorParameters);
            _animator.Play(IdleAnimationName);

            // we teleport our character to its new position (this offset is specified on the Ledge object)
            this.transform.position = _ledge.transform.position + _ledge.ClimbOffset;

            // we go back to idle and detach from the ledge
            _movement.ChangeState(CharacterStates.MovementStates.Idle);
            _controller.GravityActive(true);
            DetachFromLedge();
        }
        /// <summary>
        /// At the end of each cycle, we send our Running status to the character's animator
        /// </summary>
        public override void UpdateAnimator()
        {
            MMAnimatorExtensions.UpdateAnimatorBool(_animator, _dashingAnimationParameter, (_movement.CurrentState == CharacterStates.MovementStates.Dashing), _character._animatorParameters);
            MMAnimatorExtensions.UpdateAnimatorBool(_animator, _dashStartedAnimationParameter, _dashStartedThisFrame, _character._animatorParameters);

            _dashStartedThisFrame = false;
        }
 /// <summary>
 /// Updates the block's animator.
 /// </summary>
 protected virtual void UpdateAnimator()
 {
     if (_animator != null)
     {
         MMAnimatorExtensions.UpdateAnimatorBool(_animator, "Shaking", (State == FallingPlatformStates.Shaking));
     }
 }
Exemple #6
0
 /// <summary>
 /// On reset ability, we cancel all the changes made
 /// </summary>
 public override void ResetAbility()
 {
     base.ResetAbility();
     StopFlight();
     MMAnimatorExtensions.UpdateAnimatorBool(_animator, _flyingAnimationParameter, false, _character._animatorParameters);
     MMAnimatorExtensions.UpdateAnimatorFloat(_animator, _flySpeedAnimationParameter, 0f, _character._animatorParameters);
 }
Exemple #7
0
        /// <summary>
        /// This is called at Update() and sets each of the animators parameters to their corresponding State values
        /// </summary>
        protected virtual void UpdateAnimators()
        {
            UpdateAnimationRandomNumber();

            if ((UseDefaultMecanim) && (_animator != null))
            {
                MMAnimatorExtensions.UpdateAnimatorBool(_animator, _groundedAnimationParameter, _controller.Grounded, _animatorParameters);
                MMAnimatorExtensions.UpdateAnimatorBool(_animator, _aliveAnimationParameter, (ConditionState.CurrentState != CharacterStates.CharacterConditions.Dead), _animatorParameters);
                MMAnimatorExtensions.UpdateAnimatorFloat(_animator, _currentSpeedAnimationParameter, _controller.CurrentMovement.magnitude, _animatorParameters);
                MMAnimatorExtensions.UpdateAnimatorFloat(_animator, _xSpeedAnimationParameter, _controller.CurrentMovement.x, _animatorParameters);
                MMAnimatorExtensions.UpdateAnimatorFloat(_animator, _ySpeedAnimationParameter, _controller.CurrentMovement.y, _animatorParameters);
                MMAnimatorExtensions.UpdateAnimatorFloat(_animator, _zSpeedAnimationParameter, _controller.CurrentMovement.z, _animatorParameters);
                MMAnimatorExtensions.UpdateAnimatorBool(_animator, _idleAnimationParameter, (MovementState.CurrentState == CharacterStates.MovementStates.Idle), _animatorParameters);
                MMAnimatorExtensions.UpdateAnimatorFloat(_animator, _randomAnimationParameter, _animatorRandomNumber, _animatorParameters);


                foreach (CharacterAbility ability in _characterAbilities)
                {
                    if (ability.enabled && ability.AbilityInitialized)
                    {
                        ability.UpdateAnimator();
                    }
                }
            }
        }
 /// <summary>
 /// At the end of each cycle, we update our animator parameters with our current state
 /// </summary>
 public override void UpdateAnimator()
 {
     MMAnimatorExtensions.UpdateAnimatorBool(_animator, _grabbingAnimationParameter, Grabbing, _character._animatorParameters);
     MMAnimatorExtensions.UpdateAnimatorBool(_animator, _throwingAnimationParameter, Throwing, _character._animatorParameters);
     MMAnimatorExtensions.UpdateAnimatorBool(_animator, _carryingAnimationParameter, Carrying, _character._animatorParameters);
     MMAnimatorExtensions.UpdateAnimatorInteger(_animator, _carryingIDAnimationParameter, CarryingID, _character._animatorParameters);
 }
 /// <summary>
 /// On reset ability, we cancel all the changes made
 /// </summary>
 public override void ResetAbility()
 {
     base.ResetAbility();
     Throw();
     MMAnimatorExtensions.UpdateAnimatorBool(_animator, _grabbingAnimationParameter, false, _character._animatorParameters);
     MMAnimatorExtensions.UpdateAnimatorBool(_animator, _throwingAnimationParameter, false, _character._animatorParameters);
     MMAnimatorExtensions.UpdateAnimatorBool(_animator, _carryingAnimationParameter, false, _character._animatorParameters);
 }
Exemple #10
0
 /// <summary>
 /// At the end of the ability's cycle, we send our current crouching and crawling states to the animator
 /// </summary>
 public override void UpdateAnimator()
 {
     MMAnimatorExtensions.UpdateAnimatorBool(_animator, _activatingAnimationParameter, _activating, _character._animatorParameters);
     if (_activating && (ButtonActivatedZone != null) && (ButtonActivatedZone.AnimationTriggerParameterName != ""))
     {
         SetTriggerParameter();
     }
     _activating = false;
 }
 /// <summary>
 /// On reset ability, we cancel all the changes made
 /// </summary>
 public override void ResetAbility()
 {
     base.ResetAbility();
     if (_condition.CurrentState == CharacterStates.CharacterConditions.Normal)
     {
         DetachFromLedge();
     }
     MMAnimatorExtensions.UpdateAnimatorBool(_animator, _ledgeHangingAnimationParameter, false, _character._animatorParameters);
 }
 /// <summary>
 /// On reset ability, we cancel all the changes made
 /// </summary>
 public override void ResetAbility()
 {
     base.ResetAbility();
     if (_condition.CurrentState == CharacterStates.CharacterConditions.Normal)
     {
         RunStop();
     }
     MMAnimatorExtensions.UpdateAnimatorBool(_animator, _runningAnimationParameter, false, _character._animatorParameters);
 }
Exemple #13
0
 /// <summary>
 /// On reset ability, we cancel all the changes made
 /// </summary>
 public override void ResetAbility()
 {
     base.ResetAbility();
     if (_condition.CurrentState == CharacterStates.CharacterConditions.Normal)
     {
         GetOffTheLadder();
     }
     MMAnimatorExtensions.UpdateAnimatorBool(_animator, _ladderClimbingUpAnimationParameter, false, _character._animatorParameters);
 }
Exemple #14
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 override void UpdateAnimator()
 {
     MMAnimatorExtensions.UpdateAnimatorBool(_animator, _weaponEquippedAnimationParameter, (CurrentWeapon != null), _character._animatorParameters);
     if (CurrentWeapon == null)
     {
         MMAnimatorExtensions.UpdateAnimatorInteger(_animator, _weaponEquippedIDAnimationParameter, -1, _character._animatorParameters);
         return;
     }
     else
     {
         MMAnimatorExtensions.UpdateAnimatorInteger(_animator, _weaponEquippedIDAnimationParameter, CurrentWeapon.WeaponAnimationID, _character._animatorParameters);
     }
 }
 /// <summary>
 /// When the character dies we stop its jetpack
 /// </summary>
 public override void ResetAbility()
 {
     // if we have a jetpack particle emitter, we turn it off
     if (ParticleEmitter != null)
     {
         ParticleSystem.EmissionModule emissionModule = ParticleEmitter.emission;
         emissionModule.enabled = false;
     }
     StopStartFeedbacks();
     JetpackFuelDurationLeft = JetpackFuelDuration;
     UpdateJetpackBar();
     MMAnimatorExtensions.UpdateAnimatorBool(_animator, _jetpackingAnimationParameter, false, _character._animatorParameters);
     _movement?.ChangeState(CharacterStates.MovementStates.Idle);
     _stillFuelLeft = true;
 }
Exemple #16
0
 public override void UpdateAnimator()
 {
     MMAnimatorExtensions.UpdateAnimatorBool(_animator, _proneAnimationParameter, (_movement.CurrentState == CharacterStates.MovementStates.Prone), _character._animatorParameters, _character.PerformAnimatorSanityChecks);
     MMAnimatorExtensions.UpdateAnimatorBool(_animator, _proneMovingAnimationParameter, (_movement.CurrentState == CharacterStates.MovementStates.ProneMoving), _character._animatorParameters, _character.PerformAnimatorSanityChecks);
 }
Exemple #17
0
 /// <summary>
 /// At the end of each cycle, sends Jumping states to the Character's animator
 /// </summary>
 public override void UpdateAnimator()
 {
     MMAnimatorExtensions.UpdateAnimatorBool(_animator, _jumpingAnimationParameter, (_movement.CurrentState == CharacterStates.MovementStates.Jumping), _character._animatorParameters);
     MMAnimatorExtensions.UpdateAnimatorBool(_animator, _hitTheGroundAnimationParameter, _controller.JustGotGrounded, _character._animatorParameters);
 }
Exemple #18
0
 /// <summary>
 /// At the end of each cycle, we send our Running status to the character's animator
 /// </summary>
 public override void UpdateAnimator()
 {
     MMAnimatorExtensions.UpdateAnimatorBool(_animator, _swimmingAnimationParameter, (_swimDurationLeft > 0f), _character._animatorParameters);
     MMAnimatorExtensions.UpdateAnimatorBool(_animator, _swimmingIdleAnimationParameter, (_movement.CurrentState == CharacterStates.MovementStates.SwimmingIdle), _character._animatorParameters);
 }
Exemple #19
0
 /// <summary>
 /// At the end of each cycle, we send our character's animator the current fall damage status
 /// </summary>
 public override void UpdateAnimator()
 {
     MMAnimatorExtensions.UpdateAnimatorBool(_animator, _crushedAnimationParameter, _crushedThisFrame, _character._animatorParameters);
 }
Exemple #20
0
 /// <summary>
 /// At the end of each cycle, we send our Running status to the character's animator
 /// </summary>
 public override void UpdateAnimator()
 {
     MMAnimatorExtensions.UpdateAnimatorBool(_animator, _runningAnimationParameter, (_movement.CurrentState == CharacterStates.MovementStates.Running), _character._animatorParameters);
 }
 /// <summary>
 /// Sends the current speed and the current value of the Walking state to the animator
 /// </summary>
 public override void UpdateAnimator()
 {
     MMAnimatorExtensions.UpdateAnimatorFloat(_animator, _speedAnimationParameter, CurrentSpeed, _character._animatorParameters);
     MMAnimatorExtensions.UpdateAnimatorBool(_animator, _walkingAnimationParameter, (_movement.CurrentState == CharacterStates.MovementStates.Walking), _character._animatorParameters);
     MMAnimatorExtensions.UpdateAnimatorBool(_animator, _idleAnimationParameter, (_movement.CurrentState == CharacterStates.MovementStates.Idle), _character._animatorParameters);
 }
Exemple #22
0
 /// <summary>
 /// Sends the current speed and the current value of the Walking state to the animator
 /// </summary>
 public override void UpdateAnimator()
 {
     MMAnimatorExtensions.UpdateAnimatorFloat(_animator, _speedAnimationParameter, Mathf.Abs(_normalizedHorizontalSpeed), _character._animatorParameters);
     MMAnimatorExtensions.UpdateAnimatorBool(_animator, _walkingAnimationParameter, (_movement.CurrentState == CharacterStates.MovementStates.Walking), _character._animatorParameters);
 }
 /// <summary>
 /// At the end of each cycle, we send our Running status to the character's animator
 /// </summary>
 public override void UpdateAnimator()
 {
     MMAnimatorExtensions.UpdateAnimatorBool(_animator, _fallingDownHoleAnimationParameter, (_movement.CurrentState == CharacterStates.MovementStates.FallingDownHole), _character._animatorParameters);
 }
Exemple #24
0
 /// <summary>
 /// At the end of the ability's cycle, we send our current crouching and crawling states to the animator
 /// </summary>
 public override void UpdateAnimator()
 {
     MMAnimatorExtensions.UpdateAnimatorBool(_animator, _stairsAnimationParameter, OnStairs, _character._animatorParameters);
 }
Exemple #25
0
 /// <summary>
 /// On reset ability, we cancel all the changes made
 /// </summary>
 public override void ResetAbility()
 {
     base.ResetAbility();
     MMAnimatorExtensions.UpdateAnimatorBool(_animator, _stairsAnimationParameter, false, _character._animatorParameters);
 }
Exemple #26
0
        /// <summary>
        /// Changes the character's current weapon to the one passed as a parameter
        /// </summary>
        /// <param name="newWeapon">The new weapon.</param>
        public virtual void ChangeWeapon(Weapon newWeapon, string weaponID, bool combo = false)
        {
            // if the character already has a weapon, we make it stop shooting
            if (CurrentWeapon != null)
            {
                if (!combo)
                {
                    ShootStop();

                    AnimatorControllerParameter[] parameters = _character._animator.parameters;
                    foreach (AnimatorControllerParameter parameter in parameters)
                    {
                        if (parameter.name == CurrentWeapon.EquippedAnimationParameter)
                        {
                            MMAnimatorExtensions.UpdateAnimatorBool(_animator, CurrentWeapon.EquippedAnimationParameter, false);
                        }
                    }

                    Destroy(CurrentWeapon.gameObject);
                }
            }

            if (newWeapon != null)
            {
                if (!combo)
                {
                    CurrentWeapon = (Weapon)Instantiate(newWeapon, WeaponAttachment.transform.position + newWeapon.WeaponAttachmentOffset, Quaternion.identity);
                }
                CurrentWeapon.transform.SetParent(WeaponAttachment.transform);
                if (ForceWeaponScaleResetOnEquip)
                {
                    CurrentWeapon.transform.localScale = Vector3.one;
                }
                CurrentWeapon.SetOwner(_character, this);
                CurrentWeapon.WeaponID = weaponID;
                _aimableWeapon         = CurrentWeapon.GetComponent <WeaponAim> ();
                // we handle (optional) inverse kinematics (IK)
                if (_weaponIK != null)
                {
                    _weaponIK.SetHandles(CurrentWeapon.LeftHandHandle, CurrentWeapon.RightHandHandle);
                }
                // we turn off the gun's emitters.
                CurrentWeapon.Initialization();
                CurrentWeapon.InitializeComboWeapons();
                CurrentWeapon.InitializeAnimatorParameters();
                InitializeAnimatorParameters();
                if ((_character != null) && !combo)
                {
                    if (!_character.IsFacingRight)
                    {
                        if (CurrentWeapon != null)
                        {
                            CurrentWeapon.FlipWeapon();
                            CurrentWeapon.FlipWeaponModel();
                        }
                    }
                }
            }
            else
            {
                CurrentWeapon = null;
            }
        }
 /// <summary>
 /// At the end of each cycle, we send our Running status to the character's animator
 /// </summary>
 public override void UpdateAnimator()
 {
     MMAnimatorExtensions.UpdateAnimatorBool(_animator, _waveHandAnimationParameter, (_movement.CurrentState == CharacterStates.MovementStates.WaveHand), _character._animatorParameters);
     MMAnimatorExtensions.UpdateAnimatorBool(_animator, _winAnimationParameter, (_movement.CurrentState == CharacterStates.MovementStates.Win), _character._animatorParameters);
     MMAnimatorExtensions.UpdateAnimatorInteger(_animator, _winIndexAnimationParameter, _randomWinIndex, _character._animatorParameters);
 }
Exemple #28
0
 /// <summary>
 /// At the end of each cycle, we send our character's animator the current flying status
 /// </summary>
 public override void UpdateAnimator()
 {
     MMAnimatorExtensions.UpdateAnimatorBool(_animator, _flyingAnimationParameter, (_movement.CurrentState == CharacterStates.MovementStates.Flying), _character._animatorParameters);
     MMAnimatorExtensions.UpdateAnimatorFloat(_animator, _flySpeedAnimationParameter, Mathf.Abs(_controller.Speed.magnitude), _character._animatorParameters);
 }
 /// <summary>
 /// At the end of the ability's cycle, we send our current crouching and crawling states to the animator
 /// </summary>
 public override void UpdateAnimator()
 {
     MMAnimatorExtensions.UpdateAnimatorBool(_animator, _activatingAnimationParameter, _activating, _character._animatorParameters);
     _activating = false;
 }
Exemple #30
0
 /// <summary>
 /// At the end of each cycle, we send our character's animator the current following status
 /// </summary>
 public override void UpdateAnimator()
 {
     MMAnimatorExtensions.UpdateAnimatorBool(_animator, _followingPathAnimationParameter, (_movement.CurrentState == CharacterStates.MovementStates.FollowingPath), _character._animatorParameters);
     MMAnimatorExtensions.UpdateAnimatorFloat(_animator, _followingPathSpeedAnimationParameter, Mathf.Abs(_mmPathMovement.CurrentSpeed.magnitude), _character._animatorParameters);
 }