public static bool SetConstsFromFile(string path) { ReadConfiguration configurations = null; try { configurations = new ReadConfiguration(path, false); Set(configurations); //Console.WriteLine(configurations.ToString()); return(true); } catch { return(false); } finally { if (configurations != null) { configurations.Dispose(); } } }
private static void Set(ReadConfiguration configurations) { //User Plane SetConsts(typeof(GameConsts.B25Plane), configurations.GetConfiguration(ConfigurationNames.B25), GameConsts.B25Plane.Singleton); SetConsts(typeof(GameConsts.F4UPlane), configurations.GetConfiguration(ConfigurationNames.F4U), GameConsts.F4UPlane.Singleton); SetConsts(typeof(GameConsts.P47Plane), configurations.GetConfiguration(ConfigurationNames.P47), GameConsts.P47Plane.Singleton); switch (EngineConfig.CurrentPlayerPlaneType) { case PlaneType.P47: GameConsts.GenericPlane.SetCurrentUserPlane(GameConsts.P47Plane.Singleton); break; case PlaneType.F4U: GameConsts.GenericPlane.SetCurrentUserPlane(GameConsts.F4UPlane.Singleton); break; case PlaneType.B25: GameConsts.GenericPlane.SetCurrentUserPlane(GameConsts.B25Plane.Singleton); break; } //Enemy Plane SetConsts(typeof(GameConsts.EnemyFighter), configurations.GetConfiguration(ConfigurationNames.EnemyFighter), GameConsts.EnemyFighter.Singleton); SetConsts(typeof(GameConsts.EnemyBomber), configurations.GetConfiguration(ConfigurationNames.EnemyBomber), GameConsts.EnemyBomber.Singleton); //Soldier SetConsts(typeof(GameConsts.Soldier), configurations.GetConfiguration(ConfigurationNames.Soldier), new GameConsts.Soldier()); //Wooden Bunker SetConsts(typeof(GameConsts.WoodenBunker), configurations.GetConfiguration(ConfigurationNames.WoodenBunker), new GameConsts.WoodenBunker()); //Concrete Bunker SetConsts(typeof(GameConsts.ConcreteBunker), configurations.GetConfiguration(ConfigurationNames.ConcreteBunker), new GameConsts.ConcreteBunker()); //Flak Bunker SetConsts(typeof(GameConsts.FlakBunker), configurations.GetConfiguration(ConfigurationNames.FlakBunker), new GameConsts.FlakBunker()); SetConsts(typeof(GameConsts.ShipWoodenBunker), configurations.GetConfiguration(ConfigurationNames.ShipWoodenBunker), new GameConsts.ShipWoodenBunker()); //Concrete Bunker SetConsts(typeof(GameConsts.ShipConcreteBunker), configurations.GetConfiguration(ConfigurationNames.ShipConcreteBunker), new GameConsts.ShipConcreteBunker()); SetConsts(typeof(GameConsts.Gun), configurations.GetConfiguration(ConfigurationNames.Gun), new GameConsts.Gun()); SetConsts(typeof(GameConsts.Bomb), configurations.GetConfiguration(ConfigurationNames.Bomb), new GameConsts.Bomb()); SetConsts(typeof(GameConsts.Rocket), configurations.GetConfiguration(ConfigurationNames.Rocket), new GameConsts.Rocket()); SetConsts(typeof(GameConsts.Torpedo), configurations.GetConfiguration(ConfigurationNames.Torpedo), new GameConsts.Torpedo()); //Effects SetConsts(typeof(GameConsts.Effects), configurations.GetConfiguration(ConfigurationNames.Effects), new GameConsts.Effects()); }