Ejemplo n.º 1
0
    protected override bool SwitchState(int index)
    {
        if (index < 0 || index >= (int)STATE_SC.STATE_TOTAL)
        {
            return(false);
        }

        prevState = currState;
        currState = (STATE_SC)index;
        return(true);
    }
Ejemplo n.º 2
0
 public override void Init()
 {
     Debug.Log("ScenarioCut - Init");
     currState        = STATE_SC.STATE_CUT_START;
     prevState        = currState;
     isEventCompleted = false;
     isInteracted     = false;
     isScenarioDone   = false;
     //instructionIndex = 0;
     step  = 0;
     timer = 5.0f;
     MedTriggerLocal.SetActive(false);
     medKitCanvas.SetActive(false);
     if (traineeChef.GetComponent <GetCut>() != null)
     {
         traineeChef.GetComponent <GetCut>().enabled = true;
     }
 }
Ejemplo n.º 3
0
    // 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_SC.STATE_CUT_START:
            // Start scenario
            timer -= 1 * Time.deltaTime;
            if (timer > 0)
            {
                chefAnimController.SetBool("beforeCutIdle", true);
            }
            else
            {
                chefAnimController.SetBool("getsCut", true);
                chefAnimController.SetBool("afterCutIdle", true);
                progressBar.SetActive(true);
                progressBar.GetComponent <ProgressBar>().currValue = 0f;
                //SwitchState((int)STATE_SC.STATE_GET_MEDKIT);

                if (AnimatorIsPlaying("After Cut Idle"))
                {
                    SwitchState((int)STATE_SC.STATE_GET_MEDKIT);
                }
            }
            break;

        case STATE_SC.STATE_GET_MEDKIT:
            //Player finds the medkit and brings in to a certain location
            isEventCompleted            = isInteracted;
            Arrow.instance.objectToSnap = MedKit;
            if (isEventCompleted)
            {
                EnableGreenEffect();
                SwitchState((int)STATE_SC.STATE_GET_MEDKIT_TO_LOCAL);
            }
            break;

        case STATE_SC.STATE_GET_MEDKIT_TO_LOCAL:
            //Player brings the medkit to a certain location
            Arrow.instance.objectToSnap = MedTriggerLocal;
            MedTriggerLocal.SetActive(true);
            if (isEventCompleted)
            {
                EnableGreenEffect();
                Arrow.instance.objectToSnap = null;
                tempCollider.SetActive(true);
                MedTriggerLocal.SetActive(false);
                medKitCanvas.SetActive(true);
                aSource.PlayOneShot(correctSound);
                SwitchState((int)STATE_SC.STATE_PURIFIED_WATER);
            }
            break;

        case STATE_SC.STATE_PURIFIED_WATER:
            //Get purified water and apply on traineeChef
            if (isEventCompleted)
            {
                progressBar.GetComponent <ProgressBar>().AddProgress(35f);
                aSource.PlayOneShot(correctSound);
                SwitchState((int)STATE_SC.STATE_APPLY_GAUZE);
            }
            break;

        case STATE_SC.STATE_APPLY_GAUZE:
            //Get gauze and apply pressure on traineeChef
            if (isEventCompleted)
            {
                aSource.PlayOneShot(correctSound);
                SwitchState((int)STATE_SC.STATE_APPLY_YELLOW_ACRI);
            }
            break;

        case STATE_SC.STATE_APPLY_YELLOW_ACRI:
            //Apply yellow ACRI solution
            if (isEventCompleted)
            {
                aSource.PlayOneShot(correctSound);
                progressBar.GetComponent <ProgressBar>().AddProgress(35f);
                SwitchState((int)STATE_SC.STATE_APPLY_BANDANGE);
            }
            break;

        case STATE_SC.STATE_APPLY_BANDANGE:
            //Get bandage and apply on traineeChef
            if (isEventCompleted)
            {
                if (!isScenarioDone)
                {
                    aSource.PlayOneShot(correctSound);
                }
                progressBar.GetComponent <ProgressBar>().AddProgress(35f);
                isScenarioDone = true;
            }
            break;
        }
    }