Beispiel #1
0
        /// <summary>
        /// Triggered when something collides with the override zone
        /// </summary>
        /// <param name="collider">Something colliding with the override zone.</param>
        protected virtual void OnTriggerEnter2D(Collider2D collider)
        {
            // we check that the object colliding with the override zone is actually a characterJump
            CharacterJump characterJump = collider.GetComponent <CharacterJump>();

            if (characterJump == null)
            {
                return;
            }

            _previousJumpHeight         = characterJump.JumpHeight;
            _previousJumpMinimumAirTime = characterJump.JumpMinimumAirTime;
            _previousNumberOfJumps      = characterJump.NumberOfJumps;
            _previousJumpRestrictions   = characterJump.JumpRestrictions;
            _previousNumberOfJumpsLeft  = characterJump.NumberOfJumpsLeft;

            characterJump.JumpHeight         = JumpHeight;
            characterJump.JumpMinimumAirTime = JumpMinimumAirTime;
            characterJump.NumberOfJumps      = NumberOfJumps;
            characterJump.JumpRestrictions   = JumpRestrictions;
            if (ResetNumberOfJumpsLeft)
            {
                characterJump.SetNumberOfJumpsLeft(NumberOfJumps);
            }
        }
Beispiel #2
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 #3
0
 /// <summary>
 /// On Start we grab our components
 /// </summary>
 protected override void Initialization()
 {
     base.Initialization();
     _characterJump     = this.gameObject.MMGetComponentNoAlloc <CharacterJump>();
     _characterWallJump = this.gameObject.MMGetComponentNoAlloc <CharacterWalljump>();
     _characterSwim     = this.gameObject.MMGetComponentNoAlloc <CharacterSwim>();
 }
Beispiel #4
0
        ///
        protected override void Initialization()
        {
            if (LevelManager.Instance.Players.Count == 0)
            {
                Debug.LogError("No player found!");
                return;
            }

            if (_controller == null)
            {
                _controller   = this.gameObject.GetComponent <CorgiController>();
                thisCharacter = this.gameObject.GetComponent <Character>();
            }
            else
            {
                _controller   = this.gameObject.GetComponentInParent <CorgiController>();
                thisCharacter = this.gameObject.GetComponentInParent <Character>();
            }

            _characterHorizontalMovement = thisCharacter?.FindAbility <CharacterHorizontalMovement>();
            _characterRun  = thisCharacter?.FindAbility <CharacterRun>();
            _characterJump = thisCharacter?.FindAbility <CharacterJump>();
            _jetpack       = thisCharacter?.FindAbility <CharacterJetpack>();

            thisCharacter.MovementState.ChangeState(CharacterStates.MovementStates.Idle);
        }
 /// <summary>
 /// On Start we grab our components
 /// </summary>
 protected override void Initialization()
 {
     base.Initialization();
     _characterJump     = _character?.FindAbility <CharacterJump>();
     _characterWallJump = _character?.FindAbility <CharacterWalljump>();
     _characterSwim     = _character?.FindAbility <CharacterSwim>();
 }
 /// <summary>
 /// On init we grab our AI components
 /// </summary>
 protected override void Initialization()
 {
     _controller = GetComponent <CorgiController>();
     _character  = GetComponent <Character>();
     _characterHorizontalMovement = GetComponent <CharacterHorizontalMovement>();
     _characterJump = GetComponent <CharacterJump>();
     _direction     = _character.IsFacingRight ? Vector2.right : Vector2.left;
 }
Beispiel #7
0
 /// <summary>
 /// On late update we set a force to our collider's controller if we have one
 /// </summary>
 protected virtual void LateUpdate()
 {
     if (_controller != null)
     {
         _controller.SetVerticalForce(Mathf.Sqrt(2f * JumpPlatformBoost * -_controller.Parameters.Gravity));
         _characterJump = _controller.gameObject.GetComponentNoAlloc <CharacterJump>();
         if (_characterJump != null)
         {
             _characterJump.CanJumpStop = false;
         }
     }
 }
Beispiel #8
0
 protected virtual void Update()
 {
     if ((_character != null) && (_characterJump != null))
     {
         if (_character.ConditionState.CurrentState == CharacterStates.CharacterConditions.Dead)
         {
             Restore();
             _character     = null;
             _characterJump = null;
         }
     }
 }
 /// <summary>
 /// On late update we set a force to our collider's controller if we have one
 /// </summary>
 protected virtual void LateUpdate()
 {
     if (_controller != null)
     {
         _controller.SetVerticalForce(Mathf.Sqrt(2f * JumpPlatformBoost * -_controller.Parameters.Gravity));
         _characterJump = _controller.gameObject.MMGetComponentNoAlloc <Character>()?.FindAbility <CharacterJump>();
         if (_characterJump != null)
         {
             _characterJump.CanJumpStop = false;
         }
         ActivationFeedback?.PlayFeedbacks();
     }
 }
        ///
        protected override void Initialization()
        {
            AgentFollowsPlayer = false;
            _target            = LevelManager.Instance.Players[0].transform;

            _controller             = GetComponent <CorgiController>();
            _targetCharacter        = GetComponent <Character>();
            _characterBasicMovement = GetComponent <CharacterHorizontalMovement>();
            _targetCharacter.MovementState.ChangeState(CharacterStates.MovementStates.Idle);
            _characterRun      = GetComponent <CharacterRun>();
            _characterJump     = GetComponent <CharacterJump>();
            _jetpack           = GetComponent <CharacterJetpack>();
            followSpeedStorage = followSpeed;
        }
Beispiel #11
0
        /// <summary>
        /// Initialization
        /// </summary>
        protected virtual void Start()
        {
            if (LevelManager.Instance.Players.Count == 0)
            {
                return;
            }
            // we get the player
            _target = LevelManager.Instance.Players[0].transform;
            // we get its components
            _controller                  = GetComponent <CorgiController>();
            _targetCharacter             = GetComponent <Character>();
            _characterHorizontalMovement = GetComponent <CharacterHorizontalMovement>();
            _characterRun                = GetComponent <CharacterRun>();
            _characterJump               = GetComponent <CharacterJump>();
            _jetpack = GetComponent <CharacterJetpack>();

            // we make the agent start following the player
            AgentFollowsPlayer = true;

            _targetCharacter.MovementState.ChangeState(CharacterStates.MovementStates.Idle);
        }
Beispiel #12
0
        /// <summary>
        /// Triggered when something exits the water
        /// </summary>
        /// <param name="collider">Something colliding with the water.</param>
        protected virtual void OnTriggerExit2D(Collider2D collider)
        {
            // we check that the object colliding with the water is actually a characterJump
            CharacterJump characterJump = collider.GetComponent <CharacterJump>();

            if (characterJump == null)
            {
                return;
            }

            characterJump.JumpHeight         = _previousJumpHeight;
            characterJump.JumpMinimumAirTime = _previousJumpMinimumAirTime;
            characterJump.NumberOfJumps      = _previousNumberOfJumps;
            characterJump.JumpRestrictions   = _previousJumpRestrictions;
            if (ResetNumberOfJumpsLeft)
            {
                characterJump.SetNumberOfJumpsLeft(characterJump.NumberOfJumps);
            }
            else
            {
                characterJump.SetNumberOfJumpsLeft(_previousNumberOfJumpsLeft);
            }
        }
Beispiel #13
0
 /// <summary>
 /// On Start() we grab a few components for storage
 /// </summary>
 protected override void Initialization()
 {
     base.Initialization();
     _characterJump          = this.gameObject.GetComponent <CharacterJump>();
     _climbingAnimationDelay = new WaitForSeconds(ClimbingAnimationDuration);
 }
Beispiel #14
0
 /// <summary>
 /// On Start() we grab our character jump component
 /// </summary>
 protected override void Initialization()
 {
     base.Initialization();
     _characterJump = GetComponent <CharacterJump>();
 }
 /// <summary>
 /// On Start() we grab a few components for storage
 /// </summary>
 protected override void Initialization()
 {
     base.Initialization();
     _characterJump          = _character?.FindAbility <CharacterJump>();
     _climbingAnimationDelay = new WaitForSeconds(ClimbingAnimationDuration);
 }
Beispiel #16
0
 /// <summary>
 /// On init we grab our CharacterJump component
 /// </summary>
 protected override void Initialization()
 {
     _characterJump = this.gameObject.GetComponent <CharacterJump>();
 }
Beispiel #17
0
 /// <summary>
 /// On init we grab our CharacterJump component
 /// </summary>
 protected override void Initialization()
 {
     _characterJump = this.gameObject.GetComponentInParent <Character>()?.FindAbility <CharacterJump>();
 }
Beispiel #18
0
 /// <summary>
 /// Triggered when something exits the water
 /// </summary>
 /// <param name="collider">Something colliding with the water.</param>
 protected virtual void OnTriggerExit2D(Collider2D collider)
 {
     // we check that the object colliding with the water is actually a characterJump
     _characterJump = collider.GetComponent <CharacterJump>();
     Restore();
 }