private void BeginNextJob() { List <string> availableJobPartTypes = new List <string>(jobPartTypes); foreach (string jobPartType in jobPartTypes) { // If there is at least one active job of this type if (activeJobPartTypes.Contains(jobPartType)) { // If there are two or more active jobs of this type List <string> matchingJobs = activeJobPartTypes.FindAll(x => x.Equals(jobPartType)); if (matchingJobs.Count >= 2) { availableJobPartTypes.Remove(jobPartType); } } } TVBoxHandler nextTVBoxHandler = availableTVBoxHandlers[0]; availableTVBoxHandlers.RemoveAt(0); soundEffectPlayer.PlayBellSound(); string nextJobPartType = availableJobPartTypes[Random.Range(0, availableJobPartTypes.Count)]; activeJobPartTypes.Add(nextJobPartType); activeTVBoxHandlers.Add(nextTVBoxHandler); nextTVBoxHandler.OnJobStart(nextJobPartType, activeJobPartTypes.Count - 1); }
public void OnTVBoxJobBehaviorFinished(TVBoxHandler jobTVBoxHandler) { int jobIndex = activeTVBoxHandlers.FindIndex(x => x == jobTVBoxHandler); availableTVBoxHandlers.Add(jobTVBoxHandler); activeJobPartTypes.RemoveAt(jobIndex); activeTVBoxHandlers.Remove(jobTVBoxHandler); }
public bool CheckIfValidJobObject(string objectType) { if (!activeJobPartTypes.Contains(objectType)) { return(false); } // Otherwise, check all occurances of the object type in job list for (int i = 0; i < activeJobPartTypes.Count; i++) { if (activeJobPartTypes[i].Equals(objectType)) { TVBoxHandler jobTVBoxHandler = activeTVBoxHandlers[i]; if (jobTVBoxHandler.CheckIfJobIsActive()) { return(true); } } } return(false); }
public void OnValidObjectSubmitted(ConveyorPartHandler objectPartHandler) { if (!gameIsActive) { return; } string objectType = objectPartHandler.GetPartType(); if (!activeJobPartTypes.Contains(objectType)) { return; } TVBoxHandler jobTVBoxHandler = null; // Otherwise, find first valid occurances of the object type in job list for (int i = 0; i < activeJobPartTypes.Count; i++) { if (activeJobPartTypes[i].Equals(objectType)) { TVBoxHandler currentJobTVBoxHandler = activeTVBoxHandlers[i]; if (currentJobTVBoxHandler.CheckIfJobIsActive()) { jobTVBoxHandler = currentJobTVBoxHandler; break; } } } if (jobTVBoxHandler == null) { Debug.LogWarning("WARNING - Object considered valid was not labeled as active" + $"by any TV box handlers, object='{objectPartHandler.gameObject.name}'"); return; } objectPartHandler.OnValidObjectSubmitted(); totalEarnings += jobTVBoxHandler.OnJobSubmitted(); totalEarningsText.text = GetEarningsString(); soundEffectPlayer.PlaySuccessSound(); currentConveyorSpeed *= 1.05f; foreach (ConveyorBeltHandler beltHandler in conveyorBeltHandlers) { beltHandler.SetSpeed(currentConveyorSpeed); } mainMusicAudioSource.pitch = Mathf.Clamp(mainMusicAudioSource.pitch * 1.02f, 1.0f, 1.75f); //conveyorBeltAudioSource.pitch = Mathf.Clamp(conveyorBeltAudioSource.pitch * 1.02f, 1.0f, 1.5f); currentSpawnTimeMultiplier *= 0.95f; spawnManager.SetSpawnTimeMultiplier(currentSpawnTimeMultiplier); currentTimeMultiplier *= 0.9f; foreach (TVBoxHandler boxHandler in tvBoxHandlers) { boxHandler.SetTimeMultiplier(currentTimeMultiplier); } currentEarningsMultiplier *= 1.1f; foreach (TVBoxHandler boxHandler in tvBoxHandlers) { boxHandler.SetCurrentEarningsMultiplier(currentEarningsMultiplier); } Debug.Log($"<color=cyan>SUBMITTED JOB for {objectType}</color>"); }