Exemple #1
0
    //on game lose
    public void OnGameLose(LoseReason loseReason)
    {
        if (dialogsComponent.winDialog.activeSelf || dialogsComponent.loseDialog.activeSelf || shownDialogType != Game.DialogType.LOSE)
        {
            return;
        }

        General.audioManagerComp.FadeOutClip(SFX.instance.audioSources [0], 5, 0.01f);
        SFX.instance.audioSources [2].clip = SFX.instance.loseSFX;
        SFX.instance.audioSources [2].Play();

        try {
            pauseButtonCollider.enabled = false;
            blackScreenAnimatorComp.SetBool("isFadingOut", false);
            blackScreenAnimatorComp.SetBool("isFadingIn", true);
            dialogsComponent.loseDialog.SetActive(true);

            TextMesh dialogMessage          = dialogsComponent.loseDialog.transform.Find("text").GetComponent <TextMesh> ();
            Animator loseDialogAnimatorComp = dialogsComponent.loseDialog.GetComponent <Animator> ();
            loseDialogAnimatorComp.SetBool("isFadingOut", false);
            loseDialogAnimatorComp.SetBool("isFadingIn", true);

            if (loseReason == LoseReason.WRONG_CHOICE)
            {
                dialogMessage.text = "Your Choice is wrong !";                                                //put your reason here
            }
            else if (loseReason == LoseReason.TIMEOUT)
            {
                dialogMessage.text = "Timeout";                                                //time-out reason
            }
        } catch (Exception ex) {
            Debug.LogError(ex.Message);
        }
    }
 //LOAD REFERENCES
 static void loadReferences()
 {
     screen            = GameObject.Find("EndScreen");
     endscreen         = (EndScreenController)screen.GetComponent(typeof(EndScreenController));
     losejustification = GameObject.Find("Justification Text");
     reason            = (LoseReason)losejustification.GetComponent(typeof(LoseReason));
     timer             = GameObject.Find("TimeManager").GetComponent <TimeManager>();
 }
Exemple #3
0
        public void Lost(LoseReason loseReason)
        {
            if (LostGame)
            {
                return;
            }
            LostGame = true;
            switch (loseReason)
            {
            case LoseReason.ExceptionThrown:
                Log.e(string.Format("Player {0} lost because an exception was thrown", name));
                break;

            case LoseReason.AllBuildingsDestroyed:
                Log.e(string.Format("Player {0} lost because all his buildings were destroyed", name));
                break;

            case LoseReason.TimeoutStalemate:
                Log.e(string.Format("Stalemate. Player {0} lost because of a game timeout", name));
                break;

            default:
                throw new ArgumentOutOfRangeException("loseReason", loseReason, null);
            }
            if (this == GameManager.Instance.GuiPlayer)
            {
                GameTestRunner.Failed = true;
            }
            // This causes enemies to Win if they don't have any more enemies
            if (loseReason == LoseReason.TimeoutStalemate)
            {
                return;
            }
            foreach (var enemyFactionIndex in Faction.EnemyFactionIndexes())
            {
                foreach (var player in GameManager.Instance.Players)
                {
                    if (this != player && player.FactionIndex == enemyFactionIndex)
                    {
                        player.Win();
                    }
                }
            }
        }
Exemple #4
0
        public void SetSubText(LoseReason r)
        {
            switch (r)
            {
            case LoseReason.Burn:
            {
                SubText.text = _burnLoseTexts[Random.Range(0, _burnLoseTexts.Count)];
                break;
            }

            case LoseReason.Spices:
            {
                SubText.text = _spicesLoseTexts[Random.Range(0, _spicesLoseTexts.Count)];
                break;
            }

            case LoseReason.Cook:
            {
                SubText.text = _cookLoseTexts[Random.Range(0, _cookLoseTexts.Count)];
                break;
            }
            }
        }
Exemple #5
0
 public void ShowLosePanel(LoseReason reason)
 {
     loseReason = reason;
     UpdateLoseReasonMessage();
     losePanel.gameObject.SetActive(true);
 }