public void TabsButton(int _tabNum) { currentChat = _tabNum; //clear all messages foreach (Transform text in generalTextContainer.transform) { GameObject.Destroy(text.gameObject); } //add lastest messages for (int i = 0; i < maxNumOfMessages; i++) { if (tabs[currentChat].displayedText.Count - (maxNumOfMessages - i) >= 0) { GameObject newText = Instantiate(textPrefab, generalTextContainer.transform); newText.GetComponent <TextMeshProUGUI>().text = tabs[currentChat].displayedText[tabs[currentChat].displayedText.Count - (maxNumOfMessages - i)]; tabs[currentChat].currentText = tabs[currentChat].displayedText.Count - 1; } } manager.CloseChat(); //update the choices for (int i = 0; i < tabs[currentChat].lastMessage.options.Count; i++) { optionsPanel.transform.GetChild(i).GetComponent <ChoiceController>().SetValues(tabs[currentChat].lastMessage.options[i]); } if (tabs[currentChat].lastMessage.options.Count != 0) { manager.ChatStartButton(); } }
// 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 (!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); Vector3 moveDir = Quaternion.Euler(0f, targetAngle, 0f) * Vector3.forward; controller.Move(moveDir.normalized * speed * Time.deltaTime); } } else { if (currentAwnser != "") { if (!Input.GetMouseButtonDown(0) && !Input.GetMouseButtonDown(1) && Input.anyKeyDown) { manager.AddAwnser(currentAwnser[0]); currentAwnser = currentAwnser.Remove(0, 1); } } else { if (Input.GetKeyDown(KeyCode.Return)) { chatManager.SendAwnser(currentOption); manager.CloseChat(); } } } //mouse click if (Input.GetMouseButtonDown(0)) { Targetted(); } //close opend tabs and remove targets if (Input.GetKeyDown(KeyCode.Escape)) { manager.NoTarget(); if (manager.inChat) { manager.CloseChat(); } } }
// 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(); } } } }