Exemplo n.º 1
0
        /// <summary>
        /// Triggered when something exits the water
        /// </summary>
        /// <param name="collider">Something colliding with the dialogue zone.</param>
        protected virtual void OnTriggerExit2D(Collider2D collider)
        {
            // we check that the object colliding with the water is actually a corgi controller and a character
            Character character = collider.GetComponent <Character>();
            CharacterButtonActivation characterButtonActivation = collider.GetComponent <CharacterButtonActivation>();

            if (!CheckConditions(character, characterButtonActivation))
            {
                return;
            }

            if (ShouldUpdateState)
            {
                _characterButtonActivation = characterButtonActivation;
                if (characterButtonActivation != null)
                {
                    characterButtonActivation.InButtonActivatedZone = false;
                    characterButtonActivation.ButtonActivatedZone   = null;
                }
            }

            if ((_buttonA != null) && !AlwaysShowPrompt)
            {
                StartCoroutine(HidePrompt());
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// Determines whether or not this zone should be activated
        /// </summary>
        /// <returns><c>true</c>, if conditions was checked, <c>false</c> otherwise.</returns>
        /// <param name="character">Character.</param>
        /// <param name="characterButtonActivation">Character button activation.</param>
        protected virtual bool CheckConditions(Character character, CharacterButtonActivation characterButtonActivation)
        {
            if (character == null)
            {
                return(false);
            }

            if (RequiresPlayerCharacter)
            {
                if (character.CharacterType != Character.CharacterTypes.Player)
                {
                    return(false);
                }
            }

            if (RequiresButtonActivationAbility)
            {
                // we check that the object colliding with the water is actually a corgi controller and a character
                if (characterButtonActivation == null)
                {
                    return(false);
                }
            }

            return(true);
        }
Exemplo n.º 3
0
        /// <summary>
        /// Triggered when something exits the water
        /// </summary>
        /// <param name="collider">Something colliding with the dialogue zone.</param>
        protected virtual void TriggerExit(GameObject collider)
        {
            // we check that the object colliding with the water is actually a TopDown controller and a character
            Character character = collider.gameObject.GetComponentNoAlloc <Character>();
            CharacterButtonActivation characterButtonActivation = collider.gameObject.GetComponentNoAlloc <CharacterButtonActivation>();

            if (!CheckConditions(character, characterButtonActivation))
            {
                return;
            }

            if (ShouldUpdateState)
            {
                _characterButtonActivation = characterButtonActivation;
                if (characterButtonActivation != null)
                {
                    characterButtonActivation.InButtonActivatedZone = false;
                    characterButtonActivation.ButtonActivatedZone   = null;
                }
            }

            if ((_buttonPrompt != null) && !AlwaysShowPrompt)
            {
                HidePrompt();
            }

            _currentCharacter = null;
        }
Exemplo n.º 4
0
        /// <summary>
        /// Triggered when something collides with the button activated zone
        /// </summary>
        /// <param name="collider">Something colliding with the water.</param>
        protected virtual void TriggerEnter(GameObject collider)
        {
            _currentCharacter = collider.gameObject.GetComponentNoAlloc <Character>();
            CharacterButtonActivation characterButtonActivation = collider.gameObject.GetComponentNoAlloc <CharacterButtonActivation>();

            if (!CheckConditions(_currentCharacter, characterButtonActivation))
            {
                return;
            }


            if (ShouldUpdateState)
            {
                _characterButtonActivation = characterButtonActivation;
                if (characterButtonActivation != null)
                {
                    characterButtonActivation.InButtonActivatedZone     = true;
                    characterButtonActivation.ButtonActivatedZone       = this;
                    characterButtonActivation.InButtonAutoActivatedZone = AutoActivation;
                }
            }

            if (AutoActivation)
            {
                TriggerButtonAction();
            }

            // if we're not already showing the prompt and if the zone can be activated, we show it
            if (ShowPromptWhenColliding)
            {
                ShowPrompt();
            }
        }
Exemplo n.º 5
0
 /// <summary>
 /// On Start() we reset our number of jumps
 /// </summary>
 protected override void Initialization()
 {
     base.Initialization();
     ResetNumberOfJumps();
     _characterWallJump           = GetComponent <CharacterWalljump>();
     _characterCrouch             = GetComponent <CharacterCrouch>();
     _characterButtonActivation   = GetComponent <CharacterButtonActivation>();
     _characterHorizontalMovement = GetComponent <CharacterHorizontalMovement> ();
     _characterLadder             = GetComponent <CharacterLadder>();
 }
Exemplo n.º 6
0
 /// <summary>
 /// On Start() we reset our number of jumps
 /// </summary>
 protected override void Initialization()
 {
     base.Initialization();
     ResetNumberOfJumps();
     _characterWallJump         = GetComponent <CharacterWalljump>();
     _characterCrouch           = GetComponent <CharacterCrouch>();
     _characterButtonActivation = GetComponent <CharacterButtonActivation>();
     _characterLadder           = GetComponent <CharacterLadder>();
     _initialNumberOfJumps      = NumberOfJumps;
     CanJumpStop = true;
 }
 /// <summary>
 /// On Start() we reset our number of jumps
 /// </summary>
 protected override void Initialization()
 {
     base.Initialization();
     ResetNumberOfJumps();
     _characterWallJump         = _character?.FindAbility <CharacterWalljump>();
     _characterCrouch           = _character?.FindAbility <CharacterCrouch>();
     _characterButtonActivation = _character?.FindAbility <CharacterButtonActivation>();
     _characterLadder           = _character?.FindAbility <CharacterLadder>();
     _initialNumberOfJumps      = NumberOfJumps;
     CanJumpStop = true;
 }
        /// <summary>
        /// Determines whether or not this zone should be activated
        /// </summary>
        /// <returns><c>true</c>, if conditions was checked, <c>false</c> otherwise.</returns>
        /// <param name="character">Character.</param>
        /// <param name="characterButtonActivation">Character button activation.</param>
        protected virtual bool CheckConditions(GameObject collider)
        {
            Character character = collider.gameObject.MMGetComponentNoAlloc <Character>();

            switch (ButtonActivatedRequirement)
            {
            case ButtonActivatedRequirements.Character:
                if (character == null)
                {
                    return(false);
                }
                break;

            case ButtonActivatedRequirements.ButtonActivator:
                if (collider.gameObject.MMGetComponentNoAlloc <ButtonActivator>() == null)
                {
                    return(false);
                }
                break;

            case ButtonActivatedRequirements.Either:
                if ((character == null) && (collider.gameObject.MMGetComponentNoAlloc <ButtonActivator>() == null))
                {
                    return(false);
                }
                break;
            }

            if (RequiresPlayerType)
            {
                if (character == null)
                {
                    return(false);
                }
                if (character.CharacterType != Character.CharacterTypes.Player)
                {
                    return(false);
                }
            }

            if (RequiresButtonActivationAbility)
            {
                CharacterButtonActivation characterButtonActivation = collider.gameObject.MMGetComponentNoAlloc <Character>()?.FindAbility <CharacterButtonActivation>();
                // we check that the object colliding with the water is actually a CorgiController and a character
                if (characterButtonActivation == null)
                {
                    return(false);
                }
            }

            return(true);
        }
Exemplo n.º 9
0
        /// <summary>
        /// Triggered when something collides with the button activated zone
        /// </summary>
        /// <param name="collider">Something colliding with the water.</param>
        protected virtual void OnTriggerEnter2D(Collider2D collider)
        {
            Character character = collider.gameObject.GetComponentNoAlloc <Character>();
            CharacterButtonActivation characterButtonActivation = collider.gameObject.GetComponentNoAlloc <CharacterButtonActivation>();

            if (!CheckConditions(character, characterButtonActivation))
            {
                return;
            }

            // if we can only activate this zone when grounded, we check if we have a controller and if it's not grounded,
            // we do nothing and exit
            if (CanOnlyActivateIfGrounded)
            {
                if (character != null)
                {
                    CorgiController controller = collider.gameObject.GetComponentNoAlloc <CorgiController>();
                    if (controller != null)
                    {
                        if (!controller.State.IsGrounded)
                        {
                            return;
                        }
                    }
                }
            }

            if (ShouldUpdateState)
            {
                _characterButtonActivation = characterButtonActivation;
                if (characterButtonActivation != null)
                {
                    characterButtonActivation.InButtonActivatedZone = true;
                    characterButtonActivation.ButtonActivatedZone   = this;
                }
            }

            if (AutoActivation)
            {
                TriggerButtonAction();
            }

            // if we're not already showing the prompt and if the zone can be activated, we show it
            if (CanShowPrompt() && ShowPromptWhenColliding)
            {
                ShowPrompt();
            }
        }
Exemplo n.º 10
0
        /// <summary>
        /// When exiting, and if needed, we reset the time scale
        /// </summary>
        /// <param name="collider"></param>
        protected override void TriggerExit(GameObject collider)
        {
            base.TriggerExit(collider);
            if (Mode == Modes.ExitBased)
            {
                Character character = collider.gameObject.GetComponentNoAlloc <Character>();
                CharacterButtonActivation characterButtonActivation = collider.gameObject.GetComponentNoAlloc <CharacterButtonActivation>();

                if (!CheckConditions(character, characterButtonActivation))
                {
                    return;
                }

                MMTimeScaleEvent.Trigger(MMTimeScaleMethods.Unfreeze, 1f, 0f, false, 0f, false);
            }
        }
        /// <summary>
        /// Triggered when something collides with the button activated zone
        /// </summary>
        /// <param name="collider">Something colliding with the water.</param>
        protected virtual void TriggerEnter(GameObject collider)
        {
            if (!CheckConditions(collider))
            {
                return;
            }

            // at this point the object is colliding and authorized, we add it to our list
            _collidingObjects.Add(collider.gameObject);
            if (!TestForLastObject(collider))
            {
                return;
            }

            _currentCharacter = collider.gameObject.MMGetComponentNoAlloc <Character>();

            if (ShouldUpdateState)
            {
                _characterButtonActivation = _currentCharacter?.FindAbility <CharacterButtonActivation>();
                if (_characterButtonActivation != null)
                {
                    _characterButtonActivation.InButtonActivatedZone     = true;
                    _characterButtonActivation.ButtonActivatedZone       = this;
                    _characterButtonActivation.InButtonAutoActivatedZone = AutoActivation;
                    _characterButtonActivation.InJumpPreventingZone      = PreventJumpsWhileInThisZone;
                    _characterButtonActivation.SetTriggerParameter();
                }
            }

            EnterFeedback?.PlayFeedbacks(this.transform.position);

            if (AutoActivation)
            {
                TriggerButtonAction(collider);
            }

            // if we're not already showing the prompt and if the zone can be activated, we show it
            if (ShowPromptWhenColliding)
            {
                ShowPrompt();
            }

            TriggerEnterAction(collider);
        }
        /// <summary>
        /// Triggered when something exits the water
        /// </summary>
        /// <param name="collider">Something colliding with the dialogue zone.</param>
        protected virtual void TriggerExit(GameObject collider)
        {
            // we check that the object colliding with the water is actually a CorgiController and a character

            if (!CheckConditions(collider))
            {
                return;
            }

            _collidingObjects.Remove(collider.gameObject);
            if (!TestForLastObject(collider))
            {
                return;
            }

            _currentCharacter = null;

            if (ShouldUpdateState)
            {
                _characterButtonActivation = collider.gameObject.MMGetComponentNoAlloc <Character>()?.FindAbility <CharacterButtonActivation>();
                if (_characterButtonActivation != null)
                {
                    _characterButtonActivation.InButtonActivatedZone     = false;
                    _characterButtonActivation.ButtonActivatedZone       = null;
                    _characterButtonActivation.InButtonAutoActivatedZone = false;
                    _characterButtonActivation.InJumpPreventingZone      = false;
                }
            }

            ExitFeedback?.PlayFeedbacks(this.transform.position);

            if ((_buttonPrompt != null) && !AlwaysShowPrompt)
            {
                HidePrompt();
            }

            TriggerExitAction(collider);
        }