Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using UnityEngine;
- using System.Collections;
- using System.Collections.Generic;
- public class levelManager : MonoBehaviour
- {
- public Object emu;
- public Object emutype2;
- Object CurSpawn;
- public Transform Spawn1;
- public Transform Spawn2;
- public Transform Spawn3;
- public Transform Spawn4;
- Transform CurTrans;
- private float SpawnInterval;
- int x = 1;
- List<string> CurrentLevel;
- string CurrentLine;
- string CurrentString;
- char val1;
- char val2;
- private float timer;
- private void Start()
- {
- //combine with menu to switch level loaded
- SetInterval(levels.L1);
- }
- private void Update()
- {
- timer += Time.deltaTime;
- if (timer > SpawnInterval)
- {
- //combine with menu to switch level loaded
- SpawnEnem(levels.L1);
- timer = 0;
- }
- }
- private void SetInterval(List<string> level)
- {
- SpawnInterval = float.Parse(level[0]);
- }
- private void SpawnEnem(List<string> level)
- {
- if (x < level.Count)
- {
- CurrentLine = level[x];
- if (CurrentLine != "n")
- {
- string[] words = CurrentLine.Split(' ');
- for (int i = 0; i <= words.Length - 1; i++)
- {
- CurrentString = words[i];
- val1 = CurrentString[0];
- val2 = CurrentString[1];
- switch (val1)
- {
- case 'e':
- CurSpawn = emu;
- break;
- case 'w':
- CurSpawn = emutype2;
- break;
- }
- switch (val2)
- {
- case '1':
- CurTrans = Spawn1;
- break;
- case '2':
- CurTrans = Spawn2;
- break;
- case '3':
- CurTrans = Spawn3;
- break;
- case '4':
- CurTrans = Spawn4;
- break;
- }
- Instantiate(CurSpawn, CurTrans.position, CurTrans.rotation);
- }
- }
- x += 1;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement