private void InitializeSpecialStageObjects(ContentManager content, List <StageObject> stageObjects, TiledSharp.TmxMap tmx, TiledSharp.TmxList <TiledSharp.TmxObjectGroup.TmxObject> objectgroup) { // Initialize Special Background Objects foreach (TiledSharp.TmxObjectGroup.TmxObject tmxObject in objectgroup) { // object's Y-coordinate is oriented to the bottom of the placement of the object, and we need top. // so, we get the tile and look at its height and subtract that from the object's Y-coordinate to detemrine placement of object. float fObjectHeight = 0; StageObject s = null; switch (tmxObject.Type) { case "Bridge": case "EnemySpawnLocation": switch (tmxObject.Type) { case "Bridge": s = new StageBridge(); break; case "EnemySpawnLocation": s = new EnemySpawnLocation("EnemyFootSoldier"); break; default: throw new InvalidDataException(string.Format("Unexpected background object type: {0}", tmxObject.Type)); } s.Initialize(null, this, new Vector2((float)tmxObject.X, (float)tmxObject.Y - fObjectHeight)); if (s is StageBridge) { ((StageBridge)s).InitializeBridge(content, new Point(tmxObject.X, tmxObject.Y), 4); } s.Height = tmxObject.Height; s.Width = tmxObject.Width; break; default: int gid = tmxObject.Tile.Gid; for (int i = 0; i < StageTiles.Count; i++) { if (gid < tmx.Tilesets[i].FirstGid) { break; } fObjectHeight = (float)tmx.Tilesets[i].TileHeight; } s = new StageObject(); s.Initialize(content.Load <Texture2D>(tmxObject.Type), this, new Vector2((float)tmxObject.X, (float)tmxObject.Y - fObjectHeight)); break; } //e.Initialize(content, new Vector2((float)tmxObject.X, (float)tmxObject.Y), this, "Sniper"); stageObjects.Add(s); } }
private IEnumerator Spawn(int nrOfEnemies) { EnemySpawnLocation enemySpawnLocation = enemySpawnLocations[RandomManager.GetRandomNumber(0, enemySpawnLocations.Length)]; for (int i = 0; i < nrOfSpawnsPerWave; i++) { enemySpawnLocation.objectPool.Get(enemySpawnLocation.objectPool.transform.position, enemySpawnLocation.objectPool.transform.rotation); } yield return(new WaitForSecondsRealtime(timeBetweenSpawn + (UnrestManager.GetInstance().CurrentUnrest *unrestModifier))); StartCoroutine(Spawn(nrOfEnemies)); }