Beispiel #1
0
    private void OnTriggerEnter2D(Collider2D trigger)
    {
        PlayerMovement2 p = trigger.GetComponent <PlayerMovement2>();

        if (p && !locked)
        {
            //Moves Camera and player on entering door
            if (transform.rotation.z == -0.7071068f)
            {
                MainCamera.moveRight();
                trigger.transform.position = new Vector3(trigger.transform.position.x + move_unit,
                                                         trigger.transform.position.y,
                                                         trigger.transform.position.z);
            }
            if (transform.rotation.z == 0)
            {
                MainCamera.moveUp();
                trigger.transform.position = new Vector3(trigger.transform.position.x,
                                                         trigger.transform.position.y + move_unit,
                                                         trigger.transform.position.z);
            }
            if (transform.rotation.z == 1)
            {
                MainCamera.moveDown();
                trigger.transform.position = new Vector3(trigger.transform.position.x,
                                                         trigger.transform.position.y - move_unit,
                                                         trigger.transform.position.z);
            }
            if (transform.rotation.z == .7071068f)
            {
                MainCamera.moveLeft();
                trigger.transform.position = new Vector3(trigger.transform.position.x - move_unit,
                                                         trigger.transform.position.y,
                                                         trigger.transform.position.z);
            }

            locked = true;
            Invoke("unlockDoors", 0.3f);
        }
    }