Пример #1
0
    // Update is called once per frame
    void Update()
    {
        if (isActive)
        {
            dialogManager.setRoom("room_3");
            player.setRoom("room_3");

            switch (eventCounter)
            {
            case 0:
                if (event1.getColliderStateEnter())
                {
                    player.freeze();

                    if (player.getFirstItem() != null)
                    {
                        //Debug.Log ("FirstIsntHere");
                        dialogManager.setDialog("someitems.txt");
                        firstTime = false;
                    }
                    else if (firstTime)
                    {
                        dialogManager.setDialog("noitems.txt");
                    }
                    else
                    {
                        dialogManager.setDialog("lostitems.txt");
                        eventCounter++;
                    }
                }
                if (dialogManager.getDialogOutput() == "falling")
                {
                    collider.enabled = false;
                    if (timeCounter < 2f)
                    {
                        tempPlanken = planken.transform.position.y + Time.deltaTime * 2f;

                        planken.transform.position = new Vector3(planken.transform.position.x, tempPlanken, planken.transform.position.z);
                    }

                    if (timeCounter > .5f && (spieler.transform.position.y > 14))
                    {
                        tempPlanken = spieler.transform.position.y - Time.deltaTime * 1f;

                        spieler.transform.position = new Vector3(spieler.transform.position.x, tempPlanken, spieler.transform.position.z);

                        tempPlanken = spieler.transform.localScale.y - 0.05f * Time.deltaTime;

                        spieler.transform.localScale = new Vector3(tempPlanken, tempPlanken, 1f);
                    }

                    if (timeCounter > 1.5f && timeCounter < 3.5f)
                    {
                        tempPlanken = planken.transform.position.y - Time.deltaTime * 2f;

                        planken.transform.position = new Vector3(planken.transform.position.x, tempPlanken, planken.transform.position.z);
                    }
                    else if (timeCounter > 3.5f)
                    {
                        spieler.transform.localScale = new Vector3(0.025f, 0.025f, 1f);
                        timeCounter = 0f;
                        player.setSpeed(1f);
                        collider.enabled = true;
                        //player.unfreeze ();
                        dialogManager.setDialogOutputTo("");
                    }

                    timeCounter += Time.deltaTime;
                }
                if (dialogManager.getDialogOutput() == "delete")
                {
                    player.deleteIventory();
                }
                if (dialogManager.getDialogOutput() == "endDialog")
                {
                    //Debug.Log ("endDialog = true");
                    endDialog = true;
                }

                if (dialogManager.getDialogOutput() == "unfreeze")
                {
                    player.unfreeze();
                    dialogManager.setDialogOutputTo("");
                }
                if (dialogManager.isActive() == false && endDialog)
                {
                    eventCounter++;
                }



                break;

            case 1:
                player.unfreeze();
                eventCounter++;

                break;


            case 2:
                eventCounter++;

                break;

            case 3:

                exitDoor.setIsLocked();                 //exitDoor locked=false!! (unlock)
                roomSolved = true;
                eventCounter++;
                break;

            case 4:
                break;
            }



            if (roomSolved)
            {
                if (exitDoor.isLocked())
                {
                    File.Delete("dialog/room_3/ItemHolder.txt");
                    r4Dark         = GameObject.Find("raum4D").GetComponent <SpriteRenderer>();
                    r4Dark.enabled = false;
                    r3Dark         = GameObject.Find("raum3D").GetComponent <SpriteRenderer>();
                    r3Dark.enabled = true;
                    //audio.GetComponent<AudioSource> ().Stop ();
                    endAndProceed();
                }
            }
        }
    }