Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public int numEasyRooms = 3;
- public int numObjectsGroupPerEnemyGroup = 3;
- public List<GameObject> floor1Enemies;
- public List<GameObject> floor1Objects;
- public List<GameObject> floor1EnemiesHard;
- public List<GameObject> floor1ObjectsHard;
- public List<GameObject> floor1BonusObjects;
- public List<GameObject> tutorialEnemies;
- public GameObject tutorialObjects;
- public GameObject floor1BossEnemies;
- public GameObject floor1BossObjects;
- private int lastLevelIndex = 100;
- private int ranObjectIndex = 100;
- [HideInInspector]
- public int numRoomsCleared = 0;
- // Use this for initialization
- void Start () {
- }
- public void LoadCurrentLevel(int floor, string roomType)
- {
- if (roomType == "Normal Room" && numRoomsCleared > 0)
- {
- GameObject enemyGroup;
- GameObject objects;
- List<GameObject> floorEnemyGroup = new List<GameObject>();
- List<GameObject> FloorObjectGroups = new List<GameObject>();
- /////Spawn easy enemies and objects
- if (numRoomsCleared < numEasyRooms)
- {
- floorEnemyGroup = GetFloorEnemyGroups(floor, false);
- FloorObjectGroups = GetFloorObjectGroups(floor, false);
- }
- //Spawn hard enemies and objects
- else
- {
- floorEnemyGroup = GetFloorEnemyGroups(floor, true);
- FloorObjectGroups = GetFloorObjectGroups(floor, true);
- }
- while (ranObjectIndex == lastLevelIndex)
- ranObjectIndex = Random.Range(0, floor1Objects.Count);
- objects = FloorObjectGroups[ranObjectIndex];
- //This is for when we have more layouts for each level
- int startingObjectIndex = ranObjectIndex * numObjectsGroupPerEnemyGroup;
- enemyGroup = floorEnemyGroup[Random.Range(startingObjectIndex, startingObjectIndex + numObjectsGroupPerEnemyGroup + 1)];
- GameManager.instance.objectSpawner.SpawnObjects(objects);
- GameManager.instance.enemySpawner.SpawnEnemies(enemyGroup);
- lastLevelIndex = ranObjectIndex;
- }
- else if (floor == 1) //If first level spawn tutoral
- {
- GameManager.instance.gameStates.inTutorial = true;
- List<GameObject> tutorialEnemyGroup = tutorialEnemies;
- int ranEnemyIndex = Random.Range(0, tutorialEnemyGroup.Count);
- GameManager.instance.objectSpawner.SpawnObjects(tutorialObjects);
- GameManager.instance.enemySpawner.SpawnEnemies(tutorialEnemyGroup[ranEnemyIndex]);
- }
- if (roomType == "Boss Room")
- {
- GameManager.instance.enemySpawner.SpawnEnemies(GetFloorBoss(floor));
- GameManager.instance.objectSpawner.SpawnObjects(GetBossObjects(floor));
- }
- }
- List<GameObject> GetFloorEnemyGroups (int floor, bool hard)
- {
- List<GameObject> floorEnemyGroups = new List<GameObject>();
- switch (floor)
- {
- case 1:
- if (hard)
- floorEnemyGroups = floor1EnemiesHard;
- else
- floorEnemyGroups = floor1Enemies;
- break;
- }
- return floorEnemyGroups;
- }
- List<GameObject> GetFloorObjectGroups(int floor, bool hard)
- {
- List<GameObject> floorObjectGroups = new List<GameObject>();
- switch (floor)
- {
- case 1:
- if (hard)
- floorObjectGroups = floor1ObjectsHard;
- else
- floorObjectGroups = floor1Objects;
- break;
- }
- return floorObjectGroups;
- }
- GameObject GetFloorBoss(int floor)
- {
- GameObject floorBossGroup = new GameObject();
- switch (floor)
- {
- case 1:
- floorBossGroup = floor1BossEnemies;
- break;
- }
- return floorBossGroup;
- }
- GameObject GetBossObjects(int floor)
- {
- GameObject BossObjectsGroup = new GameObject();
- switch (floor)
- {
- case 1:
- BossObjectsGroup = floor1BossObjects;
- break;
- }
- return BossObjectsGroup;
- }
Advertisement
Add Comment
Please, Sign In to add comment