Esempio n. 1
0
        /// <summary>
        /// Tries to activate the button activated zone
        /// </summary>
        protected virtual void ButtonActivation()
        {
            // if the player is in a button activated zone, we handle it
            if ((InButtonActivatedZone) &&
                (ButtonActivatedZone != null) &&
                (_condition.CurrentState == CharacterStates.CharacterConditions.Normal || _condition.CurrentState == CharacterStates.CharacterConditions.Frozen) &&
                (_movement.CurrentState != CharacterStates.MovementStates.Dashing))
            {
                // if the button can only be activated while grounded and if we're not grounded, we do nothing and exit
                if (ButtonActivatedZone.CanOnlyActivateIfGrounded && !_controller.State.IsGrounded)
                {
                    return;
                }
                // if it's an auto activated zone, we do nothing
                if (ButtonActivatedZone.AutoActivation && !ButtonActivatedZone.AutoActivationAndButtonInteraction)
                {
                    return;
                }
                // we trigger a character event
                MMCharacterEvent.Trigger(_character, MMCharacterEventTypes.ButtonActivation);

                ButtonActivatedZone.TriggerButtonAction(_character.gameObject);
                PlayAbilityStartFeedbacks();

                _activating = true;
            }
        }
Esempio n. 2
0
        /// <summary>
        /// Causes the character to start jumping.
        /// </summary>
        public virtual void JumpStart()
        {
            if (!EvaluateJumpConditions())
            {
                return;
            }
            // we reset our walking speed
            if ((_movement.CurrentState == CharacterStates.MovementStates.Crawling) ||
                (_movement.CurrentState == CharacterStates.MovementStates.Crouching) ||
                (_movement.CurrentState == CharacterStates.MovementStates.LadderClimbing))
            {
                _characterHorizontalMovement.ResetHorizontalSpeed();
            }

            if (_movement.CurrentState == CharacterStates.MovementStates.LadderClimbing)
            {
                _characterLadder.GetOffTheLadder();
            }

            _controller.ResetColliderSize();

            // if we're still here, the jump will happen
            // we set our current state to Jumping
            _movement.ChangeState(CharacterStates.MovementStates.Jumping);

            // we trigger a character event
            MMCharacterEvent.Trigger(_character, MMCharacterEventTypes.Jump);

            // we start our sounds
            PlayAbilityStartSfx();

            if (ResetCameraOffsetOnJump)
            {
                _sceneCamera.ResetLookUpDown();
            }

            if (NumberOfJumpsLeft != NumberOfJumps)
            {
                _doubleJumping = true;
            }

            // we decrease the number of jumps left
            NumberOfJumpsLeft = NumberOfJumpsLeft - 1;

            // we reset our current condition and gravity
            _condition.ChangeState(CharacterStates.CharacterConditions.Normal);
            _controller.GravityActive(true);
            _controller.CollisionsOn();

            // we set our various jump flags and counters
            SetJumpFlags();
            CanJumpStop = true;

            // we make the character jump
            _controller.SetVerticalForce(Mathf.Sqrt(2f * JumpHeight * Mathf.Abs(_controller.Parameters.Gravity)));
            JumpHappenedThisFrame = true;
        }
Esempio n. 3
0
 public virtual void OnMMEvent(MMCharacterEvent characterEvent)
 {
     if (characterEvent.TargetCharacter.CharacterType == Character.CharacterTypes.Player)
     {
         switch (characterEvent.EventType)
         {
         case MMCharacterEventTypes.Jump:
             MMAchievementManager.AddProgress("JumpAround", 1);
             break;
         }
     }
 }