Пример #1
0
    string getStringFromResponse(string path, int index)
    {
        string[] pathArray = StringArrayFunctions.getMessage(path);
        Debug.Log("PATH IS " + pathArray.Length + " LONG");
        Debug.Log("PATH IS " + path);

        return(pathArray[index]);
    }
Пример #2
0
    int offerType(GameObject obj, Response r)
    {
        string[] pathArray = StringArrayFunctions.getMessage(r.path);
        if (pathArray[0] == "remove")
        {
            return(1);
        }
        if (pathArray [0] == "tanning")
        {
            return(2);
        }
        if (pathArray [0] == "love")
        {
            return(3);
        }

        if (pathArray [0] == "dermatologist")
        {
            return(4);
        }
        if (pathArray.Length > 1)
        {
            //has a character attached to it
            if (pathArray [1] == "epilogue")
            {
                Debug.Log("Epilogue: " + r.path);

                return(5);
            }
        }
        if (pathArray[0] == "piercing")
        {
            return(6);
        }
        if (pathArray[0] == "haircut")
        {
            return(7);
        }
        return(-1);
    }
Пример #3
0
    void respond(string path, int index, string belief)
    {
        //TODO: Path update for just character
        //PLAYER RESPONSE EVENT
//        GetComponent<PlayerBehavior>().trackEvent(2, "DLG", belief, StringArrayFunctions.getMessage(path)[0]);
        //player.takeAction (true);
        player.removeMessage(index);
        //TODO: Check threshold requirements if needed in mid conversation to add/remove response time
        if (StringArrayFunctions.getMessage(path)[1].Contains("deadend"))
        {
            //Player chose a dead end, unhook to allow for a new conversation
            //player.unhook();
        }
        else
        {
            Debug.Log("NOT A DEADEND: " + path);
        }
        player.addMessage(path);
//		player.refreshInbox();
        //player.previewInbox.messageContainer.SetActive(true);
        Destroy(gameObject);
    }
Пример #4
0
    void respond(string path, int index, string belief)
    {
        //        responseContainer.SetActive(false);
        string[] res = StringArrayFunctions.getMessage(path);
        player.SendMessageToPlayer(player.getCharacter(), res[1], true);
        Debug.Log("responding to " + player.getCharacter() + " with passage: " + res[1]);
        player.ClearResponseOptions();

        Debug.Log(path);

        if (StringArrayFunctions.getMessage(path)[1].Contains("deadend"))
        {
            //Player chose a dead end, unhook to allow for a new conversation
        }
        respondButton.SetActive(true);

        if (StringArrayFunctions.getMessage(path)[1].Contains("finished"))
        {
            //Player chose a dead end, unhook to allow for a new conversation
            Debug.Log("Conversation Finished");
            waitingForResponse = false;
        }
    }
Пример #5
0
    public void NewStatusUpdate(string path)
    {
        if (path.Contains("random"))
        {
            //only use
        }

        GameObject post = Instantiate(postTemplate, postContainer.transform);

        post.GetComponent <Post>().timePosted.text = "Now";
        string[] message = StringArrayFunctions.getMessage(path);

        if (message.Length == 2)
        {
            //INTERVENTION
            post.GetComponent <Post>().status.text      = json[message[0]][message[1]]["post"];
            post.GetComponent <Post>().profileName.text = json[message[0]][message[1]]["name"];
            //            post.GetComponent<Post>().profilePhoto = IMAGE;
        }
        else if (message.Length == 1)
        {
            //RANDOM

            int randomCharacterNameIndex = Random.Range(0, json[message[0]]["names"].Count);
            randomCharacterPostIndex = Random.Range(0, json[message[0]]["posts"].Count);
            post.GetComponent <Post>().status.text      = json[message[0]]["posts"][randomCharacterPostIndex]["post"];
            post.GetComponent <Post>().profileName.text = json[message[0]]["names"][randomCharacterNameIndex];
        }
        post.GetComponentInChildren <Button>().onClick.AddListener(() =>
        {
            //Pop Up Footer

            footer.SetActive(true);



            //Populate Responses
            if (message.Length == 1)
            {
                responses = json[message[0]]["posts"][randomCharacterPostIndex]["responses"];
            }
            else
            {
                responses = json[message[0]][message[1]]["responses"];
            }
            if (!post.GetComponent <Post>().responsesPopulated)
            {
                for (int i = 0; i < responses.Count; i++)
                {
                    string[] param = StringArrayFunctions.getMessage(responses[i]["path"]);

                    GameObject comment = Instantiate(commentTemplate, comments.gameObject.transform);
                    comment.GetComponent <ResponseOption>().response.text     = responses[i]["response"];
                    comment.GetComponent <ResponseOption>().postCommentButton = post.GetComponent <Post>().commentButton;
                    comment.GetComponentInChildren <Button>().onClick.AddListener(() =>

                    {
                        comment.GetComponent <ResponseOption>().clicked();

                        //POST COMMENT CLICK
                        post.GetComponent <Post>().UpdateCommentCount();
                        //                        comments.togglePagination(false);
                        //                        comments.gameObject.SetActive(false);
                        //check if there's a DM
                        if (param[0].Contains("chat"))
                        {
                            string[] chats           = PlayerPrefsX.GetStringArray("chats");
                            List <string> chats_list = chats.ToList();
                            if (!chats_list.Contains(param[2]))
                            {
                                Debug.Log("This chat doesn't exist yet, adding it to chat list");
                                chats_list.Add(param[2]);
                                PlayerPrefsX.SetStringArray("chats", chats_list.ToArray());
                            }
                            else
                            {
                                Debug.Log("This chat already exists, not adding it to the list");
                            }
                            notifications.SetActive(true);
                        }
                        //REMOVE PREVIOUS RESPONSE OPTIONS
                        foreach (Transform child in comments.transform)
                        {
                            GameObject.Destroy(child.gameObject);
                        }

                        footer.SetActive(false);
                    });
                }
                post.GetComponent <Post>().responsesPopulated = true;
                comments.CheckForResponseOptions();
                comments.gameObject.SetActive(true);
            }
        });
    }
Пример #6
0
    public void addResponse(Response r)
    {
        string[] param = StringArrayFunctions.getMessage(r.path);
        if (param.Length > 2)
        {
            Invoke("GameFinished", 6.0f);
        }
        else
        {
            Debug.Log("Adding Response");
            //show response in chat interface
            GameObject response = Instantiate(responseTemplate, responseOptions.transform);
            response.GetComponent <ResponseOption>().response.text = r.text;
            response.GetComponentInChildren <Button>().onClick.AddListener(() =>
            {
                responseText   = r.text;
                responsePath   = r.path;
                responseIndex  = r.messageIndex;
                responseBelief = r.belief;

                addResponseToChatLog(r.text);

                List <string> chat_path_response_history = PlayerPrefsX.GetStringArray(player.getCharacter() + "_responses").ToList();
                chat_path_response_history.Add(r.text);
                Debug.Log("character: response: " + r.text);
                PlayerPrefsX.SetStringArray(player.getCharacter() + "_responses", chat_path_response_history.ToArray());

                responseTimer = Time.time + Random.Range(1.5f, 3f);

                //store conversation in player prefs string array. Example anxiety = "Hey, you've been missing class a lot. You alright? - Are you really sure about this?"

//                string[] previous_responses = PlayerPrefsX.GetStringArray("responses_" + player.getCharacter());
//                List<string> previous_responses_list = previous_responses.ToList();
//                previous_responses_list.Add(r.text);
//                PlayerPrefsX.SetStringArray("responses_" + player.getCharacter(), previous_responses_list.ToArray());

                if (!r.path.Contains("reroute"))
                {
                    Debug.Log("good choice!");
                    waitingForNPCMessage = true;
                }

                else if (r.path.Contains("reroute") && rerouteCounter < maxReroutes)
                {
                    //end conversation, player failed
                    Debug.Log("bad choice...");
                    rerouteCounter++;
                    waitingForNPCMessage = true;
                }
                else if (rerouteCounter >= maxReroutes)
                {
                    Debug.Log("failed...");
                    waitingForNPCMessage = false;
                    waitingForResponse   = false;
                    //spawn message
                    NPCLeftConversation();
                }
                //cleanup option display
                responseOptions.GetComponent <ResponseOptions>().options.Clear();
                responseOptions.GetComponent <ResponseOptions>().togglePagination(false);
                responseOptions.transform.parent.gameObject.SetActive(false);
            });
        }
    }