Пример #1
0
    //Instance method [Singleton]
    void ToInstance()
    {
        //Check if instance already exists
        if (instance == null)
        {
            //if not, set instance to this
            instance = this;
        }

        //If instance already exists and it's not this:
        else if (instance != this)
        {
            //Then destroy this. This enforces our singleton pattern, meaning there can only ever be one instance of a GameManager.
            Destroy(gameObject);
        }
    }
Пример #2
0
    Vector2 DirectionDoor()
    {
        //Vector2 direction = new Vector2(0,0);
        //Vector2 origin = transform.position;

        CamRoomMove crm = CamRoomMove.instance;

        Vector2 vec = new Vector2(0, 0);
        Vector2 aux = transform.position;

        if (doorDirection == Direction.Left)   //Setting Values according to the character's door enter

        {
            vec = new Vector2(aux.x - nextDoorDistance, aux.y);
            crm.MovCam(-1, 0);
        }
        else if (doorDirection == Direction.Right)
        {
            vec = new Vector2(aux.x + nextDoorDistance, aux.y);
            crm.MovCam(1, 0);
        }
        else if (doorDirection == Direction.Top)
        {
            vec = new Vector2(aux.x, aux.y + nextDoorDistance);
            crm.MovCam(0, 1);
        }
        else if (doorDirection == Direction.Bot)
        {
            vec = new Vector2(aux.x, aux.y - nextDoorDistance);
            crm.MovCam(0, -1);

            //direction = new Vector2(0, -1);
            //origin = new Vector2(aux.x, aux.y - 30);
        }

        //RaycastHit2D hit = Physics2D.Raycast(origin, direction, nextDoorDistance, obstacleLayer);

        return(vec);
    }