Example #1
0
    private void MovePlayerToNextRoom()
    {
        Player.instance.transform.position = destination.teleportTransform.position;
        RoomBHV parent = destination.parentRoom;

        Player.instance.AdjustCamera(parent.x, parent.y);
        OnRoomExit();
        OnRoomEnter();
    }
Example #2
0
 private void Awake()
 {
     parentRoom = transform.parent.GetComponent <RoomBHV>();
     audioSrc   = GetComponent <AudioSource>();
 }
Example #3
0
    void InstantiateRoom(int x, int y)
    {
        if (map.rooms[x, y] == null)
        {
            return;
        }
        Room    room    = map.rooms[x, y];
        RoomBHV newRoom = Instantiate(roomPrefab, roomsParent);

        roomBHVMap[x, y] = newRoom;
        if (x > 1)   // west
        {
            if (map.rooms[x - 1, y] != null)
            {
                //Sets door
                newRoom.westDoor = map.rooms[x - 1, y].lockID;
                //Links room doors - assumes the rooms are given in a specific order from data: incr X, incr Y
                roomBHVMap[x, y].doorWest.SetDestination(roomBHVMap[x - 2, y].doorEast);
                roomBHVMap[x - 2, y].doorEast.SetDestination(roomBHVMap[x, y].doorWest);
            }
        }
        if (y > 1)   // north
        {
            if (map.rooms[x, y - 1] != null)
            {
                //Sets door
                newRoom.northDoor = map.rooms[x, y - 1].lockID;
                //Links room doors - assumes the rooms are given in a specific order from data: incr X, incr Y
                roomBHVMap[x, y].doorNorth.SetDestination(roomBHVMap[x, y - 2].doorSouth);
                roomBHVMap[x, y - 2].doorSouth.SetDestination(roomBHVMap[x, y].doorNorth);
            }
        }
        if (x < Map.sizeX)   // east
        {
            if (map.rooms[x + 1, y] != null)
            {
                //Sets door
                newRoom.eastDoor = map.rooms[x + 1, y].lockID;
            }
        }
        if (y < Map.sizeY)   // south
        {
            if (map.rooms[x, y + 1] != null)
            {
                //Sets door
                newRoom.southDoor = map.rooms[x, y + 1].lockID;
            }
        }
        newRoom.x = x;                          //TODO: check use
        newRoom.y = y;                          //TODO: check use
        newRoom.availableKeyID = room.keyID;    // Avaiable key to be collected in that room
        if (x == map.startX && y == map.startY) // sala é a inicial
        {
            newRoom.isStart = true;
        }
        if (x == map.endX && y == map.endY)   // sala é a final
        {
            newRoom.isEnd = true;
        }
        //Sets room transform position
        newRoom.gameObject.transform.position = new Vector2(roomSpacingX * x, -roomSpacingY * y);
    }