public void ResetState(int checkpoint, int subObjectives) { bowlingComplete.SetValue(0f); spareMode.SetValue(0f); initialSetupTimer = 0f; currentState = BowlingState.BowlingState_InitialSetup; }
private void Update() { for (int i = 0; i < 10; i++) { if (!bowlingPins[i].IsInPlace()) { pinsDownOutputs[i].SetValue(1f); } else { pinsDownOutputs[i].SetValue(0f); } } switch (currentState) { case BowlingState.BowlingState_Complete: break; case BowlingState.BowlingState_InitialSetup: initialSetupTimer += Time.deltaTime; if (initialSetupTimer >= 3f) { for (int n = 0; n < 10; n++) { bowlingPins[n].Show(); } inSpareMode = false; spareMode.SetValue(0f); currentState = BowlingState.BowlingState_Ready; } break; case BowlingState.BowlingState_Ready: if (ballInPinsArea.value > 0.5f) { currentState = BowlingState.BowlingState_BallInPins; pinsKnockDownTimer = 0f; } break; case BowlingState.BowlingState_BallInPins: { pinsKnockDownTimer += Time.deltaTime; pinsDown = 0; for (int l = 0; l < 10; l++) { if (!bowlingPins[l].IsInPlace()) { pinsDown++; } } if (pinsDown == 10) { for (int m = 0; m < 10; m++) { bowlingPins[m].Hide(); } bowlingComplete.SetValue(1f); currentState = BowlingState.BowlingState_Complete; } else if (pinsKnockDownTimer >= 10f) { currentState = BowlingState.BowlingState_TidyingPins; } break; } case BowlingState.BowlingState_TidyingPins: if (inSpareMode) { for (int j = 0; j < 10; j++) { bowlingPins[j].Show(); } inSpareMode = false; spareMode.SetValue(0f); } else { for (int k = 0; k < 10; k++) { if (!bowlingPins[k].IsInPlace()) { bowlingPins[k].Hide(); } } if (pinsDown != 0) { inSpareMode = true; spareMode.SetValue(1f); } } currentState = BowlingState.BowlingState_Ready; break; } }