void Update() { switch (State) { case IncubatorState.Working: GrowLevel += Time.deltaTime; if (GrowLevel >= GrowTime) { OnHumanDone(); } if (OxygenLevel > 0) { OxygenLevel -= GameManager.Instance.PressureLossSpeed * Time.deltaTime; } if (Mathf.Abs(0.5f - OxygenLevel) > TargetPrecision) { State = IncubatorState.Idle; } break; case IncubatorState.Filling: OxygenLevel += GameManager.Instance.IncubatorFillingRate * Time.deltaTime; break; } }
private void OnDisconnectedTube() { if (CurrentHuman != GameManager.HumanType.None) { State = IncubatorState.Working; } else { State = IncubatorState.Idle; } }
private void OnTaskStart(GameManager.HumanType type) { if (State == IncubatorState.Working) { return; } CurrentHuman = type; State = IncubatorState.Working; GrowTime = GameManager.Instance.GetGrowTime(type); GrowLevel = 0; TargetPrecision = GameManager.Instance.GetPrecision(type); OxygenLevel = 0.5f; GameObject newTruck = Instantiate(TruckPrefab); newTruck.transform.position = TruckStartPosition; CurrentTruck = newTruck.GetComponent <Truck>(); CurrentTruck.SetTargetPosition(new Vector2(transform.position.x, TruckStartPosition.y)); }
private void OnHumanDone() { State = IncubatorState.Idle; CurrentTruck.SetTargetPosition(TruckEndPosition); GameManager.Instance.IncubatorDoneEvent.Invoke(this, CurrentHuman); }
private void OnConnectedTube() { State = IncubatorState.Filling; }