Advertisement
Guest User

LevelManager

a guest
Jun 25th, 2016
149
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 3.57 KB | None | 0 0
  1. public int numEasyRooms = 3;
  2.     public int numObjectsGroupPerEnemyGroup = 3;
  3.     public List<GameObject> floor1Enemies;
  4.     public List<GameObject> floor1Objects;
  5.     public List<GameObject> floor1EnemiesHard;
  6.     public List<GameObject> floor1ObjectsHard;
  7.     public List<GameObject> floor1BonusObjects;
  8.     public List<GameObject> tutorialEnemies;
  9.     public GameObject tutorialObjects;
  10.     public GameObject floor1BossEnemies;
  11.     public GameObject floor1BossObjects;
  12.  
  13.     private int lastLevelIndex = 100;
  14.     private int ranObjectIndex = 100;
  15.  
  16.     [HideInInspector]
  17.     public int numRoomsCleared = 0;
  18.  
  19.     // Use this for initialization
  20.     void Start () {
  21.    
  22.     }
  23.  
  24.     public void LoadCurrentLevel(int floor, string roomType)
  25.     {
  26.         if (roomType == "Normal Room" && numRoomsCleared > 0)
  27.         {
  28.             GameObject enemyGroup;
  29.             GameObject objects;
  30.             List<GameObject> floorEnemyGroup = new List<GameObject>();
  31.             List<GameObject> FloorObjectGroups = new List<GameObject>();
  32.  
  33.             /////Spawn easy enemies and objects
  34.             if (numRoomsCleared < numEasyRooms)
  35.             {
  36.                 floorEnemyGroup = GetFloorEnemyGroups(floor, false);
  37.                 FloorObjectGroups = GetFloorObjectGroups(floor, false);
  38.             }
  39.             //Spawn hard enemies and objects
  40.             else
  41.             {
  42.                 floorEnemyGroup = GetFloorEnemyGroups(floor, true);
  43.                 FloorObjectGroups = GetFloorObjectGroups(floor, true);
  44.             }
  45.  
  46.             while (ranObjectIndex == lastLevelIndex)
  47.                 ranObjectIndex = Random.Range(0, floor1Objects.Count);
  48.  
  49.             objects = FloorObjectGroups[ranObjectIndex];
  50.  
  51.             //This is for when we have more layouts for each level
  52.             int startingObjectIndex = ranObjectIndex * numObjectsGroupPerEnemyGroup;
  53.             enemyGroup = floorEnemyGroup[Random.Range(startingObjectIndex, startingObjectIndex + numObjectsGroupPerEnemyGroup + 1)];
  54.  
  55.             GameManager.instance.objectSpawner.SpawnObjects(objects);
  56.             GameManager.instance.enemySpawner.SpawnEnemies(enemyGroup);
  57.             lastLevelIndex = ranObjectIndex;
  58.         }
  59.         else if (floor == 1) //If first level spawn tutoral
  60.         {
  61.             GameManager.instance.gameStates.inTutorial = true;
  62.  
  63.             List<GameObject> tutorialEnemyGroup = tutorialEnemies;
  64.             int ranEnemyIndex = Random.Range(0, tutorialEnemyGroup.Count);
  65.  
  66.             GameManager.instance.objectSpawner.SpawnObjects(tutorialObjects);
  67.             GameManager.instance.enemySpawner.SpawnEnemies(tutorialEnemyGroup[ranEnemyIndex]);
  68.         }
  69.  
  70.         if (roomType == "Boss Room")
  71.         {
  72.             GameManager.instance.enemySpawner.SpawnEnemies(GetFloorBoss(floor));
  73.             GameManager.instance.objectSpawner.SpawnObjects(GetBossObjects(floor));
  74.         }
  75.  
  76.    
  77.     }
  78.  
  79.     List<GameObject> GetFloorEnemyGroups (int floor, bool hard)
  80.     {
  81.         List<GameObject> floorEnemyGroups = new List<GameObject>();
  82.         switch (floor)
  83.         {
  84.             case 1:
  85.                 if (hard)
  86.                     floorEnemyGroups = floor1EnemiesHard;
  87.                 else
  88.                     floorEnemyGroups = floor1Enemies;
  89.                 break;
  90.         }
  91.  
  92.         return floorEnemyGroups;
  93.     }
  94.  
  95.     List<GameObject> GetFloorObjectGroups(int floor, bool hard)
  96.     {
  97.         List<GameObject> floorObjectGroups = new List<GameObject>();
  98.         switch (floor)
  99.         {
  100.             case 1:
  101.                 if (hard)
  102.                     floorObjectGroups = floor1ObjectsHard;
  103.                 else
  104.                     floorObjectGroups = floor1Objects;
  105.                 break;
  106.         }
  107.  
  108.         return floorObjectGroups;
  109.     }
  110.  
  111.     GameObject GetFloorBoss(int floor)
  112.     {
  113.         GameObject floorBossGroup = new GameObject();
  114.         switch (floor)
  115.         {
  116.             case 1:
  117.                 floorBossGroup = floor1BossEnemies;
  118.                 break;
  119.         }
  120.  
  121.         return floorBossGroup;
  122.     }
  123.  
  124.     GameObject GetBossObjects(int floor)
  125.     {
  126.         GameObject BossObjectsGroup = new GameObject();
  127.         switch (floor)
  128.         {
  129.             case 1:
  130.                 BossObjectsGroup = floor1BossObjects;
  131.                 break;
  132.         }
  133.  
  134.         return BossObjectsGroup;
  135.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement