コード例 #1
0
    // NPC is saying something
    public void speak(Boolean display)
    {
        string dialogue = Dialogue.getDialogue(personality, interactionType);

        // Write the text if the player is on the same screen
        //if (display)
        textbox.Write(dialogue, sprite);

        if (personality == "shy")
        {
            // 20% chance to become sad
            if (Random.Range(0, 5) == 0)
            {
                RemoveState("normal");
                RemoveState("happy");
                states.Add("sad");
                sprite.setState("sad");
            }
        }
    }
コード例 #2
0
ファイル: NPC.cs プロジェクト: kycarr/CSSeniorProject
    public void SetState(State state)
    {
        if (states.Contains(state))
        {
            return;
        }

        if (state == State.happy)
        {
            World.AddChaos(World.NPC_HAPPY);
            RemoveState(State.normal);
            RemoveState(State.sad);
            RemoveState(State.angry);
        }
        else if (state == State.angry || state == State.sad)
        {
            World.AddChaos(World.NPC_UPSET);
            RemoveState(State.normal);
            RemoveState(State.happy);
            World.numUnhappy++;
        }
        else if (state == State.normal)
        {
            RemoveState(State.happy);
            RemoveState(State.sad);
            RemoveState(State.angry);
        }
        else if (state == State.dead)
        {
            if (personality != Personality.psychotic)
            {
                World.AddChaos(World.NPC_DIES);
            }
            World.numKilled++;
        }
        else if (state == State.psychotic)
        {
            World.AddChaos(World.NPC_PSYCHOTIC);
            World.AddPsychopath(1);
        }

        states.Add(state);
        sprite.setState(Enum.GetName(typeof(State), state));
    }