Advertisement
Wolvenspud

EW - levelManager

Oct 7th, 2017
140
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 2.47 KB | None | 0 0
  1. using UnityEngine;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4.  
  5. public class levelManager : MonoBehaviour
  6. {
  7.  
  8.     public Object emu;
  9.     public Object emutype2;
  10.     Object CurSpawn;
  11.  
  12.     public Transform Spawn1;
  13.     public Transform Spawn2;
  14.     public Transform Spawn3;
  15.     public Transform Spawn4;
  16.     Transform CurTrans;
  17.  
  18.     private float SpawnInterval;
  19.     int x = 1;
  20.     List<string> CurrentLevel;
  21.     string CurrentLine;
  22.     string CurrentString;
  23.     char val1;
  24.     char val2;
  25.     private float timer;
  26.  
  27.     private void Start()
  28.     {
  29.         //combine with menu to switch level loaded
  30.         SetInterval(levels.L1);
  31.     }
  32.  
  33.     private void Update()
  34.     {
  35.         timer += Time.deltaTime;
  36.         if (timer > SpawnInterval)
  37.         {
  38.             //combine with menu to switch level loaded
  39.             SpawnEnem(levels.L1);
  40.             timer = 0;
  41.         }
  42.     }
  43.  
  44.     private void SetInterval(List<string> level)
  45.     {
  46.         SpawnInterval = float.Parse(level[0]);
  47.     }
  48.     private void SpawnEnem(List<string> level)
  49.     {
  50.         if (x < level.Count)
  51.         {
  52.             CurrentLine = level[x];
  53.             if (CurrentLine != "n")
  54.             {
  55.                 string[] words = CurrentLine.Split(' ');
  56.                 for (int i = 0; i <= words.Length - 1; i++)
  57.                 {
  58.                     CurrentString = words[i];
  59.                     val1 = CurrentString[0];
  60.                     val2 = CurrentString[1];
  61.                     switch (val1)
  62.                     {
  63.                         case 'e':
  64.                             CurSpawn = emu;
  65.                             break;
  66.                         case 'w':
  67.                             CurSpawn = emutype2;
  68.                             break;
  69.                     }
  70.                     switch (val2)
  71.                     {
  72.                         case '1':
  73.                             CurTrans = Spawn1;
  74.                             break;
  75.                         case '2':
  76.                             CurTrans = Spawn2;
  77.                             break;
  78.                         case '3':
  79.                             CurTrans = Spawn3;
  80.                             break;
  81.                         case '4':
  82.                             CurTrans = Spawn4;
  83.                             break;
  84.                     }
  85.                     Instantiate(CurSpawn, CurTrans.position, CurTrans.rotation);
  86.                 }
  87.  
  88.             }
  89.             x += 1;
  90.         }
  91.     }
  92. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement