private void OnSceneGUI() { SpawnSet spawnSet = target as SpawnSet; RoomDefinition roomDefinition = spawnSet.GetComponentInParent <RoomDefinition>(); RoomDefinitionEditor.DrawRoomDefinitionEditorSceneGUI(roomDefinition); Repaint(); }
IEnumerator LaunchSet(SpawnSet s) { yield return(new WaitForSeconds(s.waitTime)); switch (s.unitType) { case units.SIMPLE_GROUND_UNIT: spawner.SpawnSimpleGroundUnit(SpawnPoints[s.spawnPointIndex].position); break; } // Spawn given unit }
public static Stage[] Load(string fileName) { List<GameEvent> events = new List<GameEvent> (); var asset = Resources.Load (fileName) as TextAsset; int currDelay = 0; SpawnSet currSpawnSet = new SpawnSet(new List<Spawn> (), 0); foreach (var line in asset.text.Split('\n')) { int tryparse; if (int.TryParse (line, out tryparse)) { currDelay = tryparse; if (currSpawnSet.spawns.Count > 0) { events.Add ((GameEvent)currSpawnSet); } currSpawnSet = new SpawnSet (new List<Spawn> (), currDelay); continue; } if (line.Contains ("Shift")) { events.Add ((GameEvent)new BackgroundShift ((Colors)Enum.Parse(typeof(Colors), line.Split (' ') [1]), currDelay)); } else if (line.Contains ("Spawn")) { Colors color = Colors.player; if (!line.Contains ("asteroid")) { color = (Colors)Enum.Parse (typeof(Colors), line.Split (' ') [1]); } var cannons = line.Split(' ')[2]; bool[] outCannons = GetCannons(cannons); Vector3 position =new Vector3(Constants.slots[int.Parse (line.Split (' ') [3])],5,1); currSpawnSet.spawns.Add (new Spawn (position, color, outCannons, line.Contains ("shield"), line.Contains ("rotat"))); } else if (line.Contains ("Boss")){ events.Add((GameEvent)new Boss(new Vector3(Constants.slots[6],3 ,1), int.Parse(line.Split(' ')[1]),currDelay)); } else if (line.Contains ("Music")) { events.Add ((GameEvent)new MusicEvent (int.Parse(line.Split (' ') [1]), currDelay)); } } if (currSpawnSet.spawns.Count > 0) { events.Add ((GameEvent)currSpawnSet); } return new[]{new Stage (events)}; }
/// <summary> /// spawn set of enemy /// </summary> /// <param name="set"> /// set of enemy /// </param> public void SetSpawn(SpawnSet set) { Queue <Transform> spawnQueue = new Queue <Transform>(); foreach (var tag in set.enemyTag) { var pointQueue = LineData[tag]; if (pointQueue.Count > 0) { GameObject newEnemy = enemyPool.SpawnFromPool(tag, set.spawnPoint.transform.position, Quaternion.identity); Enemy enemy = newEnemy.GetComponent <Enemy>(); enemy.enemyManagement = this; liveEnemy.Add(enemy); enemy.StanbyPositionRef = pointQueue.Dequeue(); // Debug.Log(enemy.linePositionRef); spawnQueue.Enqueue(newEnemy.transform); } } set.spawnPoint.StartSpawn(spawnQueue); }
IEnumerator SpawnEnemy(SpawnSet spawnSet) { int count = spawnSet.count; while (count > 0) { if (count >= 4) { for (int i = 0; i < 4; i++) { GameObject enemy = Instantiate<GameObject> (spawnSet.obj); enemy.transform.SetParent (spawnSet.mustBeKilled ? mustKillEnemies.transform : normalEnemies.transform); enemy.transform.rotation = Quaternion.Euler (0f, 0f, Random.Range (0, 360)); zPosition += 0.000001f; //Makes sure that monsters always spawn on diffrent layers so there is no z-fighting enemy.GetComponent<Mob> ().AddBuffToStats (spawnSet.buff); enemy.transform.position = new Vector3 (ClosestSpawn [i].x, ClosestSpawn [i].y, zPosition); yield return new WaitForSeconds(spawnSet.interval); count--; } } else { GameObject enemy = Instantiate<GameObject> (spawnSet.obj); enemy.transform.SetParent (spawnSet.mustBeKilled ? mustKillEnemies.transform : normalEnemies.transform); enemy.transform.rotation = Quaternion.Euler (0f, 0f, Random.Range (0, 360)); zPosition += 0.000001f; //Makes sure that monsters always spawn on diffrent layers so there is no z-fighting enemy.GetComponent<Mob> ().AddBuffToStats (spawnSet.buff); enemy.transform.position = new Vector3 (ClosestSpawn [mark].x, ClosestSpawn [mark].y, zPosition); yield return new WaitForSeconds(spawnSet.interval); count--; } } isSpawnFinished -= 1; }
public void AddEnemy(SpawnSet spawnSet) { enemies.Add (spawnSet); }
// Use this for initialization void Start() { // load the wave file zPosition = 0; waveList = new List<Wave>(); JSONNode wavesData = JSON.Parse(waveFile.text); // set up global buff globalBuff.strengthAddon = wavesData ["options"] ["buff"] ["str"].AsInt; globalBuff.dexterityAddon = wavesData ["options"] ["buff"] ["dex"].AsInt; globalBuff.intelligenceAddon = wavesData ["options"] ["buff"] ["int"].AsInt; globalBuff.baseHealth = wavesData ["options"] ["buff"] ["health"].AsInt; globalBuff.baseMana = wavesData ["options"] ["buff"] ["mana"].AsInt; JSONArray wavesName = wavesData ["waves"].AsArray; for (int i = 0; i < wavesName.Count; i++) { JSONNode waveData = wavesData [wavesName [i]]; int count = waveData ["count"].AsInt; JSONArray enemies = waveData ["enemies"].AsArray; Wave w = new Wave(); for (int j = 0; j < enemies.Count; j++) { JSONNode enemyData = enemies [j]; SpawnSet spawnSet = new SpawnSet ( Resources.Load<GameObject> (enemyData ["enemy"]), enemyData ["count"].AsInt, enemyData ["mustBeKilled"].AsBool, enemyData ["interval"].AsFloat); // look for buff if (enemyData ["buff"].Count > 0) { JSONClass buffJson = enemyData ["buff"].AsObject; Buff buff = new Buff (); buff.strengthAddon = buffJson ["str"].AsInt; buff.dexterityAddon = buffJson ["dex"].AsInt; buff.intelligenceAddon = buffJson ["int"].AsInt; buff.baseHealth = buffJson ["health"].AsInt; buff.baseMana = buffJson ["mana"].AsInt; buff.level = j + 1; buff.AddBuff (globalBuff); spawnSet.SetBuff (buff); } w.AddEnemy (spawnSet); } waveList.Add (w); } Debug.Log (waveList.Count.ToString () + " waves loaded"); }