public void Level1Setup() { PlayerPrefs.SetString("TSSE[Level][Current]", "Level1"); LevelDefinitions.Level level1 = new LevelDefinitions.Level(); level1.uniqueId = "Level1"; List <ShipDefinitions.ShipEntity> enemies = new List <ShipDefinitions.ShipEntity>(); // Adding default enemies for sake of testing ShipDefinitions.ShipEntity enemy1 = new ShipDefinitions.ShipEntity(ShipDefinitions.EngineType.Engine1, ShipDefinitions.WeaponType.Flame, ShipDefinitions.ShipType.Ruby, new List <ItemAbstract>(), ShipDefinitions.Faction.Enemy, "Enemy1"); ShipDefinitions.ShipEntity enemy2 = new ShipDefinitions.ShipEntity(ShipDefinitions.EngineType.Engine1, ShipDefinitions.WeaponType.Flame, ShipDefinitions.ShipType.Ruby, new List <ItemAbstract>(), ShipDefinitions.Faction.Enemy, "Enemy2"); ShipDefinitions.ShipEntity enemy3 = new ShipDefinitions.ShipEntity(ShipDefinitions.EngineType.Engine1, ShipDefinitions.WeaponType.Flame, ShipDefinitions.ShipType.Ruby, new List <ItemAbstract>(), ShipDefinitions.Faction.Enemy, "Enemy3"); ShipDefinitions.ShipEntity enemy4 = new ShipDefinitions.ShipEntity(ShipDefinitions.EngineType.Engine2, ShipDefinitions.WeaponType.Crown, ShipDefinitions.ShipType.Ruby, new List <ItemAbstract>(), ShipDefinitions.Faction.Enemy, "Enemy4"); ShipDefinitions.ShipEntity enemy5 = new ShipDefinitions.ShipEntity(ShipDefinitions.EngineType.Engine2, ShipDefinitions.WeaponType.Crown, ShipDefinitions.ShipType.Ruby, new List <ItemAbstract>(), ShipDefinitions.Faction.Enemy, "Enemy5"); ShipDefinitions.ShipEntity enemy6 = new ShipDefinitions.ShipEntity(ShipDefinitions.EngineType.Engine2, ShipDefinitions.WeaponType.Crown, ShipDefinitions.ShipType.Ruby, new List <ItemAbstract>(), ShipDefinitions.Faction.Enemy, "Enemy6"); enemies.Add(enemy1); enemies.Add(enemy2); enemies.Add(enemy3); enemies.Add(enemy4); enemies.Add(enemy5); enemies.Add(enemy6); level1.ships = enemies; level1.shipSpawningTokens = new Dictionary <string, string>(); level1.shipSpawningTokens["Enemy1"] = "wave0"; level1.shipSpawningTokens["Enemy2"] = "wave0"; level1.shipSpawningTokens["Enemy3"] = "wave0"; level1.shipSpawningTokens["Enemy4"] = "wave1"; level1.shipSpawningTokens["Enemy5"] = "wave1"; level1.shipSpawningTokens["Enemy6"] = "wave1"; level1.shipSpawningTokens["PlayerShip0"] = "center"; level1.shipSpawningTokens["PlayerShip1"] = "center"; level1.shipSpawningTokens["PlayerShip2"] = "center"; level1.shipSpawningTokens["PlayerShip3"] = "center"; level1.shipSpawningTokens["PlayerShip4"] = "center"; level1.shipSpawningTokens["PlayerShip5"] = "center"; PlayerPrefs.SetString("TSSE[Level][Current]", level1.uniqueId); LevelDefinitions.saveLevel(level1); }
/// <summary> /// Checks that the ClassDefinition is valid, and it not, attempts to bring it into a valid state. /// </summary> private void ValidateAndFix() { var levelNames = new HashSet <string>(); var duplicateLevelDefinitions = new List <LevelDefinition>(); var fileInfo = GetFileStringForError(); foreach (var def in LevelDefinitions) { if (!levelNames.Add(def.Name)) { LevelingPlugin.Instance.LogPrint($"{fileInfo}Class '{Name}' already has a Level named '{def.Name}'. Disabling duplicate level.", TraceLevel.Error); duplicateLevelDefinitions.Add(def); } } foreach (var dupDef in duplicateLevelDefinitions) { LevelDefinitions.Remove(dupDef); } }
// Use this for initialization void Start() { string levelId = PlayerPrefs.GetString("TSSE[Level][Current]"); print("current level: " + levelId); currentLevel = LevelDefinitions.loadLevel(levelId); print(levelId); playerShips = new List <ShipDefinitions.ShipEntity>(); for (int i = 0; i < 6; i++) { string id = "PlayerShip" + i.ToString(); playerShips.Add(ShipDefinitions.loadShip(id)); } enemyWaves = new List <List <ShipDefinitions.ShipEntity> >(); foreach (ShipDefinitions.ShipEntity entity in currentLevel.ships) { if (entity.shipType != ShipDefinitions.ShipType.None) { string spawningToken = ""; int waveNum = 0; //string spawnPos = "spawn:0:0"; if (currentLevel.shipSpawningTokens.ContainsKey(entity.uniqueId)) { spawningToken = currentLevel.shipSpawningTokens[entity.uniqueId]; string[] tokens = spawningToken.Split('#'); foreach (string token in tokens) { print("3: " + entity.uniqueId); print("3: " + token); if (token.Contains("wave")) { waveNum = int.Parse(token.Substring(token.Length - 1, 1)); } /* * if(token.Contains("spawn")) * { * spawnPos = token; * } */ } if (enemyWaves.ToArray().GetLength(0) <= waveNum) { print(waveNum); print(enemyWaves.ToArray().GetLength(0)); enemyWaves.Add(new List <ShipDefinitions.ShipEntity>()); } enemyWaves[waveNum].Add(entity); } else { // if we have no token for this ship, just spawn it immediately // better we see effects immediately instead of failing silently spawnShip(getSpawnPosition(spawningToken), entity); } } } spawnPlayers(); //spawnWave(0); }