JohnSmithSpeech.cs 2.29 KB
Newer Older
1
2
3
4
5
6
7
8
9
10
11
12
using System.Collections;
using System.Collections.Generic;
using UnityEngine;


public class JohnSmithSpeech : MonoBehaviour, Character {

    private Queue<string> conversation = new Queue<string>();
    private Queue<string[]> responseQueue = new Queue<string[]>();

    private string[] currentResponses;

13
14
15
16
    public float getLevel() {
        return GameManager.JohnLevel;
    }

17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
    public string GreetingMessage() {
        loadConversation();
        currentResponses = new string[] { "Hi there", "Who are you" };
        return "Hello, im John Smith";
    }
    public string GoodbyeMessage() {
        currentResponses = new string[] { };
        return "See you soon!";
    }

    public string ProximityMessage() {
        currentResponses = new string[] { };
        return "Clowns are so underrated these days";
    }
    public string butthurtGoodbye() {
        currentResponses = new string[] { };
        return "No attention for poor John Smith?";
    }

    public string nothingMoreToSay() {
        currentResponses = new string[] { };
        if (Random.Range(0, 1f) < 0.8) {
            return "youre still here?";
        } else {
            return "latta";
        }
    }

    public string converse() {
        if (conversation.Count > 0) {
            currentResponses = responseQueue.Dequeue();
            return conversation.Dequeue();
        } else {
            return nothingMoreToSay();
        }
    }

    private void loadConversation() {
        conversation.Clear();
        responseQueue.Clear();

        conversation.Enqueue("welcome to the circus");
        responseQueue.Enqueue(new string[] { "response 1" });

        conversation.Enqueue("line 2");
        responseQueue.Enqueue(new string[] { "response 2", "response 2" });

        conversation.Enqueue("line 3");
        responseQueue.Enqueue(new string[] { "response 3", "response 3", "response 3" });

        conversation.Enqueue("line 4");
        responseQueue.Enqueue(new string[] { "response 4", "response 4" });

        conversation.Enqueue("line 5");
        responseQueue.Enqueue(new string[] { "response 5", "response 5", "response 5" });

        conversation.Enqueue("line 6");
        responseQueue.Enqueue(new string[] { "response 6" });
    }

    public string[] getResponses() {
        return currentResponses;
    }
}