private void UpdateSpeech() { float anchorX = VendorSpeech.GetComponent <RectTransform>().anchoredPosition.x; float anchorY = VendorSpeech.GetComponent <RectTransform>().anchoredPosition.y; if (speechVisible) { if (VendorSpeech.GetComponent <RectTransform>().anchoredPosition.y < 94) { VendorSpeech.GetComponent <RectTransform>().anchoredPosition = new Vector3(anchorX, anchorY + 1200 * Time.deltaTime); if (VendorSpeech.GetComponent <RectTransform>().anchoredPosition.y >= 94) { VendorSpeech.GetComponent <RectTransform>().anchoredPosition = new Vector3(anchorX, 94); canSpeek = true; } } if (!VendorSpeech.activeSelf) { VendorSpeech.SetActive(true); } } else { canSpeek = false; if (VendorSpeech.GetComponent <RectTransform>().anchoredPosition.y > -94) { VendorSpeech.GetComponent <RectTransform>().anchoredPosition = new Vector3(anchorX, anchorY - 1200 * Time.deltaTime); } if (VendorSpeech.activeSelf && VendorSpeech.GetComponent <RectTransform>().anchoredPosition.y <= -94) { VendorSpeech.GetComponent <RectTransform>().anchoredPosition = new Vector3(anchorX, -94); VendorSpeech.SetActive(false); } } if (speechVisible && vendorSpeechText.text != currentVendorText && canSpeek) { vendorSpeechTimer += Time.deltaTime; vendorSoundTimer += Time.deltaTime; if (vendorSpeechTimer > 0.04f) { if (vendorSpeechText.text.Length < currentVendorText.Length) { vendorSpeechText.text += currentVendorText[vendorSpeechText.text.Length]; vendorSpeechTimer = 0f; } } if (vendorSoundTimer > 0.15f) { FindObjectOfType <AudioManager>().Play("talk" + Random.Range(1, 4)); vendorSoundTimer = 0f; } } }