Exemplo n.º 1
0
 /// <summary>
 /// On init we grab our components
 /// </summary>
 protected override void Initialization()
 {
     base.Initialization();
     _characterButtonActivation = _character?.FindAbility <CharacterButtonActivation> ();
     JumpStartFeedback?.Initialization(this.gameObject);
     JumpStopFeedback?.Initialization(this.gameObject);
 }
Exemplo n.º 2
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)
        {
            if (!CheckConditions(collider))
            {
                return;
            }

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

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

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

            TriggerExitAction(collider);
        }
Exemplo n.º 3
0
 /// <summary>
 /// On init we grab our components
 /// </summary>
 protected override void Initialization()
 {
     base.Initialization();
     _characterButtonActivation = GetComponent <CharacterButtonActivation> ();
     JumpStartFeedback?.Initialization(this.gameObject);
     JumpStopFeedback?.Initialization(this.gameObject);
 }
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)
        {
            if (!CheckConditions(collider))
            {
                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 (collider != null)
                {
                    TopDownController controller = collider.gameObject.MMGetComponentNoAlloc <TopDownController>();
                    if (controller != null)
                    {
                        if (!controller.Grounded)
                        {
                            return;
                        }
                    }
                }
            }

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

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

            if (AutoActivation)
            {
                _autoActivationCoroutine = StartCoroutine(TriggerButtonActionCo());
            }

            // 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>
        /// 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 <CharacterButtonActivation>();
                // we check that the object colliding with the water is actually a TopDown controller and a character
                if (characterButtonActivation == null)
                {
                    return(false);
                }
            }

            return(true);
        }
Exemplo n.º 6
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)
        {
            if (!CheckConditions(collider))
            {
                return;
            }

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

            AutoActivationInProgress = false;
            if (_autoActivationCoroutine != null)
            {
                StopCoroutine(_autoActivationCoroutine);
            }

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

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

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

            TriggerExitAction(collider);
        }