Exemplo n.º 1
0
    private void Awake()
    {
        _buttonControls = FindObjectOfType <ButtonControls>();
        _generateRooms  = FindObjectOfType <GenerateRooms>();

        winLeaveButton.onClick.AddListener(delegate { _buttonControls.ChangeScene("Main Menu"); });
        winReplayButton.onClick.AddListener(delegate { _buttonControls.ChangeScene("Create Rooms"); });
    }
Exemplo n.º 2
0
        public ManagerIsland(ManagerMouse managerMouse)
        {
            GenerateRooms generateRooms = new GenerateRooms();

            rooms = generateRooms.Rooms;

            for (int i = 0; i < rooms.Count; i++)
            {
                managerMap.Add(new ManagerMap(rooms[i]));
            }

            Functions.managerMap = CurrentMap();

            int[] min = new int[2] {
                3, rooms[0].rectangle.Width / 3
            };
            int[] max = new int[2] {
                rooms[0].rectangle.Height / 2 + rooms[0].rectangle.Height / 3, rooms[0].rectangle.Height
            };

            for (int i = 0; i < managerMap.Count; i++)
            {
                Warcraft.MAP_SIZE = rooms[i].rectangle.Width / Warcraft.TILE_SIZE;

                Vector2[] pos = { Vector2.Zero, Vector2.Zero };

                for (int j = 0; j < managerMap[i].FULL_MAP.Count; j++)
                {
                    for (int k = 0; k < managerMap[i].FULL_MAP[j].Count; k++)
                    {
                        if (managerMap[i].FULL_MAP[j][k].tileType != TileType.WATER && !managerMap[i].FULL_MAP[j][k].isWall && !managerMap[i].FULL_MAP[j][k].isWater)
                        {
                            if (pos[0] == Vector2.Zero)
                            {
                                pos[0] = managerMap[i].FULL_MAP[j][k].position;
                            }
                            else
                            {
                                pos[1] = managerMap[i].FULL_MAP[j][k].position;
                            }
                        }
                    }
                }

                for (int j = 0; j < 2; j++)
                {
                    Vector2 place = Functions.CleanHalfPosition(managerMap[i], pos[j]);
                    place = place + new Vector2(rooms[i].rectangle.X, rooms[i].rectangle.Y);

                    ManagerBuildings.goldMines.Add(new Buildings.Neutral.GoldMine((int)(place.X / Warcraft.TILE_SIZE), (int)(place.Y / Warcraft.TILE_SIZE), managerMouse, managerMap[i], null));
                }
            }
        }
    // Set references
    private void Awake()
    {
        // Validation on Serialize Fields
        //if (allyTempParent == null)
        //Debug.Log("allyTempParent was not initialized correctly in ProceduralGenerationContoller attached to " + this.name);

        // Validation on other Procedural Gen Scripts
        GameObject procGenContObj = this.gameObject;

        _genRoomsRef = procGenContObj.GetComponent <GenerateRooms>();
        if (_genRoomsRef == null)
        {
            Debug.Log("There was no GenerateRooms attached to " + procGenContObj.name);
        }
        _wallsGenRef = procGenContObj.GetComponent <GenerateWalls>();
        if (_wallsGenRef == null)
        {
            Debug.Log("There was no GenerateWalls attached to " + procGenContObj.name);
        }
        _stairsGenRef = procGenContObj.GetComponent <GenerateStairs>();
        if (_stairsGenRef == null)
        {
            Debug.Log("There was no GenerateStairs attached to " + procGenContObj.name);
        }
        _tilesGenRef = procGenContObj.GetComponent <GenerateTiles>();
        if (_tilesGenRef == null)
        {
            Debug.Log("There was no GenerateTiles attached to " + procGenContObj.name);
        }
        _safeRoomGenRef = procGenContObj.GetComponent <GenerateSafeRoom>();
        if (_safeRoomGenRef == null)
        {
            Debug.Log("There was no GenerateSafeRoom attached to " + procGenContObj.name);
        }
        _placeAlliesRef = procGenContObj.GetComponent <PlaceAllies>();
        if (_placeAlliesRef == null)
        {
            Debug.Log("There was no PlaceAllies attached to " + procGenContObj.name);
        }
        _enemiesGenRef = procGenContObj.GetComponent <GenerateEnemies>();
        if (_enemiesGenRef == null)
        {
            Debug.Log("There was no GenerateEnemies attached to " + procGenContObj.name);
        }
    }
Exemplo n.º 4
0
    public void Start()
    {
        stage = new GameObject("Stage");
        InitializeMaze();

        // Generate rooms
        GenerateRooms roomsGenerator = new GenerateRooms();
        Room          room           = new Room();

        roomsGenerator.CreateRooms(mazeCells, minRooms, maxRooms);
        room.PersonalizeRoom(mazeCells, floorMaterials);

        // Generate maze around the rooms to make corridors
        Maze maze = new MazeAlgorithm(mazeCells, size);

        maze.CreateMaze();

        // Spawn in enemies and the player
        Spawn sp = new Spawn();

        sp.SpawnEnemies(rows, columns, size, enemyPrefab, minEnemies, maxEnemies);
        sp.SpawnPlayer(playerPrefab);
    }