Esempio n. 1
0
        protected virtual IEnumerator HideCo()
        {
            StartCoroutine(MMFade.FadeSprite(Border, FadeOutDuration, _alphaZero));
            StartCoroutine(MMFade.FadeSprite(Background, FadeOutDuration, _alphaZero));
            StartCoroutine(MMFade.FadeCanvasGroup(TextCanvasGroup, FadeOutDuration, 0f, true));
            yield return(new WaitForSeconds(0.3f));

            this.gameObject.SetActive(false);
        }
Esempio n. 2
0
        /// <summary>
        /// Fades the dialogue box out.
        /// </summary>
        /// <param name="duration">Duration.</param>
        public virtual void FadeOut(float duration)
        {
            Color newBackgroundColor = new Color(_backgroundColor.r, _backgroundColor.g, _backgroundColor.b, 0);
            Color newTextColor       = new Color(_textColor.r, _textColor.g, _textColor.b, 0);

            StartCoroutine(MMFade.FadeImage(TextPanel, duration, newBackgroundColor));
            StartCoroutine(MMFade.FadeImage(TextPanelArrowDown, duration, newBackgroundColor));
            StartCoroutine(MMFade.FadeText(DialogueText, duration, newTextColor));
            StartCoroutine(MMFade.FadeSprite(_buttonSpriteRenderer, duration, new Color(1f, 1f, 1f, 0f)));
        }
        protected virtual void Kill()
        {
            StartCoroutine(MMFade.FadeSprite(this.GetComponent <SpriteRenderer>(), FadeOutTime, new Color(1f, 1f, 1f, 0f)));
            //StartCoroutine(MMFade.FadeSprite(nodeA.GetComponent<SpriteRenderer>(), FadeOutTime, new Color(1f, 1f, 1f, 0f)));
            //StartCoroutine(MMFade.FadeSprite(nodeB.GetComponent<SpriteRenderer>(), FadeOutTime, new Color(1f, 1f, 1f, 0f)));
            //StartCoroutine(MMFade.FadeSprite(nodeC.GetComponent<SpriteRenderer>(), FadeOutTime, new Color(1f, 1f, 1f, 0f)));
            boxCollider2d.enabled = false;

            nodeA.DoorOpened = true;
            nodeB.DoorOpened = true;
            nodeC.DoorOpened = true;
        }
Esempio n. 4
0
        /// <summary>
        /// Shows the button A prompt.
        /// </summary>
        /// Override for showprompt to show it relative to parent sprite.
        public override void ShowPrompt()
        {
            if (_promptHiddenForever)
            {
                return;
            }
            // we add a blinking A prompt to the top of the zone
            GameObject prompt = (GameObject)Instantiate(Resources.Load("GUI/ButtonA"));

            //We get the transform of the parent sprite to ensure the prompt is above the sprite
            prompt.transform.position = gameObject.GetComponentInParent <BoxCollider2D> ().transform.position + PromptRelativePosition;
            prompt.transform.parent   = transform;
            prompt.GetComponent <SpriteRenderer>().material.color = new Color(1f, 1f, 1f, 0f);
            StartCoroutine(MMFade.FadeSprite(prompt.GetComponent <SpriteRenderer>(), 0.2f, new Color(1f, 1f, 1f, 1f)));
        }
        /// <summary>
        /// Hides the button A prompt.
        /// </summary>
        public virtual IEnumerator HidePrompt()
        {
            if (_buttonA != null)
            {
                if (_buttonA.GetComponent <SpriteRenderer> () != null)
                {
                    StartCoroutine(MMFade.FadeSprite(_buttonA.GetComponent <SpriteRenderer> (), 0.2f, new Color(1f, 1f, 1f, 0f)));
                }
                yield return(new WaitForSeconds(0.3f));

                Destroy(_buttonA);
            }
            else
            {
                yield return(null);
            }
        }
Esempio n. 6
0
 /// <summary>
 /// Fades the dialogue box in.
 /// </summary>
 /// <param name="duration">Duration.</param>
 public virtual void FadeIn(float duration)
 {
     if (TextPanel != null)
     {
         StartCoroutine(MMFade.FadeImage(TextPanel, duration, _backgroundColor));
     }
     if (TextPanelArrowDown != null)
     {
         StartCoroutine(MMFade.FadeImage(TextPanelArrowDown, duration, _backgroundColor));
     }
     if (DialogueText != null)
     {
         StartCoroutine(MMFade.FadeText(DialogueText, duration, _textColor));
     }
     if (_buttonSpriteRenderer != null)
     {
         StartCoroutine(MMFade.FadeSprite(_buttonSpriteRenderer, duration, new Color(1f, 1f, 1f, 1f)));
     }
 }
        /// <summary>
        /// Shows the button A prompt.
        /// </summary>
        public virtual void ShowPrompt()
        {
            if (_promptHiddenForever)
            {
                return;
            }
            // we add a blinking A prompt to the top of the zone
            if (PromptGameobjectOverride != null)
            {
                _buttonA = (GameObject)Instantiate(PromptGameobjectOverride);
            }
            else
            {
                _buttonA = (GameObject)Instantiate(Resources.Load("GUI/ButtonA"));
            }

            _buttonA.transform.position = _collider.bounds.center + PromptRelativePosition;
            _buttonA.transform.parent   = transform;
            if (_buttonA.GetComponent <SpriteRenderer>() != null)
            {
                _buttonA.GetComponent <SpriteRenderer>().material.color = new Color(1f, 1f, 1f, 0f);
                StartCoroutine(MMFade.FadeSprite(_buttonA.GetComponent <SpriteRenderer>(), 0.2f, new Color(1f, 1f, 1f, 1f)));
            }
        }
Esempio n. 8
0
        public override void Kill()
        {
            // we make our handheld device vibrate
            if (VibrateOnDeath)
            {
                #if UNITY_ANDROID || UNITY_IPHONE
                Handheld.Vibrate();
                #endif
            }

            // we prevent further damage
            DamageDisabled();

            // instantiates the destroy effect
            if (DeathEffect != null)
            {
                GameObject instantiatedEffect = (GameObject)Instantiate(DeathEffect, transform.position, transform.rotation);
                instantiatedEffect.transform.localScale = transform.localScale;
            }



            // Adds points if needed.
            if (PointsWhenDestroyed != 0)
            {
                // we send a new points event for the GameManager to catch (and other classes that may listen to it too)
                MMEventManager.TriggerEvent(new CorgiEnginePointsEvent(PointsMethods.Add, PointsWhenDestroyed));
            }

            if (_animator != null)
            {
                _animator.SetTrigger("Death");
            }

            // if we have a controller, removes collisions, restores parameters for a potential respawn, and applies a death force
            if (_controller != null)
            {
                // we make it ignore the collisions from now on
                if (CollisionsOffOnDeath)
                {
                    _controller.CollisionsOff();
                    if (_collider2D != null)
                    {
                        _collider2D.enabled = false;
                    }
                }

                // we reset our parameters
                _controller.ResetParameters();

                // we apply our death force
                if (DeathForce != Vector2.zero)
                {
                    _controller.GravityActive(true);
                    _controller.SetForce(DeathForce);
                }
            }

            if (OnDeath != null)
            {
                OnDeath();
            }

            // if we have a character, we want to change its state
            if (_character != null)
            {
                // we set its dead state to true
                _character.ConditionState.ChangeState(CharacterStates.CharacterConditions.Dead);
                _character.Reset();

                // if this is a player, we quit here
                if (_character.CharacterType == Character.CharacterTypes.Player)
                {
                    return;
                }
            }

            //turn off Barrier Sprite
            if (_barrierSprite != null)
            {
                StartCoroutine(MMFade.FadeSprite(_barrierSprite.GetComponent <SpriteRenderer>(), FadeOutTime, new Color(1f, 1f, 1f, 0f)));
            }

            //Turn on whatever object we want on after this thing is destroyed
            TurnOnObject();

            if (DelayBeforeDestruction > 0f)
            {
                Invoke("DestroyObject", DelayBeforeDestruction);
            }
            else
            {
                // finally we destroy the object
                DestroyObject();
            }
        }
Esempio n. 9
0
 public virtual void Show()
 {
     StartCoroutine(MMFade.FadeSprite(Border, FadeInDuration, _alphaOne));
     StartCoroutine(MMFade.FadeSprite(Background, FadeInDuration, _alphaOne));
     StartCoroutine(MMFade.FadeCanvasGroup(TextCanvasGroup, FadeInDuration, 1f, true));
 }