Exemple #1
0
 void StartGame()
 {
     // Spawn the player on the selected starting point
     TDMap.Room startRoom = map.GetRoom(Random.Range(0, map.GetRooms().Count));
     levelObjects.Add(Instantiate(playerSpawnPoint, new Vector3((startRoom.center.x + 0.5f) * tileSize, (0.5f * tileSize) + 3.0f, (startRoom.center.y + 0.5f) * tileSize), Quaternion.identity));
     GameManager.CreatePlayer(tileSize);
 }
Exemple #2
0
    private void CreateVerticalWall(TDMap.Room room, float roomLocation, int roomNumber)
    {
        GameObject newWall = Instantiate(wallPrefab, new Vector3((roomLocation) * tileSize, 1.5f * tileSize, wallCenterY), Quaternion.identity, this.transform);

        newWall.transform.localScale = new Vector3(tileSize, tileSize * tileSize, room.height * tileSize);
        newWall.name = "Room " + roomNumber.ToString() + "\t | Vertical wall";
        levelObjects.Add(newWall);
    }
Exemple #3
0
    void BuildWalls(TDMap.Room room, int roomNumber)
    {
        wallCenterX = room.width % 2 == 0 ? room.center.x * tileSize : (room.center.x + 0.5f) * tileSize;
        wallCenterY = room.height % 2 == 0 ? room.center.y * tileSize : (room.center.y + 0.5f) * tileSize;

        // Horizontal walls
        CreateHorizontalWall(room, room.top + 0.5f, roomNumber);
        CreateHorizontalWall(room, room.bottom + 0.5f, roomNumber);

        // Vertical walls
        CreateVerticalWall(room, room.left + 0.5f, roomNumber);
        CreateVerticalWall(room, room.right - 1.5f, roomNumber);
    }
Exemple #4
0
    void BuildPortals(TDMap.Room room, int roomNumber)
    {
        if (room.portals[(int)PORTAL.TOP].isConnected)
        {
            CreateNewPortal(room.portals[(int)PORTAL.TOP], room.portalPositionTop, roomNumber);
        }

        if (room.portals[(int)PORTAL.BOTTOM].isConnected)
        {
            CreateNewPortal(room.portals[(int)PORTAL.BOTTOM], room.portalPositionBottom, roomNumber);
        }

        if (room.portals[(int)PORTAL.LEFT].isConnected)
        {
            CreateNewPortal(room.portals[(int)PORTAL.LEFT], room.portalPositionLeft, roomNumber);
        }

        if (room.portals[(int)PORTAL.RIGHT].isConnected)
        {
            CreateNewPortal(room.portals[(int)PORTAL.RIGHT], room.portalPositionRight, roomNumber);
        }
    }
Exemple #5
0
 public void SetRoomConnection(TDMap.Room room)
 {
     connectedToRoom = room;
 }
 public void ChangeRoom(TDMap.Room room, float tileSize)
 {
     this.transform.position = new Vector3((room.center.x + 0.5f) * tileSize, 25, (room.center.y + 0.5f) * tileSize);
 }