Beispiel #1
0
        /// <summary>
        /// Performs the stomp.
        /// </summary>
        /// <param name="corgiController">Corgi controller.</param>
        protected virtual void PerformStomp(CorgiController corgiController)
        {
            if (DamageCausedKnockbackType == KnockbackStyles.SetForce)
            {
                corgiController.SetForce(KnockbackForce);
            }
            if (DamageCausedKnockbackType == KnockbackStyles.AddForce)
            {
                corgiController.AddForce(KnockbackForce);
            }

            if (_health != null)
            {
                _health.Damage(DamagePerStomp, corgiController.gameObject, InvincibilityDuration, InvincibilityDuration);
            }

            // if what's colliding with us has a CharacterJump component, we reset its JumpButtonReleased flag so that the knockback effect is applied correctly.
            CharacterJump _collidingCharacterJump = corgiController.gameObject.MMGetComponentNoAlloc <CharacterJump>();

            if (_collidingCharacterJump != null)
            {
                _collidingCharacterJump.ResetJumpButtonReleased();
                if (ResetNumberOfJumpsOnStomp)
                {
                    _collidingCharacterJump.ResetNumberOfJumps();
                }
            }
        }
Beispiel #2
0
 /// <summary>
 /// Called at update, handles gripping to Grip components (ropes, etc)
 /// </summary>
 protected virtual void Grip()
 {
     // if we're gripping to something, we disable the gravity
     if (_movement.CurrentState == CharacterStates.MovementStates.Gripping)
     {
         _controller.SetForce(Vector2.zero);
         _controller.GravityActive(false);
         if (_characterJump != null)
         {
             _characterJump.ResetNumberOfJumps();
         }
         _controller.SetTransformPosition(_gripTarget.transform.position + _gripTarget.GripOffset);
     }
 }
Beispiel #3
0
 /// <summary>
 /// Every frame, if we're hanging from a ledge, we prevent any force from moving our character, prevent flip and force our position to the ledge's offset
 /// </summary>
 protected virtual void HandleLedge()
 {
     if (_movement.CurrentState == CharacterStates.MovementStates.LedgeHanging)
     {
         _controller.SetForce(Vector2.zero);
         _controller.GravityActive(false);
         if (_characterJump != null)
         {
             _characterJump.ResetNumberOfJumps();
         }
         _characterHorizontalMovement.AbilityPermitted = false;
         _character.CanFlip             = false;
         _controller.transform.position = _ledge.transform.position + _ledge.HangOffset;
     }
 }