Exemple #1
0
    public void Talk(DialoguePart part)
    {
        if (part.wordSpeed > 0)
        {
            wordPause = part.wordSpeed;
        }
        else
        {
            wordPause = defaultWordPause;
        }

        if (part.endOfSentenceSpeed > 0)
        {
            sentencePause = part.endOfSentenceSpeed;
        }
        else
        {
            sentencePause = defaultSentencePause;
        }

        if (part.endOfSentenceDelays > 0)
        {
            sentencePauses = part.endOfSentenceDelays;
        }
        else
        {
            sentencePauses = defaultSentencePauses;
        }

        Talk(part.text);
    }
Exemple #2
0
    void SetupResponse()
    {
        DialoguePart part = SetupCustomer(false);

        customerResponseSnapshot.TransitionTo(fadeTime);
        int positives;
        int negatives;
        int score = Score(part, out positives, out negatives);

        if (negatives > positives)
        {
            Debug.Log("Customer Negative");
            textTalk.Talk(part.negativeFeedback);
        }
        else if (positives > negatives + 1)
        {
            Debug.Log("Customer Positive");
            textTalk.Talk(part.positiveFeedback);
        }
        else
        {
            Debug.Log("Customer Neutral");
            textTalk.Talk(part.neutralFeedback);
        }
        World.AddScore(score, negatives > 0);
    }
Exemple #3
0
    DialoguePart SetupCustomer(bool doTalk = true)
    {
        DialoguePart part = dialogues[World.Level][currentIndex];

        if (doTalk)
        {
            textTalk.Talk(part);
        }
        nameArea.text         = part.orderTitle;
        workshopNameArea.text = "Back to " + part.name;

        int listIndex = GetListIndex(part.identifier);

        if (listIndex < 0)
        {
            Debug.LogError(string.Format("Could not find identifier '{0}' ({1}) in lists.", part.identifier, part.name));
        }
        SingleCam.CustomerOrderSpeaker.clip    = musics[listIndex];
        SingleCam.CustomerResponseSpeaker.clip = musics[listIndex];
        SingleCam.CustomerOrderSpeaker.Play();
        SingleCam.CustomerResponseSpeaker.Play();

        customerOrderSnapshot.TransitionTo(fadeTime);

        faceImage.sprite = faces[listIndex];
        avatar.sprite    = sprites[listIndex];

        return(part);
    }
Exemple #4
0
    void LoadJSON()
    {
        if (dialogues.Count > 0)
        {
            return;
        }

        if (Workshop.ingredients.Count == 0)
        {
            Workshop.LoadJSON();
        }

        for (int part_index = 0, files = json_files.Count; part_index < files; part_index++)
        {
            TextAsset asset = Resources.Load(json_files[part_index]) as TextAsset;
            if (asset == null)
            {
                Debug.LogError("Missing file: " + json_files[part_index]);
                continue;
            }
            else
            {
                Debug.Log("Loading file: " + json_files[part_index]);
            }
            string       json = asset.text;
            DialoguePart part = JsonUtility.FromJson <DialoguePart>(json);

            if (GetListIndex(part.identifier) < 0)
            {
                Debug.LogError(string.Format("Unknown customer identifier: {0} in file {1}", part.identifier, json_files[part_index]));
            }

            if (!dialogues.ContainsKey(part.level))
            {
                dialogues[part.level]     = new List <DialoguePart>();
                usedDialogues[part.level] = new List <bool>();
            }

            dialogues[part.level].Add(part);
            usedDialogues[part.level].Add(false);

            Debug.Log(string.Format("Loaded {0} ({1}) at {2}", part.orderTitle, part.name, part.level));

            string[] invalid = GetInvalidCriteria(part.negativeCriteria);
            if (invalid.Length > 0)
            {
                Debug.LogError("These negative don't exist: " + string.Join(", ", invalid));
            }

            invalid = GetInvalidCriteria(part.positiveCriteria);
            if (invalid.Length > 0)
            {
                Debug.LogError("These positive don't exist: " + string.Join(", ", invalid));
            }
        }
    }
Exemple #5
0
    public int Score(DialoguePart part, out int positives, out int negatives)
    {
        int           score = baseScore;
        List <string> lst   = World.RocketBlueprint.Values.Select(kvp => kvp.Value).ToList();
        int           shots = lst.Count;

        positives = part.positiveCriteria.Where(e => lst.Contains(e)).Count();
        negatives = part.negativeCriteria.Where(e => lst.Contains(e)).Count();

        score += positives * bonusPart;
        score -= negatives * failScorePart;

        if (negatives == part.negativeCriteria.Length || negatives == shots)
        {
            score -= criticalFail;
        }
        else if (positives == part.positiveCriteria.Length || positives == shots)
        {
            score += completeBonus;
        }
        return(score);
    }