static void TestZXP() { string data = @" MyValue [10] Add({10}) Add({10}) Add({10}) Inner <RTSEngineTests.ZXPTestObj> { MyValue [12] Add({10}) Add({10}) Add({10}) Inner <RTSEngineTests.ZXPTestObj> { MyValue [14] Add({10}) Add({10}) Add({10}) } }" ; ZXPTestObj o = new ZXPTestObj(); ZXParser.ParseInto(data, o); Console.WriteLine(o.Value); Console.WriteLine(o.Rec.Value); Console.WriteLine(o.Rec.Rec.Value); var sw = new StreamWriter("Test.txt"); ZXParser.Write(sw, o); sw.Flush(); sw.Dispose(); }
public static RTSRace Parse(FileInfo infoFile, Dictionary <string, ReflectedScript> scripts) { // Check File Existence if (infoFile == null || !infoFile.Exists) { return(null); } // Read The Entire File string mStr; using (FileStream fs = File.OpenRead(infoFile.FullName)) { StreamReader s = new StreamReader(fs); mStr = s.ReadToEnd(); } // Set Environment Variables ZXParser.SetEnvironment("FILEROOTDIR", infoFile.Directory.FullName); ZXParser.SetEnvironment("DICTSCRIPTS", scripts); // Read Data RTSRace data = new RTSRace(); ZXParser.ParseInto(mStr, data); data.InfoFile = new FileInfo(PathHelper.GetRelativePath(infoFile.FullName)); data.UpdateActiveUnits(); data.UpdateActiveBuildings(); return(data); }
public static RTSUnitData ParseData(Dictionary <string, ReflectedScript> controllers, FileInfo infoFile, int index) { // Check File Existence if (infoFile == null || !infoFile.Exists) { return(null); } // Read The Entire File string mStr; using (FileStream fs = File.OpenRead(infoFile.FullName)) { StreamReader s = new StreamReader(fs); mStr = s.ReadToEnd(); } // Set Environment Variables ZXParser.SetEnvironment("FILEROOTDIR", infoFile.Directory.FullName); ZXParser.SetEnvironment("DICTSCRIPTS", controllers); // Read Data RTSUnitData data = new RTSUnitData(index); ZXParser.ParseInto(mStr, data); data.InfoFile = PathHelper.GetRelativePath(infoFile.FullName); return(data); }
public static void SearchAllInitInfo(DirectoryInfo dir, Dictionary <string, FileInfo> races, Dictionary <string, RTSColorScheme> dictSchemes) { var files = dir.GetFiles(); foreach (var file in files) { if (file.Extension.ToLower().EndsWith("race")) { races.Add(RTSRaceParser.ParseName(file), file); } else if (file.Extension.ToLower().EndsWith("scheme")) { object scheme = ZXParser.ParseFile(file.FullName, typeof(RTSColorScheme)); if (scheme != null) { var v = (RTSColorScheme)scheme; dictSchemes.Add(v.Name, v); } } } var dirs = dir.GetDirectories(); foreach (var subDir in dirs) { SearchAllInitInfo(subDir, races, dictSchemes); } }
public override void OnEntry(GameTime gameTime) { DevConsole.OnNewCommand += DevConsole_OnNewCommand; KeyboardEventDispatcher.OnKeyPressed += KeyboardEventDispatcher_OnKeyPressed; input.Refresh(); sP.Hook(); sS.Hook(); sT.Hook(); RendererInitArgs ria = ZXParser.ParseFile(@"Content\FX\RIA.txt", typeof(RendererInitArgs)) as RendererInitArgs; renderer = new RTSRenderer(game.Graphics, game.Content, ria, game.Window); // Rendering Effect fx = new RTSFXEntity(renderer.LoadEffect(FX_FILE_PATH)); // Default Team sP.Color = RTSColorScheme.Default.Primary; sS.Color = RTSColorScheme.Default.Secondary; sT.Color = RTSColorScheme.Default.Tertiary; colorScheme.Name = RTSColorScheme.Default.Name; // Create Camera camera = new OrbitingCamera(Vector3.Zero, 4f, G.Viewport.AspectRatio); camera.Pitch = MathHelper.PiOver4; camera.Yaw = 0; camera.FOV = MathHelper.PiOver4; unitDataFiles = new List <FileInfo>(); schemeFiles = new List <FileInfo>(); FindAllData(); curUnit = 0; }
void DevConsole_OnNewCommand(string obj) { Match m; if ((m = rgxSetFile.Match(obj)).Success) { file = RegexHelper.ExtractFile(m); } else if ((m = rgxSetName.Match(obj)).Success) { name = RegexHelper.Extract(m); } else if ((m = rgxSave.Match(obj)).Success) { if (file == null) { DevConsole.AddCommand("No File Specified"); } else if (string.IsNullOrWhiteSpace(name)) { DevConsole.AddCommand("No Name Specified"); } else { using (var s = file.Create()) { StreamWriter w = new StreamWriter(s); w.WriteLine("NAME [{0}]", name); w.WriteLine("PRIMARY [{0}, {1}, {2}]", colorScheme.Primary.X, colorScheme.Primary.Y, colorScheme.Primary.Z); w.WriteLine("SECONDARY [{0}, {1}, {2}]", colorScheme.Secondary.X, colorScheme.Secondary.Y, colorScheme.Secondary.Z); w.WriteLine("TERTIARY [{0}, {1}, {2}]", colorScheme.Tertiary.X, colorScheme.Tertiary.Y, colorScheme.Tertiary.Z); w.Flush(); } } } else if ((m = rgxLoad.Match(obj)).Success) { if (file == null) { DevConsole.AddCommand("No File Specified"); } else if (!file.Exists) { DevConsole.AddCommand("File Does Not Exist"); } var cs = ZXParser.ParseFile(file.FullName, typeof(RTSColorScheme)); if (cs == null) { DevConsole.AddCommand("Incorrect File Format"); } else { colorScheme = (RTSColorScheme)cs; name = colorScheme.Name; sP.Color = colorScheme.Primary; sS.Color = colorScheme.Secondary; sT.Color = colorScheme.Tertiary; } } }
public override void Build() { using (var fs = File.OpenRead(UIC_FILE)) { uic = new UICMainMenu(); ZXParser.ParseInto(new StreamReader(fs).ReadToEnd(), uic); } using (var s = File.OpenRead(uic.SoundClick)) { seClick = SoundEffect.FromStream(s); } }
public static void Save(string path) { if (!changeDetected) { return; } using (var s = File.Create(path)) { StreamWriter sw = new StreamWriter(s); ZXParser.Write(sw, data); sw.Flush(); } }
protected override void FullLoad() { using (var s = System.IO.File.OpenRead(@"Content\UI\Mouse\Main.png")) { tMouseMain = Texture2D.FromStream(GraphicsDevice, s); } mRenderer = new MouseRenderer(GraphicsDevice, Window); mRenderer.Texture = tMouseMain; mRenderer.InnerRadius = 28f; dcv = new DevConsoleView(Content, @"Fonts\CourierNew14", GraphicsDevice); ZXParser.SetEnvironment("GD", GraphicsDevice); ZXParser.SetEnvironment("GDM", graphics); ZXParser.SetEnvironment("Window", Window); }
public static RTSUnitModel ParseModel(RTSRenderer renderer, FileInfo infoFile, RTSRace race) { // Check File Existence if (infoFile == null || !infoFile.Exists) { return(null); } ZXParser.SetEnvironment("FILEROOTDIR", infoFile.Directory.FullName); ZXParser.SetEnvironment("RENDERER", renderer); ZXParser.SetEnvironment("RACE", race); RTSUnitViewData vd = ZXParser.ParseFile(infoFile.FullName, typeof(RTSUnitViewData)) as RTSUnitViewData; return(vd.View); }
public static TerrainData ParseData(FileInfo infoFile, List <ImpactRegion> regions) { // Check File Existence if (infoFile == null || !infoFile.Exists) { return(null); } ZXParser.SetEnvironment("FILEROOTDIR", infoFile.Directory.FullName); TerrainData mio = ZXParser.ParseFile(infoFile.FullName, typeof(TerrainData)) as TerrainData; mio.LGrid.InfoFile = PathHelper.GetRelativePath(infoFile.FullName); regions.AddRange(mio.Regions); // TODO: Remove return(mio); }
public static void Load(string path) { FileInfo fi = new FileInfo(path); if (!fi.Exists) { changeDetected = true; data = new Args(); } else { using (var s = fi.OpenRead()) { var mStr = new StreamReader(s).ReadToEnd(); ZXParser.ParseInto(mStr, data); } } }
public override void Build() { gPresets = new List <GamePreset>(); inputTypes = new string[GameState.MAX_PLAYERS]; inputInitArgs = new object[GameState.MAX_PLAYERS]; var di = new DirectoryInfo(PRESET_DIR); foreach (var fi in di.GetFiles()) { if (!fi.Extension.EndsWith(@"game")) { continue; } GamePreset gp = (GamePreset)ZXParser.ParseFile(fi.FullName, typeof(GamePreset)); gPresets.Add(gp); } }
public static Dictionary<string, ReflectedScript> Compile(string[] files, string[] references, out string error) { // No Error Default error = null; // Compile CompilerParameters compParams = new CompilerParameters(references, null, false); compParams.CompilerOptions = "/optimize"; compParams.GenerateExecutable = false; compParams.GenerateInMemory = true; compParams.TreatWarningsAsErrors = false; #if DEBUG compParams.IncludeDebugInformation = true; #endif CompilerResults cr = compiler.CompileAssemblyFromFile(compParams, files); // Check For Errors if(cr.Errors.Count > 0) { error = ""; foreach(var e in cr.Errors) error += e + "\n"; return null; } // Dictionaries var res = new Dictionary<string, ReflectedScript>(); // Loop Through All Visible Types Assembly a = cr.CompiledAssembly; Type[] types = a.GetExportedTypes(); foreach(Type t in types) { ZXPProxy.Add(t); ZXParser.AddDynamicType(t.FullName, t); // We Don't Want Abstract Classes Or Interfaces if(t.IsAbstract || t.IsInterface) continue; // Check For The Superclass if(t.IsSubclassOf(typeof(ACScript))) { var rs = new ReflectedScript(t); res.Add(rs.TypeName, rs); } } return res; }
public override void Build() { uic = ZXParser.ParseFile(UIC_FILE, typeof(UICInduZtry)) as UICInduZtry; Random rColor = new Random(); int ci = rColor.Next(0, uic.ColorCombos.Length); lBoltArgs.JagDisplacement = uic.Bolt.Width; lBoltArgs.LineMinLength = uic.Bolt.MinLength; lBoltArgs.LineMaxLength = uic.Bolt.MaxLength; lBoltArgs.Color = uic.ColorCombos[ci].Foreground; lBranchArgs.JagDisplacement = uic.Branch.Width; lBranchArgs.LineMinLength = uic.Branch.MinLength; lBranchArgs.LineMaxLength = uic.Branch.MaxLength; lBranchArgs.BranchSlope = uic.BranchingSlope; lBranchArgs.MinBounds = Vector2.Zero; lBranchArgs.MaxBounds = ViewSize; lBranchArgs.Color = uic.ColorCombos[ci].Background; }
public RTSUI(RTSRenderer renderer, string uicFile, bool showBuildPanel) { uic = ZXParser.ParseFile(uicFile, typeof(UICRTS)) as UICRTS; SpriteFont font = renderer.LoadFont(uic.Font); wrButtonPanel = new WidgetRenderer(renderer.G, font); wrMain = new WidgetRenderer(renderer.G, font); BuildBounds(renderer); BuildMinimap(renderer, uic.UICMinimap); BuildBBPanel(renderer); BuildBuildingPanel(showBuildPanel); BuildSelectionPanel(renderer); BuildUnitDataPanel(renderer); BuildBuildingDataPanel(renderer); BuildTeamDataPanel(); AlertQueue = new RTSUIAlertQueue(wrMain, uic.UICAlertQueue); AlertQueue.WidgetBase.Parent = Minimap.WidgetBase; SelectionToggle = 0; }
//public SpriteFont CreateFont(string fontName, int size, int spacing = 0, bool useKerning = true, string style = "Regular", char defaultChar = '*', int cStart = 32, int cEnd = 126) { // IDisposable disp; // SpriteFont f = XNASpriteFont.Compile(G, fontName, size, out disp, spacing, useKerning, style, defaultChar, cStart, cEnd); // toDispose.Add(disp); // return f; //} //public SpriteFont CreateFont(string fontName, int size, out IDisposable disp, int spacing = 0, bool useKerning = true, string style = "Regular", char defaultChar = '*', int cStart = 32, int cEnd = 126) { // SpriteFont f = XNASpriteFont.Compile(G, fontName, size, out disp, spacing, useKerning, style, defaultChar, cStart, cEnd); // toDispose.Add(disp); // return f; //} #endregion public void HookToGame(GameState state, int ti, Camera camera) { // Get The Team To Be Visualized teamIndex = ti; teamInput = state.teams[teamIndex].Input; SelectionCircleTexture = LoadTexture2D(@"Content\Textures\SelectionCircle.png"); // Get The Camera Camera = camera; // Create The Map CreateVoxGeos(state.VoxState.World.Atlas); Map = new VoxMap(this, state.CGrid.numCells.X, state.CGrid.numCells.Y); // TODO: Parse This In VoxMapConfig vmc = new VoxMapConfig(); vmc.VoxState = state.VoxState; vmc.TexVoxMap = @"voxmap.png"; vmc.RootPath = state.LevelGrid.Directory.FullName; vmc.FXFile = @"FX\Voxel"; Map.Build(gManager, cManager, vmc); Camera.MoveTo(state.CGrid.size.X * 0.5f, state.CGrid.size.Y * 0.5f); fxMap.MapSize = state.CGrid.size; pRenderer.MapSize = state.CGrid.size; // Hook FOW state.CGrid.OnFOWChange += OnFOWChange; Minimap.Hook(this, state, ti); // Load Particles // TODO: Config ParticleOptions pOpt = ZXParser.ParseFile(@"Content\FX\Particles\Particle.conf", typeof(ParticleOptions)) as ParticleOptions; pRenderer.Load(this, pOpt); // Load Team Visuals for (int i = 0; i < state.teams.Length; i++) { if (state.teams[i] == null) { continue; } LoadTeamVisuals(state, i); } // Set FOW for (int y = 0; y < Map.FogOfWarTexture.Height; y++) { for (int x = 0; x < Map.FogOfWarTexture.Width; x++) { switch (state.CGrid.GetFogOfWar(x, y, teamIndex)) { case FogOfWar.Active: Map.SetFOW(x, y, 1f); break; case FogOfWar.Passive: Map.SetFOW(x, y, 0.5f); break; case FogOfWar.Nothing: Map.SetFOW(x, y, 0f); break; } } } }
private void WorkThread() { try { // Start With Default Values isLoaded = false; loadException = null; LoadedRenderer = null; // Grab The Initialization Info loadData = game.LobbyScreen.InitInfo; // Build The Local Game State LoadedState = new GameState(); if (LoadFile == null) { GameEngine.BuildLocal(LoadedState, LoadData, new DirectoryInfo(@"Packs"), game.LobbyScreen.Races); } else { GameEngine.Load(LoadedState, new DirectoryInfo(@"Packs"), LoadFile.FullName); } // Create The Input Controllers for (int ti = 0; ti < LoadedState.teams.Length; ti++) { if (string.IsNullOrWhiteSpace(LoadData.Teams[ti].InputController)) { continue; } GameEngine.SetInput(LoadedState, ti, LoadedState.Scripts[LoadData.Teams[ti].InputController].CreateInstance <ACInputController>()); } // Create Camera LoadedCamera = new Camera(G.Viewport); LoadedCamera.Controller.Hook(game.Window); // Load The Renderer RendererInitArgs ria = ZXParser.ParseFile(@"Content\FX\RIA.txt", typeof(RendererInitArgs)) as RendererInitArgs; LoadedRenderer = new RTSRenderer(game.Graphics, game.Content, ria, game.Window); LoadedRenderer.HookToGame(LoadedState, 0, LoadedCamera); // Initialize Inputs int teami = -1; foreach (var t in LoadedState.teams) { teami++; if (t == null) { continue; } // Set Camera var vInput = t.Input as IVisualInputController; if (vInput != null) { vInput.Camera = LoadedCamera; } // Init t.Input.Init(LoadedState, t.Index, loadData.Teams[teami].InputInitArgs); // Build if (vInput != null) { vInput.Build(LoadedRenderer); } } // Create Gameplay LoadedGPlay = new GameplayController(); GCInitArgs gca = new GCInitArgs() { GameTypeScript = LoadData.GTController }; LoadedGPlay.Init(LoadedState, gca); } catch (Exception e) { if (LoadedRenderer != null) { LoadedRenderer.Dispose(); } loadException = e; } isLoaded = true; }
public override void Build() { uic = ZXParser.ParseFile(UIC_FILE, typeof(UICCompanyLogo)) as UICCompanyLogo; }