private void Update() { // Move the key down on press and back up on release if (Input.GetKeyDown(m_attachedKey)) { // Remove the shadow m_shadowObject.effectDistance = Vector2.zero; // Lower the key visualization by the same amount as the shadow was previously m_rectTransform.anchoredPosition = m_baseRect.position + new Vector2(0.0f, m_shadowHeight); //Play Audio keyAudio.PlayOneShot(0, 1.0f); } else if (Input.GetKeyUp(m_attachedKey)) { // Place the shadow back m_shadowObject.effectDistance = new Vector2(0.0f, m_shadowHeight); // Move the key visuals back m_rectTransform.anchoredPosition = m_baseRect.position; //play Audio keyAudio.PlayOneShot(1, 1.0f); } }
//--- Event Hooks ---// public void OnCallCompleted(Call_Group _callObj, Call_State _callFinalState) { // Handle the call termination differently, depending on if ended well or not if (_callFinalState == Call_State.Waited_Too_Long) { // Play negative feedback audioManager.PlayOneShot(4, 0.2f); //TODO: Increment missed calls counter persistManager.callsMissed += 1; } else if (_callFinalState == Call_State.Completed) { // Play positive feedback audioManager.PlayOneShot(3, 0.5f); // Add points, reputation, etc callsCompletedDaily++; GameObject.FindObjectOfType <CashCalculation_Script>().CalculateCashForCall(_callObj); //End of game Satisfaction //TODO: Increment total calls completed persistManager.callsCompleted += 1; persistManager.gamesSatisfaction += _callObj.GetSatisfationFromCall(); //callCash.GetComponent<TextMeshProUGUI>().text = GameObject.FindObjectOfType<CashCalculation_Script>().CalculateCashForCall(_callObj).ToString(); totalCash.GetComponent <TextMeshProUGUI>().text = GameObject.FindObjectOfType <CashCalculation_Script>().TotalCashEarned().ToString(); //Returns Total Cash //Debug the new money recieved. //Debug.Log(this.GetComponent<CashCalculation_Script>().CalculateCashForCall(_callObj)); } // Remove the UI element from the call backlog m_callLogUI.RemoveCallGroupUI(_callObj); // Unhook the event _callObj.m_OnCallCompleted.RemoveListener(this.OnCallCompleted); // Remove the callers from their associated rooms m_roomManager.DisconnectCallers(_callObj.CallParticipants); // We should also remove the call from the list // However, we need to wait until the end of the frame to ensure all the other call operations are complete StartCoroutine(DeleteCall(_callObj)); }
public void UpdateCallState() { // Grab the first caller's room so we can see if everyone else is there too Room_Name firstCallerRoom = m_callParticipants[0].CurrentRoom; // We need to check if it's ONLY this call group in this room. There shouldn't be another group in here if (m_roomManager.GetCurrentCapacity(firstCallerRoom) != m_numParticipants) { m_callState = Call_State.Waiting; return; } // Check in with the individual callers and see if they are in the same room foreach (var caller in m_callParticipants) { // If one of the participants is not in the same room, this call is in a waiting state by default if (firstCallerRoom != caller.CurrentRoom) { m_callState = Call_State.Waiting; return; } } // If all of the callers are in the same room, we still need to determine if they are actually in a chat room // If they are not in a chat room but they are all together, they are still waiting if (firstCallerRoom >= Room_Name.Chat_1 && firstCallerRoom <= Room_Name.Chat_5) { m_callState = Call_State.Active; if (prevState == Call_State.Waiting) { if (audioManager == null) { audioManager = GameObject.Find("AudioManager").GetComponent <Audio_Manager>(); } audioManager.PlayOneShot(2, 0.5f); } prevState = m_callState; } else { m_callState = Call_State.Waiting; prevState = m_callState; } }
// Update is called once per frame void Update() { //If we want to keep this function this class if (shouldCountTime) { timeElapsed = timeElapsed + Time.deltaTime; //Day end protocol if (timeElapsed >= dayLengthIRL) { //Call CalculateEndOfDayMoney //dailyEarnings.GetComponent<TextMeshProUGUI>().text = "$ " + this.GetComponent<CashCalculation_Script>().CalculateCashForDay(dayCounter + 1).ToString(); ; dayCounter++; if (dayCounter >= maxDayCounter) { //End week and game // save the data out to the persistence manager persistence.m_dayNumber = dayCounter; persistence.m_totalMoney = Mathf.RoundToInt(GetComponent <CashCalculation_Script>().TotalCashEarned()); // Show the day over text txtDayOver.SetActive(true); txtBackground.SetActive(true); // Remove all the callers from the rooms GameObject.FindObjectOfType <Room_Manager>().DisconnectAllCallers(); // Stop updating all of the calls GameObject.FindObjectOfType <Call_Manager>().IsActive = false; // Disable input GameObject.FindObjectOfType <Key_Manager>().enabled = false; //End day Invoke("MoveToEndWeekScreen", dayBufferLength); } else { shouldCountTime = false; //Play dayEnd Audio audioManager.PlayOneShot(5, 0.5f); // save the data out to the persistence manager persistence.m_dayNumber = dayCounter; persistence.m_totalMoney = Mathf.RoundToInt(GetComponent <CashCalculation_Script>().TotalCashEarned()); // Show the day over text txtDayOver.SetActive(true); txtBackground.SetActive(true); // Remove all the callers from the rooms GameObject.FindObjectOfType <Room_Manager>().DisconnectAllCallers(); // Stop updating all of the calls GameObject.FindObjectOfType <Call_Manager>().IsActive = false; // Disable input GameObject.FindObjectOfType <Key_Manager>().enabled = false; //End day Invoke("MoveToEndDayScreen", dayBufferLength); } } } if (clock) { timeElapsedLERP = timeElapsed / dayLengthIRL; // This is the percent of the day that has gone by dayProgressBar.fillAmount = timeElapsedLERP; if (timeElapsedLERP > 0.9f) { dayProgressBar.color = dayProgressHigh; } else if (timeElapsedLERP > 0.7f) { dayProgressBar.color = dayProgressMed; } dayLengthIG = (dayEndTime * 60.0f) - (dayStartTime * 60.0f); timeElapsedIGLERP = Mathf.Lerp((dayStartTime * 60.0f), (dayEndTime * 60.0f), timeElapsedLERP); hours = (int)timeElapsedIGLERP / 60; minutes = (int)timeElapsedIGLERP % 60; timeString = hours.ToString("00") + ":"; timeString += minutes.ToString("00"); clock.GetComponent <TextMeshProUGUI>().text = timeString; } }