protected override bool SwitchState(int index) { if (index < 0 || index >= (int)STATE_SF.STATE_TOTAL) { return(false); } prevState = currState; currState = (STATE_SF)index; return(true); }
public override void Init() { Debug.Log("ScenarioFire - Init"); currState = STATE_SF.STATE_FIRE_START; prevState = currState; isEventCompleted = false; isInteracted = false; isScenarioDone = false; step = -1; //instructionIndex = 0; if (!isBigFire) { allInstructions = smallInstructionList; } else { allInstructions = largeInstructionList; } //int rand = Random.Range(0, 2); //if (rand == 0) //{ // allInstructions = smallInstructionList; // isBigFire = false; //} //else // allInstructions = largeInstructionList; if (traineeChef.GetComponent <RunAway>() != null) { traineeChef.GetComponent <RunAway>().enabled = true; } //#if UNITY_EDITOR // isBigFire = false; //#endif smallFire.SetActive(!isBigFire); largeFire.SetActive(isBigFire); }
// Update is called once per frame void Update() { if (isScenarioDone) { //Debug.Log("Scenario Completed"); ScenarioHandler.instance.description.text = "Scenario Completed - bck btn to quit"; //ScenarioHandler.instance.ScenarioQuit(); } if (prevState != currState) { Debug.Log("StateChanged"); isEventCompleted = false; isInteracted = false; //reset index for instructions //instructionIndex = 0; ++step; SetCurrentInteractable(); SetInstruction(); prevState = currState; } switch (currState) { case STATE_SF.STATE_FIRE_START: // Buffer state doorAnim.SetBool("isOpen", true); chefAnimController.SetBool("running", true); SwitchState((int)STATE_SF.STATE_OFF_GAS); break; case STATE_SF.STATE_OFF_GAS: isEventCompleted = isInteracted; if (isEventCompleted) { aSource.PlayOneShot(correctSound); EnableGreenEffect(); SwitchState((int)STATE_SF.STATE_OFF_MAIN_GAS); } break; case STATE_SF.STATE_OFF_MAIN_GAS: isEventCompleted = isInteracted; if (isEventCompleted) { EnableGreenEffect(); aSource.PlayOneShot(correctSound); if (isBigFire) { SwitchState((int)STATE_SF.STATE_PULL_ALARM); } else { SwitchState((int)STATE_SF.STATE_GET_FIRE_BLANKET); } } break; case STATE_SF.STATE_GET_FIRE_BLANKET: if (isInteracted) { fireBlanket.SetActive(true); EnableGreenEffect(); //aSource.PlayOneShot(correctSound); if (InteractedGO == fireBlanket) { isEventCompleted = true; } } if (isEventCompleted) { //aSource.PlayOneShot(correctSound); SwitchState((int)STATE_SF.STATE_USE_FIRE_BLANKET); } break; case STATE_SF.STATE_USE_FIRE_BLANKET: //if (InteractedGO != fireBlanket) //{ // Debug.Log("Pick up the fire blanket"); // return; //} if (isEventCompleted) { EnableGreenEffect(); fireBlanket.GetComponent <Animator>().SetBool("openFireBlanket", true); //smallFire.SetActive(false); //largeFire.SetActive(false); //isScenarioDone = true; aSource.PlayOneShot(correctSound); SwitchState((int)STATE_SF.STATE_USE_FIRE_EXTINGUISHER); } break; case STATE_SF.STATE_USE_FIRE_EXTINGUISHER: extinguisherTriggerBox.SetActive(true); // enter trigger box and animation plays // particle effect shoot out from the fe // stand in the trigger box and face the fire direction for 5-10 sec b4 it ends //sfInfoContainer[currState].interactables[0].transform.forward = Camera.main.transform.forward; if (isEventCompleted) { EnableGreenEffect(); //play animation extinguisherAnim.SetBool("isExtinguisher", true); sprayParticle.SetActive(true); //particles?? StartCoroutine("FireExtinguish"); } break; case STATE_SF.STATE_PULL_ALARM: isEventCompleted = isInteracted; if (isEventCompleted) { //fireAlarmAnim.SetBool("Play", true); EnableGreenEffect(); aSource.PlayOneShot(correctSound); SwitchState((int)STATE_SF.STATE_EVACUATE); } break; case STATE_SF.STATE_EVACUATE: isEventCompleted = isInteracted; if (isEventCompleted) { EnableGreenEffect(); if (!isScenarioDone) { aSource.PlayOneShot(correctSound); } isScenarioDone = true; } break; default: break; } }