예제 #1
0
파일: Chat.cs 프로젝트: dinguses/squirrel
        private void ParseChatXml()
        {
            foreach (XmlElement node in testConvo.SelectNodes("convo/chat"))
            {
                ChatStep newStep = new ChatStep();
                newStep.type   = int.Parse(node.GetAttribute("type"));
                newStep.name   = node.GetAttribute("from");
                newStep.length = float.Parse(node.GetAttribute("time"));
                newStep.words  = node.GetAttribute("words");
                bool.TryParse(node.GetAttribute("startNext"), out bool isStartNext);
                newStep.startNext = isStartNext ? bool.Parse(node.GetAttribute("startNext")) : false;
                if (isStartNext)
                {
                    newStep.startNextTime = float.Parse(node.GetAttribute("startNextTime"));
                }

                bool.TryParse(node.GetAttribute("cancel"), out bool isCancel);
                newStep.cancel = isCancel ? bool.Parse(node.GetAttribute("cancel")) : false;

                chatSteps.Add(newStep);
            }
        }
예제 #2
0
파일: Chat.cs 프로젝트: dinguses/squirrel
        public void NextStep()
        {
            ChatStep step = chatSteps[currStep];

            if (!postChoiceJump || step.type == 5)
            {
                switch (step.type)
                {
                // 0 - Other player joining/leaving chat
                case 0:
                    bool leaving = Convert.ToBoolean(step.length);
                    MainChatText.text += ("\n<color=grey>" + step.name + (leaving ? " has entered the room." : " has left the room.") + "</color>");
                    lineCounter++;
                    StartCoroutine(Wait(0));
                    break;

                // 1 - Sending a message
                case 1:
                    numPeopleTyping++;
                    usersTyping.Add(step.name);
                    StartCoroutine(UserIsTyping(step.length, step.startNext, step.name, step.startNextTime, step.words, step.cancel));
                    break;

                // 2 - Pause
                case 2:
                    StartCoroutine(Wait(step.length));
                    break;

                // 3 - Player dialogue option
                case 3:
                    if (step.length == 1)
                    {
                        Choice1.words           = step.words;
                        Choice1.choiceName      = step.name;
                        Choice1.ChoiceText.text = Choice1.words;
                        C1_Container.SetActive(true);
                    }

                    if (step.length == 2)
                    {
                        Choice2.words           = step.words;
                        Choice2.choiceName      = step.name;
                        Choice2.ChoiceText.text = Choice2.words;
                        C2_Container.SetActive(true);
                    }

                    if (step.length == 3)
                    {
                        Choice3.words           = step.words;
                        Choice3.choiceName      = step.name;
                        Choice3.ChoiceText.text = Choice3.words;
                        C3_Container.SetActive(true);
                    }
                    StartCoroutine(Wait(0));
                    break;

                // 4 - End of player choices
                case 4:
                    // ToDo: more specific logic for 1/2 option choices
                    break;

                // 5  - Designates start of branch
                case 5:
                    if (step.name == lastChoice)
                    {
                        postChoiceJump = false;
                    }
                    StartCoroutine(Wait(0));
                    break;

                // 6 - Jump to specific id
                case 6:
                    postChoiceJump = true;
                    lastChoice     = step.name;
                    StartCoroutine(Wait(0));
                    break;

                default:
                    break;
                }

                if ((step.type == 1 || step.type == 0) && lineCounter >= 16)
                {
                    var test = textField.sizeDelta;
                    textField.sizeDelta = new Vector2(test.x, test.y + 20);
                    testRect.velocity   = new Vector2(0, 35f);
                }
            }
            else
            {
                StartCoroutine(Wait(0));
            }
        }