Ejemplo n.º 1
0
    public void SendAwnser(ChatOption _nextText)
    {
        playerController.currentAwnser = "";
        playerController.currentOption = null;
        manager.ClearAwnser();

        //print awnser

        for (int i = 0; i < _nextText.playerAwnser.Count; i++) //for each line in this message
        {
            if (i == 0)                                        //check if it is the 1st message so the name is added
            {
                tabs[currentChat].displayedText.Add("[" + manager.playerName + "] " + _nextText.playerAwnser[i]);
            }
            else//dont add name
            {
                tabs[currentChat].displayedText.Add(_nextText.playerAwnser[i]);
            }


            //check if the scroll up is active
            if (!scrolling && currentChat == tabs[currentChat].tabNum)
            {
                GameObject newText = Instantiate(textPrefab, generalTextContainer.transform); //create a new line
                if (i == 0)                                                                   //check if it is the 1st message so the name is added
                {
                    newText.GetComponent <TextMeshProUGUI>().text = "[" + manager.playerName + "] " + _nextText.playerAwnser[i];
                }
                else//dont add name
                {
                    newText.GetComponent <TextMeshProUGUI>().text = _nextText.playerAwnser[i];
                }
                tabs[currentChat].currentText += 1;
                //chatNumb[0] += 1;//current chat possion

                CheckOverflow(0);//check if overflow
            }
        }

        //close options
        manager.CloseChat();

        if (_nextText.npcAnwser.options.Count != 0)
        {
            StartCoroutine(WaitForNextSentence(_nextText.npcAnwser.timer, tabs[currentChat], 1, _nextText.npcAnwser));
        }
        else
        {
            StartCoroutine(WaitForNextSentence(_nextText.npcAnwser.timer, tabs[currentChat], tabs[currentChat].tabChat.Count - 1, _nextText.npcAnwser));
        }
    }
Ejemplo n.º 2
0
    // Update is called once per frame
    void Update()
    {
        float   horizontal = Input.GetAxisRaw("Horizontal");
        float   vertical   = Input.GetAxisRaw("Vertical");
        Vector3 dir        = new Vector3(horizontal, 0f, vertical).normalized;

        if (Input.GetMouseButton(1) && Input.GetMouseButton(0))
        {
            dir.z = 1;
        }
        if (!manager.inChat)//the player is currently not typing in chat
        {
            //movement
            if (dir.magnitude >= 0.1f)
            {
                float targetAngle = Mathf.Atan2(dir.x, dir.z) * Mathf.Rad2Deg + cam.eulerAngles.y;
                float angle       = Mathf.SmoothDampAngle(transform.eulerAngles.y, targetAngle, ref turnSmoothVel, rotSpeed);
                transform.rotation = Quaternion.Euler(0f, angle, 0f);
                vSpeed            -= 9.8f * Time.deltaTime;


                Vector3 moveDir = Quaternion.Euler(0f, targetAngle, 0f) * Vector3.forward;
                controller.SimpleMove(moveDir.normalized * speed * Time.deltaTime);
            }



            if (Input.GetKeyDown(KeyCode.B))
            {
                manager.OpenInventory();
            }

            if (Input.GetKeyDown(KeyCode.C))
            {
                manager.OpenCharacter();
            }
        }
        else
        {
            if (currentAwnser != "")
            {
                if (doorsManager.HoldToType())
                {
                    if (!Input.GetMouseButtonDown(0) && !Input.GetMouseButtonDown(1) && Input.anyKey)
                    {
                        if (manager.CheckAwnserSize())
                        {
                            //chat is full
                            manager.AwnserClearOne();
                        }

                        manager.AddAwnser(currentAwnser[0]);
                        currentAwnser = currentAwnser.Remove(0, 1);
                    }
                }
                else
                {
                    if (!Input.GetMouseButtonDown(0) && !Input.GetMouseButtonDown(1) && Input.anyKeyDown)
                    {
                        if (manager.CheckAwnserSize())
                        {
                            //chat is full
                            manager.AwnserClearOne();
                        }

                        manager.AddAwnser(currentAwnser[0]);
                        currentAwnser = currentAwnser.Remove(0, 1);
                    }
                }
            }
            else
            {
                if (Input.GetKeyDown(KeyCode.Return))
                {
                    if (currentOption.triggersEvents)
                    {
                        doorsManager.StartEvent(currentOption.nextEvent);
                    }

                    chatManager.SendAwnser(currentOption);
                    manager.CloseChat();
                }
            }
        }


        //mouse click

        if (Input.GetMouseButtonDown(0))
        {
            Targetted();
        }

        //close opend tabs and remove targets
        if (Input.GetKeyDown(KeyCode.Escape))
        {
            if (manager.CheckOpenPanels() && !manager.inChat)
            {
                manager.OpenEscPanel();
            }
            else
            {
                manager.NoTarget();
                manager.CloseRPPanel();
                manager.CloseCharacter();
                manager.CloseInventory();
                if (manager.inChat)
                {
                    manager.CloseChat();
                    manager.ClearAwnser();
                }
            }
        }
    }