コード例 #1
0
    public string getNoTask()   //Function, runs if you have a task already
    {
        if (mainCharacterVars.taskItem == interact.taskItemReq && mainCharacterVars.taskItem != "")
        { //If mainCharacter's task is complete
            taskwiththisNPC = false;
            taskinprog.SetActive(false);

            almostdonestar.SetActive(false);
            mainCharacterVars.almostdone = false;

            interactWithBank.taskmode    = false;
            interactWithMailman.taskmode = false;
            interactWithMarket.taskmode  = false;
            interactWithPizza.taskmode   = false;
            interactWithMayor.taskmode   = false;
            interactWithShady.taskmode   = false;
            completed = true;
            if (timer.targetTime > 0.0f || dayNight.dayCount == 1)
            { //If you did the task fast enough, you learn new words
                taskDialogue = dictRef.scramble(new List <string> {
                    "thank", " ", "you"
                });                                        //or what the npc will say after the task is complete/notcomplete
                dictRef.learnWord(taskPrompt.taskID, taskPrompt.itemRequired, taskPrompt.prompt, 100);
                if (mainCharacterVars.currentTaskIsHard)   //You get money if it was a hard task
                {
                    mainCharacterVars.money += Random.Range(friendship.FriendLevel, friendship.FriendLevel + 6);
                    dictRef.learnWord(taskPrompt.taskID, taskPrompt.itemRequired, taskPrompt.prompt, 100);
                }
            }
            else
            {
                taskDialogue = dictRef.scramble(new List <string> {
                    "you", " ", "took", " ", "too", " ", "long", "."
                });                                                                                                     //or what the npc will say after the task is complete/notcomplete
            }
            dayCount++;

            mainCharacterVars.taskXP++;                  //taskXP is how many tasks you have done
            mainCharacterVars.currentTask       = false; //Clear task-related variables
            mainCharacterVars.currentTaskIsHard = false;
            mainCharacterVars.taskItem          = "";
            interact.taskItemReq = "";
            taskPrompt           = default(task);
        }
        else if (interact.taskItemReq != "" && mainCharacterVars.taskItem == "" && !interact.seenTaskPrompt)   //If mainCharacter needs to see the task prompt again
        {
            taskDialogue            = interact.currentTaskPrompt;
            interact.dialogue.color = Color.red;
            interact.seenTaskPrompt = true;
        }
        else if (dayCount >= dayNight.dayCount && interact.seenNoTasks == false)
        { //If mainCharacter has reached the task limit
            taskDialogue = dictRef.scramble(noTaskDialogue);
            dictRef.learnWord("I", " ", noTaskDialogue, 10);
            interact.seenNoTasks = true;
        }
        else if (interact.taskItemReq == "" || mainCharacterVars.taskItem == "")   //If mainCharacter's task is not complete, or it is with another NPC, or mainCharacter has alread heard that the NPC is out of tasks
        {
            taskDialogue = npcConversation.makeConversation(true);
        }
        else if (mainCharacterVars.taskItem != "" && mainCharacterVars.taskItem != interact.taskItemReq)
        { //If mainCharacter's task is complete but they got the wrong thing
            taskDialogue = dictRef.scramble(new List <string> {
                "that", " ", "is", " ", "not", " ", "what", " ", "I", " ", "want", "."
            });
            taskwiththisNPC = false;

            almostdonestar.SetActive(false);
            mainCharacterVars.almostdone = false;

            taskinprog.SetActive(false);

            timer.wrongitem = true;
            completed       = true;



            dayCount++;

            mainCharacterVars.taskItem    = "";
            interact.taskItemReq          = "";
            mainCharacterVars.currentTask = false;
            taskPrompt = default(task);
        }
        else //This branch should never occur
        {
            taskDialogue = "you should not see this";
        }

        return(taskDialogue);
    }
コード例 #2
0
    void Update()
    {
        if (mainCharacterVars.currentTask)
        {
            tasklocationemote.SetActive(true);
        }
        else
        {
            tasklocationemote.SetActive(false);
        }

        if (interactable)
        {
            if (Input.GetKeyDown(KeyCode.Space) || selected != "")
            {
                if (taskmode)
                {
                    if (ismarket || ispizza)
                    {
                        //if (mainCharacterVars.taskItem == "")
                        //{
                        if (ismarket)
                        {
                            dialogue.text = "Click on what you would like to buy from the market.";
                            breadbutton.SetActive(true);
                            grapesbutton.SetActive(true);
                        }
                        else if (ispizza)
                        {
                            dialogue.text = "Click on what you want on your pizza!";
                            olivebutton.SetActive(true);
                            tomatobutton.SetActive(true);
                        }
                        meatbutton.SetActive(true);
                        //}
                        if (selected != "")
                        {
                            if (Browse(whatYouNeed))
                            {
                                mainCharacterVars.taskItem = whatYouNeed;
                                for (int i = 0; i < afterInteract.Count; i++)
                                {
                                    placeholder.Add(afterInteract[i]);
                                }
                                placeholder.Add(whatYouNeed);
                                dialogue.text = dictInitialize.scramble(placeholder);
                                placeholder.Clear();
                                selected = "";

                                mainCharacterVars.almostdone = true;
                            }
                            else if (!Browse(whatYouNeed) && selected != "")
                            {
                                mainCharacterVars.taskItem = selected;
                                for (int i = 0; i < afterInteract.Count; i++)
                                {
                                    placeholder.Add(afterInteract[i]);
                                }
                                placeholder.Add(whatYouNeed);
                                dialogue.text = dictInitialize.scramble(placeholder);
                                placeholder.Clear();
                                selected = "";

                                mainCharacterVars.almostdone = true;
                            }
                        }
                        else
                        {
                            if (ismarket)
                            {
                                dialogue.text = "Click on what you would like to buy from the market.";
                            }
                            else if (ispizza)
                            {
                                dialogue.text = "Click on what you want on your pizza!";
                            }
                        }
                    }
                    else if (!ismarket && !ispizza)
                    {
                        mainCharacterVars.taskItem = whatYouNeed;
                        for (int i = 0; i < afterInteract.Count; i++)
                        {
                            placeholder.Add(afterInteract[i]);
                        }
                        placeholder.Add(whatYouNeed);
                        dialogue.text = dictInitialize.scramble(placeholder);
                        placeholder.Clear();
                        selected = "";

                        mainCharacterVars.almostdone = true;
                    }
                }
                else if (!taskmode)
                {
                    if (mainCharacterVars.currentTask)
                    {
                        confusedemote.SetActive(true);
                    }
                    dialogue.text = npcConversation.makeConversation(false);
                }
            }
        }
    }