Esempio n. 1
0
    private void Awake()
    {
        DontDestroyOnLoad(this);
        Instance = this;
//        SceneManager.activeSceneChanged += SceneChanged;
        SceneManager.LoadScene(currentLevel);
    }
Esempio n. 2
0
        private static void Main()
        {
            while (true)
            {
                var map  = LevelSwitcher.GetNextLevel();
                var test = new Player();
                if (!Game.IsOver)
                {
                    Game.Map = LevelCreator.CreateMap(map);
                    Application.Run(new GameWindow());
                }
                else
                {
                    break;
                }
            }
            End();


            void End()
            {
                if (!Game.IsOver)
                {
                    return;
                }
                var name = Interaction.InputBox("Enter your name", "Succes", "", -1, -1);

                RecordTable.AddRecord(name, Game.MovesCount);
                MessageBox.Show(RecordTable.GetTopFive(), "Records", MessageBoxButtons.OKCancel);
            }
        }
Esempio n. 3
0
    void Awake()
    {
        levelSwitcher = GameObject.Find("LevelSwitcher").GetComponent<LevelSwitcher>();
        mainMenuUI = GameObject.Find("MainMenuUI");

        hideGUI();
    }
Esempio n. 4
0
    void Awake()
    {
        levelSwitcher = GameObject.Find("LevelSwitcher").GetComponent <LevelSwitcher>();
        mainMenuUI    = GameObject.Find("MainMenuUI");

        hideGUI();
    }
Esempio n. 5
0
 private void LevelSwitcherInitialization()
 {
     levelSwitcher = transform.parent.gameObject.GetComponent <LevelSwitcher>();
     if (levelSwitcher == null)
     {
         throw new System.NotFiniteNumberException();
     }
 }
Esempio n. 6
0
 public void OnPointerClick(PointerEventData eventData)
 {
     if (active)
     {
         LevelSwitcher.loadLevel(level.getId() + 1);
         AudioProvider.getInstance().playAudio("Standard Button");
     }
 }
Esempio n. 7
0
 void Awake()
 {
     instance = this;
 }
Esempio n. 8
0
    private void Generate()
    {
        // 1. Spawn starting room
        GameObject main = Instantiate(rooms[0], new Vector3(), Quaternion.identity);

        // 2 & 3 -->
        GenerateWalls(main.transform);
        // 6. Clutter room
        ClutterRoom();

        // 4. Ignore [closed] walls

        // 5. Process [open] walls, return to 2
        while (roomsToDo.Count != 0)
        {
            Vector3    pos  = roomsToDo.Pop();
            GameObject side = Instantiate(rooms[Random.Range(0, rooms.Count)], pos, Quaternion.identity);

            // 2 & 3 -->
            GenerateWalls(side.transform);

            // 6. Clutter room
            ClutterRoom();
        }

        roomCount++;
        Vector3 lastRoom = new Vector3();

        stackRoomCount = maxStackPerRoom;

        // 7. Process [door] walls, return to 1
        canSpawnEnemies = true;
        while (reservedRooms.Count != 0)
        {
            Vector3 reservedPos = reservedRooms.Pop();
            // 1. Spawn starting room
            GameObject reservedSide = Instantiate(rooms[Random.Range(0, rooms.Count)], reservedPos, Quaternion.identity);

            // 2 & 3 -->
            GenerateWalls(reservedSide.transform);

            // 6. Clutter room
            ClutterRoom();

            // 4. Ignore [closed] walls

            // 5. Process [open] walls, return to 2
            while (roomsToDo.Count != 0)
            {
                Vector3    pos  = roomsToDo.Pop();
                GameObject side = Instantiate(rooms[Random.Range(0, rooms.Count)], pos, Quaternion.identity);

                // 2 & 3 -->
                GenerateWalls(side.transform);

                // 6. Clutter room
                ClutterRoom();
            }

            roomCount++;
            lastRoom = reservedPos;

            stackRoomCount = maxStackPerRoom;
        }

        // If an end point was not generated in a different room, generate in last loaded room
        // Issue with this as standard is that last loaded room will be next to first room
        // Due to nature of stack
        if (!hasEnd)
        {
            lastRoom.y += 10.0f;
            LevelSwitcher ls = Instantiate(levelEnd, lastRoom, Quaternion.identity);
            ls.TheEnd = true;
        }
    }
Esempio n. 9
0
    private void GenerateWalls(Transform roomTrans)
    {
        // Array to hold this room's four wall types
        WallTypes[] walls = new WallTypes[4];
        hasDoors = false;

        // 2. For each wall, determine if [open], [closed], [door]
        for (int index = 0; index < walls.Length; index++)
        {
            // First wall values correspond to indices in roomWalls. Last is a special number to identify when there is no wall
            walls[index] = (WallTypes)Random.Range(0, 3);

            if (walls[index] == WallTypes.DOOR)
            {
                if (roomCount >= maxRooms)
                {
                    walls[index] = WallTypes.BLANK;
                }
                hasDoors = true;
            }
        }

        // 3. Place associated walls (none for [open])
        Vector3 wallPos = roomTrans.position;

        //////////////////////
        // The four compass directions (-X, +X, -Z, +Z) are the same, so only first commented
        //////////////////////

        // Left wall (-X)
        // If target position already filled
        if (placedRooms.Contains(roomTrans.position + (-roomTrans.right * 20.0f)))
        {
            Debug.Log("Room to -X");
        }
        // If target position reserved for another room
        else if (reservedRooms.Contains(roomTrans.position + (-roomTrans.right * 20.0f)))
        {
            InstantiateWall(WallTypes.BLANK, roomTrans.position + (-roomTrans.right * 9.5f), Quaternion.identity);
        }
        // If target position available!
        else
        {
            // Individual wall logic
            switch (walls[0])
            {
            // Spawn blank wall
            case WallTypes.BLANK:
                InstantiateWall(WallTypes.BLANK, roomTrans.position + (-roomTrans.right * 9.5f), Quaternion.identity);
                break;

            // Spawn a door and reserve the target beyond it for another room
            case WallTypes.DOOR:
                InstantiateWall(WallTypes.DOOR, roomTrans.position + (-roomTrans.right * 9.5f), Quaternion.identity);
                reservedRooms.Push(roomTrans.position + (-roomTrans.right * 20.0f));
                break;

            // Leave a space, this room will be expanded
            case WallTypes.NONE:
                if (stackRoomCount > 0)
                {
                    // Add a room to process in -X direction
                    Vector3 pos = roomTrans.position;
                    pos += (-roomTrans.right * 20.0f);

                    // Add room beyond empty wall as next to generate, then decrease available stack
                    roomsToDo.Push(pos);
                    stackRoomCount--;
                }
                // Unless there is no space to expand -- close off the room
                else
                {
                    InstantiateWall(WallTypes.BLANK, roomTrans.position + (-roomTrans.right * 9.5f), Quaternion.identity);
                }
                break;

            default:
                Debug.Log("========NO WALL========");
                break;
            }
        }

        // Right wall (+X)
        // If target position already filled
        if (placedRooms.Contains(roomTrans.position + (roomTrans.right * 20.0f)))
        {
            Debug.Log("Room to +X");
        }
        // If target position reserved for another room
        else if (reservedRooms.Contains(roomTrans.position + (roomTrans.right * 20.0f)))
        {
            InstantiateWall(WallTypes.BLANK, roomTrans.position + (roomTrans.right * 9.5f), Quaternion.identity);
        }
        // If target position available!
        else
        {
            // Individual wall logic
            switch (walls[1])
            {
            // Spawn blank wall
            case WallTypes.BLANK:
                InstantiateWall(WallTypes.BLANK, roomTrans.position + (roomTrans.right * 9.5f), Quaternion.identity);
                break;

            // Spawn a door and reserve the target beyond it for another room
            case WallTypes.DOOR:
                InstantiateWall(WallTypes.DOOR, roomTrans.position + (roomTrans.right * 9.5f), Quaternion.identity);
                reservedRooms.Push(roomTrans.position + (roomTrans.right * 20.0f));
                break;

            // Leave a space, this room will be expanded
            case WallTypes.NONE:
                if (stackRoomCount > 0)
                {
                    // Add a room to process in +X direction
                    Vector3 pos = roomTrans.position;
                    pos += (roomTrans.right * 20.0f);

                    // Add room beyond empty wall as next to generate, then decrease available stack
                    roomsToDo.Push(pos);
                    stackRoomCount--;
                }
                // Unless there is no space to expand -- close off the room
                else
                {
                    InstantiateWall(WallTypes.BLANK, roomTrans.position + (roomTrans.right * 9.5f), Quaternion.identity);
                }
                break;

            default:
                Debug.Log("========NO WALL========");
                break;
            }
        }

        // Back wall (-Z)
        // If target position already filled
        if (placedRooms.Contains(roomTrans.position + (-roomTrans.forward * 20.0f)))
        {
            Debug.Log("Room to -Z");
        }
        // If target position reserved for another room
        else if (reservedRooms.Contains(roomTrans.position + (-roomTrans.forward * 20.0f)))
        {
            InstantiateWall(WallTypes.BLANK, roomTrans.position + (-roomTrans.forward * 9.5f), Quaternion.Euler(0.0f, 90.0f, 0.0f));
        }
        // If target position available!
        else
        {
            // Individual wall logic
            switch (walls[2])
            {
            // Spawn blank wall
            case WallTypes.BLANK:
                InstantiateWall(WallTypes.BLANK, roomTrans.position + (-roomTrans.forward * 9.5f), Quaternion.Euler(0.0f, 90.0f, 0.0f));
                break;

            // Spawn a door and reserve the target beyond it for another room
            case WallTypes.DOOR:
                InstantiateWall(WallTypes.DOOR, roomTrans.position + (-roomTrans.forward * 9.5f), Quaternion.Euler(0.0f, 90.0f, 0.0f));
                reservedRooms.Push(roomTrans.position + (-roomTrans.forward * 20.0f));
                break;

            // Leave a space, this room will be expanded
            case WallTypes.NONE:
                if (stackRoomCount > 0)
                {
                    // Add a room to process in +X direction
                    Vector3 pos = roomTrans.position;
                    pos += (-roomTrans.forward * 20.0f);

                    // Add room beyond empty wall as next to generate, then decrease available stack
                    roomsToDo.Push(pos);
                    stackRoomCount--;
                }
                // Unless there is no space to expand -- close off the room
                else
                {
                    InstantiateWall(WallTypes.BLANK, roomTrans.position + (-roomTrans.forward * 9.5f), Quaternion.Euler(0.0f, 90.0f, 0.0f));
                }
                break;

            default:
                Debug.Log("========NO WALL========");
                break;
            }
        }

        // Front wall (+Z)
        // If target position already filled
        if (placedRooms.Contains(roomTrans.position + (roomTrans.forward * 20.0f)))
        {
            Debug.Log("Room to +Z");
        }
        // If target position reserved for another room
        else if (reservedRooms.Contains(roomTrans.position + (-roomTrans.right * 20.0f)))
        {
            InstantiateWall(WallTypes.BLANK, roomTrans.position + (roomTrans.forward * 9.5f), Quaternion.Euler(0.0f, 90.0f, 0.0f));
        }
        // If target position available!
        else
        {
            // Individual wall logic
            switch (walls[3])
            {
            // Spawn blank wall
            case WallTypes.BLANK:
                InstantiateWall(WallTypes.BLANK, roomTrans.position + (roomTrans.forward * 9.5f), Quaternion.Euler(0.0f, 90.0f, 0.0f));
                break;

            // Spawn a door and reserve the target beyond it for another room
            case WallTypes.DOOR:
                InstantiateWall(WallTypes.DOOR, roomTrans.position + (roomTrans.forward * 9.5f), Quaternion.Euler(0.0f, 90.0f, 0.0f));
                reservedRooms.Push(roomTrans.position + (roomTrans.forward * 20.0f));
                break;

            // Leave a space, this room will be expanded
            case WallTypes.NONE:
                if (stackRoomCount > 0)
                {
                    // Add a room to process in +X direction
                    Vector3 pos = roomTrans.position;
                    pos += (roomTrans.forward * 20.0f);

                    // Add room beyond empty wall as next to generate, then decrease available stack
                    roomsToDo.Push(pos);
                    stackRoomCount--;
                }
                // Unless there is no space to expand -- close off the room
                else
                {
                    InstantiateWall(WallTypes.BLANK, roomTrans.position + (roomTrans.forward * 9.5f), Quaternion.Euler(0.0f, 90.0f, 0.0f));
                }
                break;

            default:
                Debug.Log("========NO WALL========");
                break;
            }
        }

        // Determine if this room is the room with the goal - 80% chance it is not
        if (Random.value > 0.8f && !hasEnd && canSpawnEnemies)
        {
            Vector3 endRoom = roomTrans.position;
            endRoom.y += 10.0f;
            LevelSwitcher ls = Instantiate(levelEnd, endRoom, Quaternion.identity);
            ls.TheEnd = true;
            hasEnd    = true;
        }

        // Add placed room to list of placed room
        placedRooms.Add(roomTrans.position);
    }
 public void OnPointerClick(PointerEventData eventData)
 {
     AudioProvider.getInstance().playAudio("Standard Button");
     LevelSwitcher.loadLevel(id);
 }
Esempio n. 11
0
 void Awake()
 {
     levelSwitcher = this;
             image = GetComponent<RawImage> ();
 }
Esempio n. 12
0
 void Awake()
 {
     levelSwitcher = this;
     image         = GetComponent <RawImage>();
 }