Ejemplo n.º 1
0
    // Update is called once per frame
    void Update()
    {
        if (mudSwitch.isSwitchedOn())
        {
            mud.fill(); colliderE.enabled = false;
        }
        if (!mudSwitch.isSwitchedOn())
        {
            mud.drain(); colliderE.enabled = true;

            //audio.GetComponent<AudioSource> ().Stop ();
        }

        if (mud.isFilling())
        {
            player.setSpeed(drainedPlayerSpeed(player.getX(), player.getY(), defaultPlayerSpeed));

            audio.GetComponent <AudioSource> ().Play();
        }

        if (isActive)
        {
            dialogManager.setRoom("room_4");
            player.setRoom("room_4");

            switch (eventCounter)
            {
            case 0:


                if (mudSwitch.isSwitchedOn())
                {
                    eventCounter++;
                }


                break;

            case 1:

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

                break;


            case 2:

                if (distanceToEscape > 10 && distanceToEscape < 15)
                {
                    dialogManager.setDialog("dialog1.txt");
                    eventCounter++;
                }
                break;

            case 3:
                if (distanceToEscape > 7 && distanceToEscape < 10)
                {
                    dialogManager.setDialog("dialog2.txt");
                    eventCounter++;
                }
                break;


            case 4:
                if (distanceToEscape > 5 && distanceToEscape < 7)
                {
                    dialogManager.setDialog("dialog3.txt");
                    eventCounter++;
                }
                break;

            case 5:
                if (distanceToEscape > 4 && distanceToEscape < 5)
                {
                    dialogManager.setDialog("dialog4.txt");
                    eventCounter++;
                }
                break;


            case 6:
                if (distanceToEscape > 3 && distanceToEscape < 4)
                {
                    dialogManager.setDialog("dialog5.txt");
                    eventCounter++;
                }
                break;

            case 7:

                break;
            }



            if (roomSolved)
            {
                if (exitDoor.isLocked())
                {
                    //GetComponent<AudioSource> ().enabled = false;
                    player.setSpeed(defaultPlayerSpeed);
                    File.Delete("dialog/room_4/ItemHolder.txt");
                    r4Dark         = GameObject.Find("raum4D").GetComponent <SpriteRenderer>();
                    r4Dark.enabled = true;
                    r5Dark         = GameObject.Find("raum5D").GetComponent <SpriteRenderer>();
                    r5Dark.enabled = false;
                    endAndProceed();
                }
            }
        }
    }
Ejemplo n.º 2
0
    void Update()
    {
        //size calculation utility variables:
        float a, b, distance;

        a = 0f;
        b = 0f;
        float sizeModifier = 0;

        if
        (roomA.roomIsActive())
        {
            a            = roomA.getCenterX() - player.getX();
            b            = roomA.getCenterY() - player.getY();
            distance     = Mathf.Pow((float)(Mathf.Pow((float)a, 2.0f) + Mathf.Pow((float)b, 2.0f)), 0.5f);
            sizeModifier = getGaussianOf(distance, 2f, 1f);
        }
        else if
        (room1.roomIsActive())
        {
            a            = room1.getCenterX() - player.getX();
            b            = room1.getCenterY() - player.getY();
            distance     = Mathf.Pow((float)(Mathf.Pow((float)a, 2.0f) + Mathf.Pow((float)b, 2.0f)), 0.5f);
            sizeModifier = getGaussianOf(distance, 1f, 1f);
        }
        else if
        (room2.roomIsActive())
        {
            a            = room2.getCenterX() - player.getX();
            b            = room2.getCenterY() - player.getY();
            distance     = Mathf.Pow((float)(Mathf.Pow((float)a, 2.0f) + Mathf.Pow((float)b, 2.0f)), 0.5f);
            sizeModifier = getGaussianOf(distance, 1f, 1f);
        }
        else if
        (room3.roomIsActive())
        {
            a            = room3.getCenterX() - player.getX();
            b            = room3.getCenterY() - player.getY();
            distance     = Mathf.Pow((float)(Mathf.Pow((float)a, 2.0f) + Mathf.Pow((float)b, 2.0f)), 0.5f);
            sizeModifier = getGaussianOf(distance, 2f, 0.7f);
        }
        else if
        (room4.roomIsActive())
        {
            a            = room4.getCenterX() - player.getX();
            b            = room4.getCenterY() - player.getY();
            distance     = Mathf.Pow((float)(Mathf.Pow((float)a, 2.0f) + Mathf.Pow((float)b, 2.0f)), 0.5f);
            sizeModifier = getGaussianOf(distance, 2f, 0.6f);
        }
        else if
        (room5.roomIsActive())
        {
            a            = room5.getCenterX() - player.getX();
            b            = room5.getCenterY() - player.getY();
            distance     = Mathf.Pow((float)(Mathf.Pow((float)a, 2.0f) + Mathf.Pow((float)b, 2.0f)), 0.5f);
            sizeModifier = getGaussianOf(distance, 2f, 1.1f);
        }

        //Setting new camera size according to current sizeModifier:
        if (playerCamera.enabled)
        {
            Camera.main.orthographicSize = 2f + sizeModifier;
        }


        /*Vector3 temp = gameObject.transform.eulerAngles;
         * temp.z = 1;
         * gameObject.transform.eulerAngles += temp;*/
    }