public BattlefieldData LoadBattlefieldData(string fileName, bool isFullPath = false) { string fullFile = BATTLEFIELD_SAVE_DIRECTORY + fileName + ".dat"; if (isFullPath) { fullFile = fileName; } BattlefieldData data = Utility.LoadObjectFromFile <BattlefieldData> (fullFile); if (data != null) { data.spawns = new List <EnemySpawnPoint> (); for (int i = 0; i < data.spawnsX.Length; i++) { Vector3 start = new Vector3(data.spawnsX[i], data.spawnsY[i]); Vector3 end = new Vector3(data.endsX[i], data.endsY[i]); EnemySpawnPoint spawn = ScriptableObject.CreateInstance <EnemySpawnPoint>(); EnemyEndPoint endPoint = ScriptableObject.CreateInstance <EnemyEndPoint>(); spawn.worldPosition = start; endPoint.worldPosition = end; spawn.endPoint = endPoint; data.spawns.Add(spawn); } return(data); } return(null); }
void GenerateDefaultSpawnpoints() { for (int x = 1; x < battlefieldWidth + 1; x++) { EnemySpawnPoint spawn = ScriptableObject.CreateInstance <EnemySpawnPoint>(); EnemyEndPoint end = ScriptableObject.CreateInstance <EnemyEndPoint>(); spawn.worldPosition = new Vector3(x - battlefieldWidth / 2f - 0.5f, battlefieldHeight / 2f - 0.5f); end.worldPosition = new Vector3(x - battlefieldWidth / 2f - 0.5f, -battlefieldHeight / 2f - 0.5f); spawn.endPoint = end; enemySpawnPoints.Add(spawn); } }