コード例 #1
0
    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;
        }
    }
コード例 #2
0
 private void OnDisconnectedTube()
 {
     if (CurrentHuman != GameManager.HumanType.None)
     {
         State = IncubatorState.Working;
     }
     else
     {
         State = IncubatorState.Idle;
     }
 }
コード例 #3
0
    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));
    }
コード例 #4
0
 private void OnHumanDone()
 {
     State = IncubatorState.Idle;
     CurrentTruck.SetTargetPosition(TruckEndPosition);
     GameManager.Instance.IncubatorDoneEvent.Invoke(this, CurrentHuman);
 }
コード例 #5
0
 private void OnConnectedTube()
 {
     State = IncubatorState.Filling;
 }