示例#1
0
    public override void Init()
    {
        Debug.Log("ScenarioBurn - Init");
        //set the curr state
        currState = STATE_SB.STATE_BURN_START;
        prevState = currState;
        //setting of booleans
        isEventCompleted = false;
        isInteracted     = false;
        isScenarioDone   = false;
        //setting of other variables
        //instructionIndex = 0;
        // starting index of curr instruction to follow
        step  = 0;
        timer = 8.0f;
        // settign of active for gameObject
        MedTriggerLocal.SetActive(false);
        medKitCanvas.SetActive(false);
        chefToSink = false;

        // Enabling of related scripts
        if (traineeChef.GetComponent <GetBurn>() != null)
        {
            traineeChef.GetComponent <GetBurn>().enabled = true;
        }

        NonUIInteraction.firstObjSelected = NonUIInteraction.secObjSelected = null;
    }
示例#2
0
    protected override bool SwitchState(int index)
    {
        if (index < 0 || index >= (int)STATE_SB.STATE_TOTAL)
        {
            return(false);
        }

        prevState = currState;
        currState = (STATE_SB)index;
        return(true);
    }
示例#3
0
    // Update is called once per frame
    private 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_SB.STATE_BURN_START:
            // Start scenario
            timer -= 1 * Time.deltaTime;
            if (timer > 0)
            {
                chefAnimController.SetBool("beforeBurnIdle", true);
            }
            else
            {
                chefAnimController.SetBool("getsBurn", true);
                chefAnimController.SetBool("afterBurnIdle", true);

                progressBar.SetActive(true);
                progressBar.GetComponent <ProgressBar>().currValue = 0f;

                if (AnimatorIsPlaying("After Burn Idle"))
                {
                    SwitchState((int)STATE_SB.STATE_WASH_HANDS);
                }
            }
            break;

        case STATE_SB.STATE_WASH_HANDS:
            if (!chefToSink)
            {
                if (NonUIInteraction.firstObjSelected == null)
                {
                    Arrow.instance.objectToSnap = ScenarioHandler.instance.CurrScenario.GetComponent <ScenarioBurn>().traineeChef;
                }
                else if (NonUIInteraction.firstObjSelected == traineeChef)
                {
                    Arrow.instance.objectToSnap = ScenarioHandler.instance.CurrScenario.GetComponent <ScenarioBurn>().sink;
                }

                if (NonUIInteraction.firstObjSelected != null && NonUIInteraction.secObjSelected != null)
                {
                    if (NonUIInteraction.firstObjSelected.name == "Chef" && NonUIInteraction.secObjSelected.name == "SinkEmpty")
                    {
                        chefToSink = true;
                    }
                }
            }
            else
            {
                traineeChef.GetComponent <GreenParticle>().PlayGreenParticle();
                traineeChef.transform.position = sinkLocal.transform.position;
                traineeChef.transform.LookAt(sink.transform.position);
                chefAnimController.SetBool("afterCutIdle", true);
                aSource.PlayOneShot(correctSound);
                traineeChef.GetComponent <BoxCollider>().center = new Vector3(traineeChef.GetComponent <BoxCollider>().center.x, traineeChef.GetComponent <BoxCollider>().center.y, 0);
                SwitchState((int)STATE_SB.STATE_GET_MEDKIT);
                //play wash hand animation
            }
            //if (isEventCompleted)
            break;

        case STATE_SB.STATE_GET_MEDKIT:
            //Player finds the medkit and brings in to a certain location
            isEventCompleted            = isInteracted;
            Arrow.instance.objectToSnap = MedKit;
            if (isEventCompleted)
            {
                gParticle.transform.position = sbInfoContainer[currState].interactables[0].transform.position;
                gParticle.GetComponent <ParticleController>().PlayParticle();
                SwitchState((int)STATE_SB.STATE_GET_MEDKIT_TO_LOCAL);
            }

            break;

        case STATE_SB.STATE_GET_MEDKIT_TO_LOCAL:
            //Player brings the medkit to a certain location
            Arrow.instance.objectToSnap = MedTriggerLocal;
            MedTriggerLocal.SetActive(true);
            if (isEventCompleted)
            {
                medKitCanvas.SetActive(true);
                MedTriggerLocal.SetActive(true);
                Arrow.instance.objectToSnap = null;
                tempCollider.SetActive(true);
                MedTriggerLocal.SetActive(false);
                SwitchState((int)STATE_SB.STATE_PURIFIED_WATER);
                Arrow.instance.gameObject.SetActive(false);
                aSource.PlayOneShot(correctSound);
                gParticle.transform.position = sbInfoContainer[currState].interactables[0].transform.position;
                gParticle.GetComponent <ParticleController>().PlayParticle();
            }
            break;

        case STATE_SB.STATE_PURIFIED_WATER:
            //Get purified water and apply on traineeChef
            if (isEventCompleted)
            {
                aSource.PlayOneShot(correctSound);
                SwitchState((int)STATE_SB.STATE_APPLY_CREAM);
            }

            break;

        case STATE_SB.STATE_APPLY_CREAM:
            //Get cream and apply on traineeChef
            if (isEventCompleted)
            {
                aSource.PlayOneShot(correctSound);
                SwitchState((int)STATE_SB.STATE_APPLY_BANDANGE);
            }
            break;

        case STATE_SB.STATE_APPLY_BANDANGE:
            //Get bandage and apply on traineeChef
            if (isEventCompleted)
            {
                if (!isScenarioDone)
                {
                    aSource.PlayOneShot(correctSound);
                }
                isScenarioDone = true;
            }
            break;
        }
    }