Exemple #1
0
    private void StartStage(GameStage stage)
    {
        Debug.Log("starting stage " + stage);
        mCurrentStage = stage;

        if (stage == GameStage.SEARCH_1)
        {
            // NEVER COMMIT THESE LINES
            // mArrestedPerson = Player;
            // stage = GameStage.CLOSURE;
        }
        if (stage == GameStage.SEARCH_1 || stage == GameStage.SEARCH_2 || stage == GameStage.SEARCH_3)
        {
            if (stage == GameStage.SEARCH_1)
            {
                PlayerJournal.AddListen(VictimId, mStartingClue.GetSentence()); // wait until after the dialogue is over to add this to the player journal
            }

            UIController.Get().ShowJournalButton();
            UIController.Get().ShowMusicButton();

            // assign npcs to rooms (for now, ensure they go to different rooms)
            int[] roomChoices = Utilities.RandomList(clueRooms.Length, 2);
            for (int i = 0, j = 0; i < 3; ++i)
            {
                mRoundClues[i] = null;

                if (i != PlayerId)
                {
                    string npcRoom = clueRooms[roomChoices[j++]];
                    MoveToRoom(i, npcRoom);

                    // npcs pick up a clue in the room they move to
                    if (mCluesInRooms.ContainsKey(npcRoom))
                    {
                        List <ClueItem> cluesInRoom = mCluesInRooms[npcRoom];
                        if (cluesInRoom.Count > 0)
                        {
                            int      clueIdx = Random.Range(0, cluesInRoom.Count);
                            ClueItem clue    = cluesInRoom[clueIdx];
                            cluesInRoom.RemoveAt(clueIdx);

                            ClueInfo info = clue.info;
                            mPeople[i].knowledge.AddKnowledge(info.GetSentence());
                            mRoundClues[i] = info;
                        }
                    }
                }
            }

            MoveToRoom(PlayerId, mCurrentRoom); // hack to reload room with npcs gone
        }
        else if (stage == GameStage.COMMUNAL_1 || stage == GameStage.COMMUNAL_2 || stage == GameStage.COMMUNAL_3)
        {
            for (int i = 0; i < 3; ++i)
            {
                MoveToRoom(i, openingScene);
            }
        }
        else if (stage == GameStage.POLICE)
        {
            MoveToRoom(PlayerId, "EndScene");
        }
        else if (stage == GameStage.REVEAL)
        {
            DialogBlock discussion = new DialogBlock(mPeople, OnDialogueDismissed);

            // check each accusation
            int[] votes          = { 0, 0, 0 };
            int   highestVoteIdx = -1;
            int   majority       = -1;
            int   mostVotes      = 0;
            int   totalVotes     = 0;
            for (int i = 0; i < 3; ++i)
            {
                if (mAccusations[i] >= 0 && mAccusations[i] < 3)
                {
                    votes[mAccusations[i]]++;
                    totalVotes++;
                    if (votes[mAccusations[i]] > mostVotes)
                    {
                        mostVotes      = votes[mAccusations[i]];
                        highestVoteIdx = mAccusations[i];
                    }

                    if (votes[mAccusations[i]] >= 2)
                    {
                        majority = mAccusations[i];
                    }
                }
            }

            if (majority >= 0)
            {
                discussion.QueueDialogue(Police, new Sprite[] { }, "So it was the " + mPeople[majority].AttributeMap[NounType.HairColor] + "?");
                discussion.QueueDialogue(Police, new Sprite[] { mPeople[majority].HeadSprite }, "You're under arrest, ma'am.");
                discussion.QueueDialogue(Police, new Sprite[] { mPeople[(majority + 1) % 3].HeadSprite, mPeople[(majority + 2) % 3].HeadSprite }, "You two, come along and we'll get official statements.");
                mWasAllArrested = false;
                mArrestedPerson = mPeople[majority];
            }
            else
            {
                // no one got a majority
                Sprite[] allThree = new Sprite[] { mPeople[0].HeadSprite, mPeople[1].HeadSprite, mPeople[2].HeadSprite };
                discussion.QueueDialogue(Police, allThree, "You can't agree on what happened?");
                discussion.QueueDialogue(Police, allThree, "I'm going to have to take you all in to the station.");
                mWasAllArrested = true;
            }

            discussion.Start();
        }
        else if (stage == GameStage.CLOSURE)
        {
            blackFade.SetTrigger("FadeOut");
            // Give me closure please!
            // TODO - tell more of the story.
            // TODO - typing sound
            if (mWasAllArrested)
            {
                mEpilogueLines.Add("Because you could not come to a decision as a group, all three of you were arrested.");
                if (Player.IsKiller)
                {
                    mEpilogueLines.Add("You were the killer.");
                }
                else
                {
                    mEpilogueLines.Add(mPeople[KillerId].AttributeMap[NounType.HairColor].AsSubject() + " was the killer.");
                }
            }
            else
            {
                if (mArrestedPerson.IsKiller && mArrestedPerson.IsPlayer)
                {
                    mEpilogueLines.Add("You were the killer, and you were caught.");
                }
                else if (!mArrestedPerson.IsKiller && mArrestedPerson.IsPlayer)
                {
                    mEpilogueLines.Add(mPeople[KillerId].AttributeMap[NounType.HairColor].AsSubject() + " was the killer, but you were the one arrested.");
                }
                else if (mArrestedPerson.IsKiller && !mArrestedPerson.IsPlayer)
                {
                    mEpilogueLines.Add(mPeople[KillerId].AttributeMap[NounType.HairColor].AsSubject() + " was the killer, and was correctly arrested.");
                }
                else if (!mArrestedPerson.IsKiller && !mArrestedPerson.IsPlayer)
                {
                    mEpilogueLines.Add(mPeople[KillerId].AttributeMap[NounType.HairColor].AsSubject() + " was the killer, but " + mArrestedPerson.AttributeMap[NounType.HairColor].AsSubject() + " was arrested instead.");
                }
                else if (!mArrestedPerson.IsKiller && Player.IsKiller)
                {
                    mEpilogueLines.Add("You were the killer, and you escaped because " + mArrestedPerson.AttributeMap[NounType.HairColor].AsSubject() + " was arrested instead.");
                }
                else
                {
                    // I dont think this is possible. But just in case...
                    if (Player.IsKiller)
                    {
                        mEpilogueLines.Add("You were the killer");
                    }
                    else
                    {
                        mEpilogueLines.Add(mPeople[KillerId].AttributeMap[NounType.HairColor].AsSubject() + " was the killer");
                    }
                    if (mArrestedPerson.IsPlayer)
                    {
                        mEpilogueLines.Add("You were arrested");
                    }
                    else
                    {
                        mEpilogueLines.Add(mArrestedPerson.AttributeMap[NounType.HairColor].AsSubject() + " was arrested");
                    }
                }
            }
            mEpilogueLines.Add("The killer " + mPeople[KillerId].AttributeMap[NounType.Identity].AsObject());
            mEpilogueLines.Add("The killer " + mPeople[KillerId].AttributeMap[NounType.Motive].AsObject());
            for (int j = 0; j < 3; j++)
            {
                mEpilogueLines.Add(mPeople[j].AttributeMap[NounType.HairColor].AsSubject() + " " + mPeople[j].AttributeMap[NounType.Name].AsObject());
                mEpilogueLines.Add(mPeople[j].AttributeMap[NounType.HairColor].AsSubject() + " " + mPeople[j].AttributeMap[NounType.Identity].AsObject());
            }

            InvokeRepeating("UpdateEpilogueText", 1.5f, 0.5f); // after 1 seconds start the epilogue text, and do a new line every 0.3 seconds
        }
    }
Exemple #2
0
    public void Continue()
    {
        if (mDialogEntries.Count == 0)
        {
            if (mDismissedCallback != null)
            {
                mDismissedCallback(0);
                mDismissedCallback = null;
            }
            return;
        }

        DialogEntry entry = mDialogEntries[0];

        mDialogEntries.RemoveAt(0);
        AudioPlayer.PlaySound(entry.audio);
        if (entry.isInfoExchangeRequest)
        {
            UIController.Get().ShowMessage(
                entry.speaker, entry.sprites, entry.message,
                new string[] { "Yes", "No" },
                new UIButtonCallback[] {
                buttonIndex => { InsertInformationExchange(0);  Continue(); },
                buttonIndex => { InsertDialogue(0, entry.speaker, entry.sprites, "Alright. Let's talk more later."); Continue(); },
            });
        }
        else if (entry.isInfoExchange)
        {
            if (entry.speaker.IsPlayer)
            {
                // Show prompt, and share the result with other participants of this dialog
                UIController.Get().AskForSentence(entry.sprites, sentence => { ShareInfo(GameState.Get().Player, sentence); Continue(); });
            }
            else
            {
                // The GameState round-clues is guaranteed to be a recent clue that is not the result of combining multiple clues
                ClueInfo clueInfo = GameState.Get().mRoundClues[entry.speaker.PersonId];
                string   message;
                if (clueInfo != null)
                {
                    Sentence newInfo = clueInfo.GetSentence();
                    message = "I found out " + entry.speaker.Speak(newInfo); // TODO: Announce the room where it was found
                    if (newInfo.Subject.Type() == NounType.Unique)
                    {
                        message = "I found " + entry.speaker.Speak(newInfo); // TODO: Announce the room where it was found
                    }
                    ShareInfo(entry.speaker, newInfo);
                    PlayerJournal.AddListen(entry.speaker.PersonId, newInfo);
                }
                else
                {
                    message = "I found nothing.";
                }
                UIController.Get().ShowMessage(entry.speaker, entry.sprites, message, new string[] { "Continue" }, new UIButtonCallback[] { buttonIndex => Continue() });
            }
        }
        else if (entry.isCustomSentence)
        {
            UIController.Get().AskForSentence(new Sprite[] { }, sentence => { if (entry.customSentenceCallback != null)
                                                                              {
                                                                                  entry.customSentenceCallback(sentence);
                                                                              }
                                                                              Continue(); }, entry.subjectOverrides, entry.objectOverrides);
        }
        else   // a regular message, just show it
        {
            UIController.Get().ShowMessage(entry.speaker, entry.sprites, entry.message, new string[] { "Continue" }, new UIButtonCallback[] { buttonIndex => Continue() });
        }
    }