Example #1
0
    public static void RecordHighScore()
    {
        int score      = 0;
        int numPlayers = 0;

        for (int i = 0; i < DynamicData.MAX_PLAYERS; ++i)
        {
            SessionPlayer p = DynamicData.GetSessionPlayer(i);
            if (p.HasJoined)
            {
                ++numPlayers;
                score += ProgressData.GetPointsForPlayer(i);
            }
        }

        numPlayers = Mathf.Max(ProgressData.MostPlayersUsed, numPlayers);

        if (numPlayers > 1)
        {
            if (score > _highScoreCoop)
            {
                _highScoreCoop = score;
            }
        }
        else
        {
            if (score > _highScoreSinglePlayer)
            {
                _highScoreSinglePlayer = score;
            }
        }
    }
Example #2
0
 void Update()
 {
     if (this.AllowReassignment && !PauseController.IsPaused())
     {
         for (int i = 0; i < DynamicData.MAX_PLAYERS; ++i)
         {
             SessionPlayer p = DynamicData.GetSessionPlayer(i);
             if (!p.HasJoined)
             {
                 // Assignment
                 foreach (Player rewiredPlayer in ReInput.players.Players)
                 {
                     if (!rewiredPlayer.isPlaying && rewiredPlayer.GetButtonDown(JOIN_ACTION))
                     {
                         joinPlayer(p, rewiredPlayer);
                         break;
                     }
                 }
             }
             else
             {
                 // Unassignment
                 if (ReInput.players.GetPlayer(p.RewiredId).GetButtonDown(MenuInput.EXIT))
                 {
                     //TODO - Should be checking if button held rather than just pressed
                     dropPlayer(p);
                 }
             }
         }
     }
 }
Example #3
0
    private void spawnSimple(int enemiesSpawned, LevelGenOutput output, int[] guaranteedEnemiesPlaced, EnemySelector enemySelector, int difficulty, List <LevelGenMap.Coordinate> openTiles, bool spawnPlayers)
    {
        // Guaranteed enemies
        for (int i = 0; i < output.Input.GuaranteedEnemiesByDifficulty.Length; ++i)
        {
            while (guaranteedEnemiesPlaced[i] < output.Input.GuaranteedEnemiesByDifficulty[i])
            {
                int enemyId = enemySelector.ChooseEnemyOfDifficulty(i);
                guaranteedEnemiesPlaced[i] = guaranteedEnemiesPlaced[i] + 1;
                ++enemiesSpawned;
                _enemySpawns.Add(new EnemySpawnGroup(findGoodOpenPosition(openTiles, output.Input.MinDistanceBetweenSpawns).integerVector, enemyId));
            }
        }

        // Remaining enemies
        for (; enemiesSpawned < this.NumEnemies; ++enemiesSpawned)
        {
            int enemyId = enemySelector.ChooseEnemy(difficulty);
            _enemySpawns.Add(new EnemySpawnGroup(findGoodOpenPosition(openTiles, output.Input.MinDistanceBetweenSpawns).integerVector, enemyId));
        }

        // Players
        if (spawnPlayers)
        {
            bool first = true;
            List <LevelGenMap.Coordinate> tiles = openTiles;
            for (int i = 0; i < DynamicData.MAX_PLAYERS; ++i)
            {
                if (DynamicData.GetSessionPlayer(i).HasJoined)
                {
                    LevelGenMap.Coordinate playerSpawn = findGoodOpenPosition(tiles, 0);
                    _playerSpawns.Add(playerSpawn.integerVector);

                    if (first)
                    {
                        first = false;
                        List <LevelGenMap.Coordinate> nearbySpawns = new List <LevelGenMap.Coordinate>();
                        foreach (LevelGenMap.Coordinate coord in openTiles)
                        {
                            if (Mathf.Abs(coord.x - playerSpawn.x) + Mathf.Abs(coord.y - playerSpawn.y) <= this.MaxPlayerSpawnDistance)
                            {
                                nearbySpawns.Add(coord);
                            }
                        }

                        if (nearbySpawns.Count >= DynamicData.MAX_PLAYERS)
                        {
                            tiles = nearbySpawns;
                        }
                    }
                    else
                    {
                        openTiles.Remove(playerSpawn);
                    }
                }
            }
        }
    }
Example #4
0
 void Start()
 {
     if (DynamicData.GetSessionPlayer(this.PlayerIndex).HasJoined)
     {
         this.UpdateLength(ProgressData.GetHealthForPlayer(this.PlayerIndex), ProgressData.MAX_HEALTH);
         GlobalEvents.Notifier.Listen(PlayerPointsReceivedEvent.NAME, this, pointsReceived);
         GlobalEvents.Notifier.Listen(PlayerSpawnedEvent.NAME, this, playerSpawned);
     }
 }
Example #5
0
    private void pointsReceived(LocalEventNotifier.Event e)
    {
        SessionPlayer player = DynamicData.GetSessionPlayer(this.PlayerIndex);

        if (player.HasJoined && player.PlayerIndex == ((PlayerPointsReceivedEvent)e).PlayerIndex)
        {
            this.UpdateLength(ProgressData.GetHealthForPlayer(this.PlayerIndex), ProgressData.MAX_HEALTH);
        }
    }
Example #6
0
    private bool findBSPCAComboSpawns(LevelGenOutput output)
    {
        List <LevelGenMap.Coordinate> openTiles = new List <LevelGenMap.Coordinate>(output.OpenTiles);

        openTiles.Shuffle();
        EnemySelector enemySelector = new EnemySelector();

        int           difficulty      = ProgressData.GetCurrentDifficulty();
        IntegerVector enemyCountRange = output.Input.GetCurrentNumEnemiesRange();

        int[] guaranteedEnemiesPlaced = new int[output.Input.GuaranteedEnemiesByDifficulty.Length];
        this.NumEnemies = Random.Range(enemyCountRange.X, enemyCountRange.Y + 1);
        LevelGenCaveInfo caveInfo = output.MapInfo[LevelGenCaveInfo.KEY] as LevelGenCaveInfo;

        if (ProgressData.IsMiniBoss(ProgressData.MostRecentTile))
        {
            findMinibossSpawn(openTiles, (caveInfo.Data as List <List <LevelGenMap.Coordinate> >)[0]);
        }

        LevelGenRoomInfo roomInfo = output.MapInfo[LevelGenRoomInfo.KEY] as LevelGenRoomInfo;

        List <SimpleRect> availableRooms = new List <SimpleRect>(roomInfo.Data as List <SimpleRect>);

        availableRooms.Shuffle();

        // Player room
        SimpleRect playerRoom = availableRooms[availableRooms.Count - 1];

        availableRooms.RemoveAt(availableRooms.Count - 1);
        List <LevelGenMap.Coordinate> playerRoomCoords = coordinatesInRoom(playerRoom);

        openTiles.RemoveList(playerRoomCoords);
        playerRoomCoords.Shuffle();

        for (int p = 0; p < DynamicData.MAX_PLAYERS; ++p)
        {
            if (DynamicData.GetSessionPlayer(p).HasJoined)
            {
                _playerSpawns.Add(playerRoomCoords[playerRoomCoords.Count - 1].integerVector);
                playerRoomCoords.RemoveAt(playerRoomCoords.Count - 1);
            }
        }

        if (openTiles.Count <= (this.NumEnemies + DynamicData.MAX_PLAYERS) * output.Input.MinDistanceBetweenSpawns * 2 + 1)
        {
            Debug.Log("Regeneration necessary - CA");
            return(false);
        }
        else
        {
            spawnSimple(0, output, guaranteedEnemiesPlaced, enemySelector, difficulty, openTiles, false);
        }
        return(true);
    }
Example #7
0
    public static Vector2 GetMovementAxis(int playerIndex, bool normalized = false)
    {
        SessionPlayer p    = DynamicData.GetSessionPlayer(playerIndex);
        Vector2       axis = ReInput.players.GetPlayer(p.RewiredId).GetAxis2D(MOVE_HORIZONTAL, MOVE_VERTICAL);

        if (normalized)
        {
            axis.Normalize();
        }
        return(axis);
    }
Example #8
0
    private void pointsReceived(LocalEventNotifier.Event e)
    {
        SessionPlayer player = DynamicData.GetSessionPlayer(this.PlayerIndex);

        if (player.HasJoined && player.PlayerIndex == ((PlayerPointsReceivedEvent)e).PlayerIndex)
        {
            for (int i = 0; i < this.Slots.Length; ++i)
            {
                this.Slots[i].UpdateWithSessionPlayer(player);
            }
        }
    }
Example #9
0
    void Start()
    {
        SessionPlayer p = DynamicData.GetSessionPlayer(this.PlayerIndex);

        if (p.HasJoined)
        {
            controllerAssigned(p);
        }
        else
        {
            controllerUnassigned(p);
        }
    }
Example #10
0
 void Start()
 {
     _sessionPlayer = DynamicData.GetSessionPlayer(this.PlayerIndex);
     if (!_sessionPlayer.HasJoined)
     {
         this.HasReadied = true;
     }
     else
     {
         _rewiredPlayer = ReInput.players.GetPlayer(_sessionPlayer.RewiredId);
     }
     GlobalEvents.Notifier.Listen(PlayerPointsReceivedEvent.NAME, this, regenSmartSlots);
 }
Example #11
0
    private void levelComplete(LocalEventNotifier.Event e)
    {
        for (int i = 0; i < _playerControllers.Length; ++i)
        {
            PlayerController           playerController = _playerControllers[i];
            ProgressData.SlotWrapper[] slots            = playerController != null?playerController.Slots.ToArray() : new ProgressData.SlotWrapper[0];

            ProgressData.UpdatePlayerSlots(i, slots);
            if (DynamicData.GetSessionPlayer(i).HasJoined)
            {
                ProgressData.SetHealthForPlayer(i, playerController != null ? playerController.GetComponent <Damagable>().Health : 0);
            }
        }
    }
Example #12
0
    private void playerSpawned(LocalEventNotifier.Event e)
    {
        PlayerSpawnedEvent playerSpawnedEvent = e as PlayerSpawnedEvent;

        if (playerSpawnedEvent.PlayerIndex == this.PlayerIndex)
        {
            SessionPlayer p = DynamicData.GetSessionPlayer(this.PlayerIndex);
            if (p.HasJoined && !ReInput.players.GetPlayer(p.RewiredId).controllers.hasMouse)
            {
                _player           = p;
                _playerController = playerSpawnedEvent.PlayerObject.GetComponent <PlayerController>();
                _playerController.SetUsingController();
            }
        }
    }
Example #13
0
    public void SpawnPlayers()
    {
        int playerIndex = 0;

        foreach (IntegerVector position in _playerSpawns)
        {
            GameObject player = Instantiate(this.PlayerPrefab, new Vector3(position.X * _tileRenderer.TileRenderSize, position.Y * _tileRenderer.TileRenderSize, this.transform.position.z), Quaternion.identity) as GameObject;
            if (_tileRenderer.OffsetTilesToCenter)
            {
                player.transform.position = new Vector3(player.transform.position.x - _tileRenderer.TileRenderSize * _tileRenderer.Width / 2, player.transform.position.y - _tileRenderer.TileRenderSize * _tileRenderer.Height / 2, player.transform.position.z);
            }

            _targets.Add(player.transform);

            for (; playerIndex < DynamicData.MAX_PLAYERS; ++playerIndex)
            {
                if (DynamicData.GetSessionPlayer(playerIndex).HasJoined)
                {
                    break;
                }
            }
            player.GetComponent <PlayerController>().PlayerIndex = playerIndex;
            if (this.PlayerInteractionDelay > 0.0f)
            {
                player.GetComponent <PlayerController>().SetInteractionDelay(this.PlayerInteractionDelay);
            }

            GlobalEvents.Notifier.SendEvent(new PlayerSpawnedEvent(player, playerIndex));
            ++playerIndex;
        }

        /*if (this.PickupPrefabs.Length > 0)
         * {
         *  for (int i = 0; i < this.NumPickups; ++i)
         *  {
         *      IntegerVector position = _spawnPositions[_spawnPositions.Count - 1];
         *      GameObject prefab = this.PickupPrefabs[Random.Range(0, this.PickupPrefabs.Length)];
         *      GameObject pickup = Instantiate(prefab, new Vector3(position.X, position.Y, this.transform.position.z), Quaternion.identity) as GameObject;
         *
         *      if (_tileRenderer.OffsetTilesToCenter)
         *          pickup.transform.position = new Vector3(pickup.transform.position.x - _tileRenderer.TileRenderSize * _tileRenderer.Width / 2, pickup.transform.position.y - _tileRenderer.TileRenderSize * _tileRenderer.Height / 2, pickup.transform.position.z);
         *
         *      _spawnPositions.RemoveAt(_spawnPositions.Count - 1);
         *  }
         * }*/
    }
Example #14
0
    public static bool AnyPlayerButtonPressed(string buttonName)
    {
        int numJoined = 0;

        for (int i = 0; i < DynamicData.MAX_PLAYERS; ++i)
        {
            SessionPlayer p = DynamicData.GetSessionPlayer(i);
            if (p.HasJoined)
            {
                ++numJoined;
                if (!ReInput.players.GetPlayer(p.RewiredId).GetButtonDown(buttonName))
                {
                    return(false);
                }
            }
        }
        return(numJoined > 0);
    }
Example #15
0
    void Start()
    {
        SessionPlayer player = DynamicData.GetSessionPlayer(this.PlayerIndex);

        if (player.HasJoined)
        {
            for (int i = 0; i < this.Slots.Length; ++i)
            {
                this.Slots[i].UpdateWithSessionPlayer(player);
            }
            GlobalEvents.Notifier.Listen(PlayerPointsReceivedEvent.NAME, this, pointsReceived);
            GlobalEvents.Notifier.Listen(PlayerSpawnedEvent.NAME, this, playerSpawned);
        }
        else
        {
            this.gameObject.SetActive(false);
        }
    }
Example #16
0
    void Start()
    {
        if (this.PlayerIndex >= 0)
        {
            if (!DynamicData.GetSessionPlayer(this.PlayerIndex).HasJoined)
            {
                this.PlayerIndex = -1;
            }
            else
            {
                GlobalEvents.Notifier.Listen(PlayerSpawnedEvent.NAME, this, playerSpawned);
            }
        }

        if (this.PlayerIndex == -1)
        {
            this.Spawner.Targets = PlayerTargetController.Targets;
            Spawner.BeginSpawn();
        }
    }
Example #17
0
    void Start()
    {
        if (this.AssignFirstPlayerOnStart)
        {
            SessionPlayer p1 = DynamicData.GetSessionPlayer(0);
            if (!p1.HasJoined)
            {
                // Find most recent active input and join p1 with it
                Player lastActive     = null;
                float  lastActiveTime = 0.0f;
                foreach (Player p in ReInput.players.Players)
                {
                    Controller c           = p.controllers.GetLastActiveController();
                    float      cActiveTime = c != null?c.GetLastTimeActive() : lastActiveTime;

                    if (cActiveTime > lastActiveTime || (lastActive == null && (p.controllers.hasMouse || p.controllers.joystickCount != 0)))
                    {
                        lastActiveTime = cActiveTime;
                        lastActive     = p;
                    }
                }

                // Only join if this input isn't already joined with another player
                if (DynamicData.GetSessionPlayerByRewiredId(lastActive.id) == null)
                {
                    joinPlayer(p1, lastActive);
                }
            }
        }

        if (this.DisableMenuInputForUnjoinedPlayers || this.EnableMenuInputForUnjoinedPlayers)
        {
            foreach (Player rewiredP in ReInput.players.Players)
            {
                if (DynamicData.GetSessionPlayerByRewiredId(rewiredP.id) == null)
                {
                    rewiredP.controllers.maps.SetMapsEnabled(this.EnableMenuInputForUnjoinedPlayers, MenuInput.MENU_CATEGORY);
                }
            }
        }
    }
Example #18
0
    public static Vector2 GetAimingAxis(int playerIndex, Vector2 playerWorldPosition, bool normalized = true)
    {
        SessionPlayer p        = DynamicData.GetSessionPlayer(playerIndex);
        Player        rewiredP = ReInput.players.GetPlayer(p.RewiredId);
        Vector2       axis;

        if (rewiredP.controllers.hasMouse)
        {
            Vector2 playerScreenPosition = Camera.main.WorldToScreenPoint(playerWorldPosition);
            axis = rewiredP.controllers.Mouse.screenPosition - playerScreenPosition;

            if (!normalized)
            {
                float maxMouseExtension = MAX_MOUSE_EXTENSION_RATIO * Screen.width;
                if (axis.magnitude > maxMouseExtension)
                {
                    axis = axis.normalized * maxMouseExtension;
                }
                axis /= maxMouseExtension;
            }
        }
        else
        {
            axis = rewiredP.GetAxis2D(AIM_HORIZONTAL, AIM_VERTICAL);
            if (axis.magnitude < AIM_DEAD)
            {
                axis = Vector2.zero;
            }

            /*if (Mathf.Abs(axis.x) < AIM_DEAD)
             *  axis.x = 0;
             * if (Mathf.Abs(axis.y) < AIM_DEAD)
             *  axis.y = 0;*/
        }

        if (normalized)
        {
            axis.Normalize();
        }
        return(axis);
    }
Example #19
0
    /**
     * Private
     */
    private static bool checkButton(string buttonName, int playerIndex)
    {
        if (playerIndex < 0)
        {
            foreach (Player player in ReInput.players.GetPlayers())
            {
                if (player.GetButtonDown(buttonName))
                {
                    return(true);
                }
            }
            return(false);
        }

        SessionPlayer sessionPlayer = DynamicData.GetSessionPlayer(playerIndex);

        if (sessionPlayer == null || !sessionPlayer.HasJoined)
        {
            return(false);
        }

        return(ReInput.players.GetPlayer(sessionPlayer.RewiredId).GetButtonDown(buttonName));
    }
Example #20
0
    void Update()
    {
        if (!_setup)
        {
            for (int i = 0; i < DynamicData.MAX_PLAYERS; ++i)
            {
                SessionPlayer p = DynamicData.GetSessionPlayer(i);
                if (p.HasJoined)
                {
                    if (ReInput.players.GetPlayer(p.RewiredId).controllers.hasMouse)
                    {
                        _player = p;
                        AllegianceColorizer colorizer = this.GetComponent <AllegianceColorizer>();
                        AllegianceInfo      info      = colorizer.AllegianceInfo;
                        info.MemberId = i;
                        colorizer.UpdateVisual(info);
                        break;
                    }
                }
            }
            _setup = true;
        }

        if (_player != null)
        {
            if (PauseController.IsPaused())
            {
                _rectTransform.position = new Vector3(-99999, -99999, _rectTransform.position.z);
            }
            else
            {
                Player  rewiredP  = ReInput.players.GetPlayer(_player.RewiredId);
                Vector2 screenPos = rewiredP.controllers.Mouse.screenPosition;
                _rectTransform.position = new Vector3(screenPos.x, screenPos.y, _rectTransform.position.z);
            }
        }
    }
Example #21
0
    public void SpawnPlayers()
    {
        int t = 0;

        for (int p = 0; p < DynamicData.MAX_PLAYERS; ++p)
        {
            SessionPlayer player = DynamicData.GetSessionPlayer(p);
            if (player.HasJoined)
            {
                while (t < this.PlayerSpawns.Length && this.PlayerSpawns[t] == null)
                {
                    ++t;
                }
                if (t < this.PlayerSpawns.Length)
                {
                    spawnPlayer(player, this.PlayerSpawns[t]);
                }
                else
                {
                    break;
                }
            }
        }
    }
Example #22
0
    public static bool GetFireButton(int playerIndex)
    {
        SessionPlayer p = DynamicData.GetSessionPlayer(playerIndex);

        return(ReInput.players.GetPlayer(p.RewiredId).GetButton(FIRE));
    }
Example #23
0
    private bool findBSPSpawns(LevelGenOutput output)
    {
        List <LevelGenMap.Coordinate> openTiles = new List <LevelGenMap.Coordinate>(output.OpenTiles);

        openTiles.Shuffle();

        LevelGenRoomInfo roomInfo        = output.MapInfo[LevelGenRoomInfo.KEY] as LevelGenRoomInfo;
        EnemySelector    enemySelector   = new EnemySelector();
        IntegerVector    enemyCountRange = output.Input.GetCurrentNumEnemiesRange();

        this.NumEnemies = Random.Range(enemyCountRange.X, enemyCountRange.Y + 1);

        if (ProgressData.IsMiniBoss(ProgressData.MostRecentTile))
        {
            findMinibossSpawn(openTiles, openTiles);
        }

        int difficulty = ProgressData.GetCurrentDifficulty();

        int[] guaranteedEnemiesPlaced = new int[output.Input.GuaranteedEnemiesByDifficulty.Length];
        int   totalGuarantees         = 0;

        for (int i = 0; i < guaranteedEnemiesPlaced.Length; ++i)
        {
            totalGuarantees += output.Input.GuaranteedEnemiesByDifficulty[i];
        }

        if (openTiles.Count <= (this.NumEnemies + DynamicData.MAX_PLAYERS) * output.Input.MinDistanceBetweenSpawns * 2 + 1 ||
            roomInfo == null || roomInfo.Data.Count < 4 + difficulty)
        {
            Debug.Log("Regeneration necessary - BSP 1");
            return(false);
        }
        else
        {
            List <SimpleRect> availableRooms = new List <SimpleRect>(roomInfo.Data as List <SimpleRect>);
            availableRooms.Shuffle();

            // Player room
            SimpleRect playerRoom = availableRooms[availableRooms.Count - 1];
            availableRooms.RemoveAt(availableRooms.Count - 1);
            List <LevelGenMap.Coordinate> playerRoomCoords = coordinatesInRoom(playerRoom);
            openTiles.RemoveList(playerRoomCoords);
            playerRoomCoords.Shuffle();

            for (int p = 0; p < DynamicData.MAX_PLAYERS; ++p)
            {
                if (DynamicData.GetSessionPlayer(p).HasJoined)
                {
                    _playerSpawns.Add(playerRoomCoords[playerRoomCoords.Count - 1].integerVector);
                    playerRoomCoords.RemoveAt(playerRoomCoords.Count - 1);
                }
            }

            if (openTiles.Count <= this.NumEnemies * output.Input.MinDistanceBetweenSpawns * 2 + 1)
            {
                Debug.Log("Regeneration necessary - BSP 2");
                return(false);
            }
            else
            {
                int  enemiesSpawned          = 0;
                int  guaranteesSpawned       = 0;
                bool haveUnitedAllRoomsSoFar = true;

                // Enemy rooms
                for (int r = 0; r < availableRooms.Count; ++r)
                {
                    SimpleRect room = availableRooms[r];
                    if (this.NumEnemies - enemiesSpawned < 4 || (r == availableRooms.Count - 1 && haveUnitedAllRoomsSoFar && guaranteesSpawned < totalGuarantees))
                    {
                        break;
                    }
                    if (Random.value > 0.65f)
                    {
                        haveUnitedAllRoomsSoFar = false;
                        continue;
                    }

                    List <EnemySpawn> roomSpawns = new List <EnemySpawn>();

                    EnemySelector.WeightSet roomWeightSet = new EnemySelector.WeightSet();
                    enemySelector.AddWeightSet(roomWeightSet);

                    // United-spawn room
                    int favoredEnemyId = pickMaybeGuaranteedEnemy(guaranteesSpawned, totalGuarantees, enemiesSpawned, difficulty, guaranteedEnemiesPlaced, output, enemySelector);

                    roomWeightSet.WeightsByEnemyId[favoredEnemyId] = 100;

                    List <IntegerVector> roomCorners = new List <IntegerVector>();
                    roomCorners.Add(new IntegerVector(room.X, room.Y));
                    roomCorners.Add(new IntegerVector(room.X + room.Width, room.Y));
                    roomCorners.Add(new IntegerVector(room.X, room.Y + room.Height));
                    roomCorners.Add(new IntegerVector(room.X + room.Width, room.Y + room.Height));
                    roomCorners.Shuffle();

                    IntegerVector firstPosition = roomCorners[roomCorners.Count - 1];
                    ++enemiesSpawned;
                    roomSpawns.Add(new EnemySpawn(firstPosition, favoredEnemyId));
                    roomCorners.RemoveAt(roomCorners.Count - 1);
                    int enemyDifficulty = StaticData.EnemyData.EnemyTypes[favoredEnemyId].Difficulty;
                    if (guaranteedEnemiesPlaced[enemyDifficulty] < output.Input.GuaranteedEnemiesByDifficulty[enemyDifficulty])
                    {
                        guaranteedEnemiesPlaced[enemyDifficulty] += 1;
                        ++guaranteesSpawned;
                    }

                    foreach (IntegerVector position in roomCorners)
                    {
                        ++enemiesSpawned;
                        int enemyId = enemySelector.ChooseEnemy(difficulty);
                        roomSpawns.Add(new EnemySpawn(position, enemyId));
                        enemyDifficulty = StaticData.EnemyData.EnemyTypes[enemyId].Difficulty;
                        if (guaranteedEnemiesPlaced[enemyDifficulty] < output.Input.GuaranteedEnemiesByDifficulty[enemyDifficulty])
                        {
                            guaranteedEnemiesPlaced[enemyDifficulty] += 1;
                            ++guaranteesSpawned;
                        }
                    }

                    bool extraTwo = false;
                    if (this.NumEnemies - enemiesSpawned > 2 && Random.value < CHANCE_FOR_EXTRA_TWO_IN_BSP_ROOM)
                    {
                        // Let's add 2 along the walls of the longest room dimension
                        extraTwo       = true;
                        favoredEnemyId = pickMaybeGuaranteedEnemy(guaranteesSpawned, totalGuarantees, enemiesSpawned, difficulty, guaranteedEnemiesPlaced, output, enemySelector);
                        roomWeightSet.WeightsByEnemyId[favoredEnemyId] = 100;

                        IntegerVector position1;
                        IntegerVector position2;
                        if (room.Width > room.Height)
                        {
                            position1 = new IntegerVector(room.X + room.Width / 2, room.Y);
                            position2 = new IntegerVector(room.X + room.Width / 2, room.Y + room.Height);
                        }
                        else
                        {
                            position1 = new IntegerVector(room.X, room.Y + room.Height / 2);
                            position2 = new IntegerVector(room.X + room.Width, room.Y + room.Height / 2);
                        }

                        enemiesSpawned += 2;
                        roomSpawns.Add(new EnemySpawn(position1, favoredEnemyId));
                        enemyDifficulty = StaticData.EnemyData.EnemyTypes[favoredEnemyId].Difficulty;
                        if (guaranteedEnemiesPlaced[enemyDifficulty] < output.Input.GuaranteedEnemiesByDifficulty[enemyDifficulty])
                        {
                            guaranteedEnemiesPlaced[enemyDifficulty] += 1;
                            ++guaranteesSpawned;
                        }

                        int enemyId = enemySelector.ChooseEnemy(difficulty);
                        roomSpawns.Add(new EnemySpawn(position2, enemyId));
                        enemyDifficulty = StaticData.EnemyData.EnemyTypes[enemyId].Difficulty;
                        if (guaranteedEnemiesPlaced[enemyDifficulty] < output.Input.GuaranteedEnemiesByDifficulty[enemyDifficulty])
                        {
                            guaranteedEnemiesPlaced[enemyDifficulty] += 1;
                            ++guaranteesSpawned;
                        }
                    }

                    _enemySpawns.Add(new EnemySpawnGroup(new IntegerVector(room.X + room.Width / 2, room.Y + room.Height / 2), roomSpawns, ((Mathf.Max(room.Width, room.Height) + 2.6f) / 2.0f) * _tileRenderer.TileRenderSize));

                    if (!enemySelector.RemoveWeightSet(roomWeightSet))
                    {
                        Debug.Log("hrrmmmm");
                    }

                    if (extraTwo || Random.value < CHANCE_FOR_REMOVE_SPAWN_ROOM_FOR_FUTURE_BSP)
                    {
                        openTiles.RemoveList(coordinatesInRoom(room));
                    }
                }

                // Non united-room spawns
                spawnSimple(enemiesSpawned, output, guaranteedEnemiesPlaced, enemySelector, difficulty, openTiles, false);
            }
        }

        return(true);
    }