Ejemplo n.º 1
0
    private void InitSpeech()
    {
        speechIcon1 = SpeechHelper.UnknownSprite;
        speechIcon2 = SpeechHelper.UnknownSprite;

        bool isCulprit    = ID == NPCTracker.Culprit;
        bool sameTraincar = NPCTracker.FindCulprit().GetTraincar() == GetTraincar();

        #region Special Case: Cat & Twins
        if (ID == NPCTracker.ID.Cat)
        {
            if (NPCTracker.IsTwin(NPCTracker.Culprit))
            {
                Accused            = NPCTracker.FindCulprit();
                speechIcon1        = SpeechHelper.GetIcon_Person(NPCTracker.ID.Cat);
                speech2IsDirection = true;
                speechEmotion      = SpeechEmotion.Scared;
                return;
            }
            else
            {
                Accused       = this;
                speechIcon1   = SpeechHelper.GetIcon_Person(NPCTracker.ID.Cat);
                speechIcon2   = SpeechHelper.MiscIcons.Meow;
                speechEmotion = SpeechEmotion.Loopy;
                return;
            }
        }

        if (NPCTracker.IsTwin(ID) && NPCTracker.IsTwin(NPCTracker.Culprit))
        {
            Accused = NPCTracker.FindNPC(
                ID == NPCTracker.ID.TwinRed
                                ? NPCTracker.ID.TwinBlue
                                : NPCTracker.ID.TwinRed
                );
            speechIcon1        = SpeechHelper.GetIcon_Person(Accused.ID);
            speech2IsDirection = true;
            speechEmotion      = SpeechEmotion.Emphatic;
            return;
        }
        #endregion

        //base certainty
        float certainty = sameTraincar ? 1.0f : 0.9f;

        //accuse somebody
        float rng_wrongAccusation =
            isCulprit ? 1.0f :
            sameTraincar ? 0.0f :
            Random.Range(0.0f, 1.0f)
        ;

        if (rng_wrongAccusation < 0.4f)
        {
            Accused = NPCTracker.FindCulprit();
        }
        else if (rng_wrongAccusation < 0.7f)
        {
            Accused    = NPCTracker.FindNPC(NPCTracker.GetRandomNPCID());
            certainty -= 0.5f;
        }
        else
        {
            Accused    = NPCTracker.FindNPC(NPCTracker.RedHerring);
            certainty -= 0.3f;
        }

        //should never happen; just for safety
        if (Accused == null)
        {
            Accused = NPCTracker.FindNPC(NPCTracker.RedHerring);
        }
        while (Accused == this)
        {
            Accused = NPCTracker.FindNPC(NPCTracker.GetRandomNPCID());
        }

        //first icon represents accusation
        float rng_vagueness =
            sameTraincar ? Random.Range(0.0f, 0.6f) :
            Random.Range(0.0f, 1.0f)
        ;
        if (rng_vagueness < 0.3f)
        {
            speechIcon1 = SpeechHelper.GetIcon_Person(Accused.ID);
            certainty  -= 0.2f;
        }
        else if (rng_vagueness < 0.7f)
        {
            var traits = SpeechHelper.GetTraitList(Accused.ID).Icons;
            speechIcon1 = traits[Random.Range(0, traits.Length)];
        }
        else
        {
            speechIcon1 = SpeechHelper.GetIcon_Car(Accused.GetTraincar());
        }

        //second icon and animation represent certainty
        float rng_certainty = Random.Range(0.0f, certainty);

        if (rng_certainty < 0.2f)
        {
            speechIcon2   = SpeechHelper.GetIcon_Certainty(false);
            speechEmotion = SpeechEmotion.Loopy;
        }
        else if (rng_certainty < 0.5f)
        {
            speech2IsDirection = true;
            speechEmotion      = SpeechEmotion.Loopy;
        }
        else if (rng_certainty < 0.7f)
        {
            speech2IsDirection = true;
            speechEmotion      = SpeechEmotion.Scared;
        }
        else
        {
            speechIcon2   = SpeechHelper.GetIcon_Certainty(true);
            speechEmotion = SpeechEmotion.Emphatic;
        }
    }