コード例 #1
0
        public virtual void OnMMEvent(TopDownEngineEvent tdEvent)
        {
            switch (tdEvent.EventType)
            {
            case TopDownEngineEventTypes.PlayerDeath:
                if (tdEvent.OriginCharacter.PlayerID == PlayerID)
                {
                    DeadMask.gameObject.SetActive(true);
                    DeadMask.alpha = 0f;
                    StartCoroutine(MMFade.FadeCanvasGroup(DeadMask, 0.5f, 0.8f, true));
                }
                break;

            case TopDownEngineEventTypes.Repaint:
                foreach (GrasslandsMultiplayerLevelManager.GrasslandPoints points in (LevelManager.Instance as GrasslandsMultiplayerLevelManager).Points)
                {
                    if (points.PlayerID == PlayerID)
                    {
                        CoinCounter.text = points.Points.ToString();
                    }
                }
                break;

            case TopDownEngineEventTypes.GameOver:
                if (PlayerID == (LevelManager.Instance as GrasslandsMultiplayerLevelManager).WinnerID)
                {
                    WinnerScreen.gameObject.SetActive(true);
                    WinnerScreen.alpha = 0f;
                    StartCoroutine(MMFade.FadeCanvasGroup(WinnerScreen, 0.5f, 0.8f, true));
                }
                break;
            }
        }
コード例 #2
0
        /// <summary>
        /// Starts the display coroutine or the panel's fade depending on whether or not the current slot is empty
        /// </summary>
        /// <param name="item">Item.</param>
        public virtual void DisplayDetails(InventoryItem item)
        {
            if (InventoryItem.IsNull(item))
            {
                if (HideOnEmptySlot && !Hidden)
                {
                    StartCoroutine(MMFade.FadeCanvasGroup(_canvasGroup, _fadeDelay, 0f));
                    Hidden = true;
                }
                if (!HideOnEmptySlot)
                {
                    StartCoroutine(FillDetailFieldsWithDefaults(0));
                }
            }
            else
            {
                StartCoroutine(FillDetailFields(item, 0f));

                if (HideOnEmptySlot && Hidden)
                {
                    StartCoroutine(MMFade.FadeCanvasGroup(_canvasGroup, _fadeDelay, 1f));
                    Hidden = false;
                }
            }
        }
コード例 #3
0
 /// <summary>
 /// Triggered when the actual loading is done, replaces the progress bar with the complete animation
 /// </summary>
 protected virtual void LoadingComplete()
 {
     LoadingCompleteAnimation.gameObject.SetActive(true);
     StartCoroutine(MMFade.FadeCanvasGroup(LoadingProgressBar, 0.1f, 0f));
     StartCoroutine(MMFade.FadeCanvasGroup(LoadingAnimation, 0.1f, 0f));
     StartCoroutine(MMFade.FadeCanvasGroup(LoadingCompleteAnimation, 0.1f, 1f));
 }
コード例 #4
0
        protected virtual IEnumerator HideCo()
        {
            ContainerCanvasGroup.alpha = 1f;
            StartCoroutine(MMFade.FadeCanvasGroup(ContainerCanvasGroup, FadeOutDuration, 0f, true));
            yield return(new WaitForSeconds(FadeOutDuration));

            this.gameObject.SetActive(false);
        }
コード例 #5
0
        protected virtual void Disappear()
        {
            Color newColor = new Color(0, 0, 0, 0);

            StartCoroutine(MMFade.FadeImage(InstructionsPanel, FadeDuration, newColor));
            StartCoroutine(MMFade.FadeText(InstructionsText, FadeDuration, newColor));
            Invoke("DestroyInstructions", FadeDuration);
        }
コード例 #6
0
ファイル: GUIManager.cs プロジェクト: dqtoy/KoalaRescue
 /// <summary>
 /// Fades the fader to the alpha set as parameter
 /// </summary>
 /// <param name="newColor">The color to fade to.</param>
 /// <param name="duration">Duration.</param>
 public virtual void FaderTo(Color newColor, float duration)
 {
     if (Fader == null)
     {
         return;
     }
     Fader.gameObject.SetActive(true);
     StartCoroutine(MMFade.FadeImage(Fader, duration, newColor));
 }
コード例 #7
0
 /// <summary>
 /// Fades the fader to the alpha set as parameter
 /// </summary>
 /// <param name="newColor">The color to fade to.</param>
 /// <param name="duration">Duration.</param>
 public virtual void FaderTo(float newOpacity, float duration)
 {
     if (Fader == null)
     {
         return;
     }
     Fader.gameObject.SetActive(true);
     StartCoroutine(MMFade.FadeCanvasGroup(Fader, duration, newOpacity));
 }
コード例 #8
0
        /// <summary>
        /// A coroutine used to hide the instructions after a while
        /// </summary>
        /// <returns></returns>
        protected virtual IEnumerator DisappearCo()
        {
            yield return(MMCoroutine.WaitFor(DisappearDelay));

            StartCoroutine(MMFade.FadeCanvasGroup(_canvasGroup, DisappearDuration, 0f, true));
            yield return(MMCoroutine.WaitFor(DisappearDuration + 0.1f));

            this.gameObject.SetActive(false);
        }
コード例 #9
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);
        }
コード例 #10
0
ファイル: DialogueBox.cs プロジェクト: leonidas192/Iseng
        /// <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.FadeCanvasGroup(TextPanelCanvasGroup, duration, 0f));
            StartCoroutine(MMFade.FadeText(DialogueText, duration, newTextColor));
            StartCoroutine(MMFade.FadeCanvasGroup(Prompt, duration, 0f));
        }
コード例 #11
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)));
        }
コード例 #12
0
 public virtual void Show()
 {
     this.gameObject.SetActive(true);
     if (_hideCoroutine != null)
     {
         StopCoroutine(_hideCoroutine);
     }
     ContainerCanvasGroup.alpha = 0f;
     StartCoroutine(MMFade.FadeCanvasGroup(ContainerCanvasGroup, FadeInDuration, 1f, true));
 }
コード例 #13
0
        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;
        }
コード例 #14
0
 /// <summary>
 /// On game over we display our winner screen if needed
 /// </summary>
 /// <param name="tdEvent"></param>
 public virtual void OnMMEvent(TopDownEngineEvent tdEvent)
 {
     switch (tdEvent.EventType)
     {
     case TopDownEngineEventTypes.GameOver:
         if (PlayerID == (LevelManager.Instance as ExplodudesMultiplayerLevelManager).WinnerID)
         {
             WinnerScreen.gameObject.SetActive(true);
             WinnerScreen.alpha = 0f;
             StartCoroutine(MMFade.FadeCanvasGroup(WinnerScreen, 0.5f, 0.8f, true));
         }
         break;
     }
 }
コード例 #15
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)));
        }
コード例 #16
0
ファイル: DialogueBox.cs プロジェクト: leonidas192/Iseng
 /// <summary>
 /// Fades the dialogue box in.
 /// </summary>
 /// <param name="duration">Duration.</param>
 public virtual void FadeIn(float duration)
 {
     if (TextPanelCanvasGroup != null)
     {
         StartCoroutine(MMFade.FadeCanvasGroup(TextPanelCanvasGroup, duration, 1f));
     }
     if (DialogueText != null)
     {
         StartCoroutine(MMFade.FadeText(DialogueText, duration, _textColor));
     }
     if (Prompt != null)
     {
         StartCoroutine(MMFade.FadeCanvasGroup(Prompt, duration, 1f));
     }
 }
コード例 #17
0
ファイル: GUIManager.cs プロジェクト: dqtoy/KoalaRescue
 /// <summary>
 /// Fades the fader in or out depending on the state
 /// </summary>
 /// <param name="state">If set to <c>true</c> fades the fader in, otherwise out if <c>false</c>.</param>
 public virtual void FaderOn(bool state, float duration)
 {
     if (Fader == null)
     {
         return;
     }
     Fader.gameObject.SetActive(true);
     if (state)
     {
         StartCoroutine(MMFade.FadeImage(Fader, duration, new Color(0, 0, 0, 1f)));
     }
     else
     {
         StartCoroutine(MMFade.FadeImage(Fader, duration, new Color(0, 0, 0, 0f)));
     }
 }
コード例 #18
0
        /// <summary>
        /// Closes the inventory panel
        /// </summary>
        public virtual void CloseInventory()
        {
            // we unpause the game
            _pause = false;
            if (_canvasGroup != null)
            {
                _canvasGroup.blocksRaycasts = false;
            }
            // we close our inventory
            MMEventManager.TriggerEvent(new MMInventoryEvent(MMInventoryEventType.InventoryCloses, null, TargetInventoryDisplay.TargetInventoryName, null, 0, 0));
            MMEventManager.TriggerEvent(new MMGameEvent("inventoryCloses"));
            InventoryOpen = false;

            StartCoroutine(MMFade.FadeCanvasGroup(TargetInventoryContainer, 0.2f, 0f));
            StartCoroutine(MMFade.FadeCanvasGroup(Overlay, 0.2f, 0f));
        }
コード例 #19
0
        /// <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);
            }
        }
コード例 #20
0
        /// <summary>
        /// Opens the inventory panel
        /// </summary>
        public virtual void OpenInventory()
        {
            // we set the game to pause
            _pause = true;
            if (_canvasGroup != null)
            {
                _canvasGroup.blocksRaycasts = true;
            }

            // we open our inventory
            MMEventManager.TriggerEvent(new MMInventoryEvent(MMInventoryEventType.InventoryOpens, null, TargetInventoryDisplay.TargetInventoryName, TargetInventoryDisplay.TargetInventory.Content[0], 0, 0));
            MMEventManager.TriggerEvent(new MMGameEvent("inventoryOpens"));
            InventoryOpen = true;

            StartCoroutine(MMFade.FadeCanvasGroup(TargetInventoryContainer, 0.2f, 1f));
            StartCoroutine(MMFade.FadeCanvasGroup(Overlay, 0.2f, 0.85f));
        }
コード例 #21
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)));
     }
 }
コード例 #22
0
 public virtual void FaderOn(bool state, float duration, bool unscaled = true)
 {
     if (Fader == null)
     {
         return;
     }
     Fader.gameObject.SetActive(true);
     if (state)
     {
         Fader.alpha = 0f;
         StartCoroutine(MMFade.FadeCanvasGroup(Fader, duration, 1f, unscaled));
     }
     else
     {
         Fader.alpha = 1f;
         StartCoroutine(MMFade.FadeCanvasGroup(Fader, duration, 0f, unscaled));
         StartCoroutine(TurnFaderOff(duration));
     }
 }
コード例 #23
0
        /// <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)));
            }
        }
コード例 #24
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();
            }
        }
コード例 #25
0
 public virtual void Show()
 {
     StartCoroutine(MMFade.FadeSprite(Border, FadeInDuration, _alphaOne));
     StartCoroutine(MMFade.FadeSprite(Background, FadeInDuration, _alphaOne));
     StartCoroutine(MMFade.FadeCanvasGroup(TextCanvasGroup, FadeInDuration, 1f, true));
 }