/// <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.Grounded)
                {
                    return;
                }

                // if it's an auto activated zone, we do nothing
                if (ButtonActivatedZone.AutoActivation)
                {
                    return;
                }

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

                ButtonActivatedZone.TriggerButtonAction();
                PlayAbilityStartFeedbacks();
                _activating = true;
            }
        }
Esempio n. 2
0
        /// <summary>
        /// Starts a jump
        /// </summary>
        public virtual void JumpStart()
        {
            if (!EvaluateJumpConditions())
            {
                return;
            }
            _movement.ChangeState(CharacterStates.MovementStates.Jumping);
            MMCharacterEvent.Trigger(_character, MMCharacterEventTypes.Jump);
            JumpStartFeedback?.PlayFeedbacks(this.transform.position);
            PlayAbilityStartFeedbacks();

            _jumpStopped    = false;
            _jumpStartedAt  = Time.time;
            _buttonReleased = false;
        }
        /// <summary>
        /// Starts a jump
        /// </summary>
        protected virtual void HoverStart()
        {
            if (!EvaluateJumpConditions())
            {
                return;
            }
            _movement.ChangeState(CharacterStates.MovementStates.Hovering);
            MMCharacterEvent.Trigger(_character, MMCharacterEventTypes.Hover);
            gameObject.layer = 23;
            HoverStartFeedback?.PlayFeedbacks(this.transform.position);
            PlayAbilityStartFeedbacks();

            _hoverStopped   = false;
            _hoverStartedAt = Time.time;
            _buttonReleased = false;
        }
Esempio n. 4
0
        /// <summary>
        /// On jump start, we change our state to jumping
        /// </summary>
        public virtual void JumpStart()
        {
            if (!EvaluateJumpConditions())
            {
                return;
            }

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

            _movement.ChangeState(CharacterStates.MovementStates.Jumping);
            MMCharacterEvent.Trigger(_character, MMCharacterEventTypes.Jump);
            JumpStartFeedback?.PlayFeedbacks(this.transform.position);
            _jumpOrigin               = this.transform.position;
            _jumpStopped              = false;
            _jumpStartedAt            = Time.time;
            _controller.Grounded      = false;
            _controller.GravityActive = false;
            _buttonReleased           = false;

            PlayAbilityStartSfx();
            PlayAbilityUsedSfx();
            PlayAbilityStartFeedbacks();
        }