public void Load() { engine = new SharpScript(); engine.CompileCode(Template.Code, new InterfaceInteraction(this, spriteBatch, this.PlayerEntity)); engine.Invoke("Initialize"); }
public void Load(string loc) { script = new SharpScript(); try { string location = Environment.CurrentDirectory + "\\Scripts\\Logic\\" + loc + (loc.EndsWith(".cs") ? "" : ".cs"); name = loc.Split('0')[0]; string code = File.ReadAllText(location); script.CompileCode(code); script.Invoke("Load", this); Console.WriteLine("s_0: " + s_0); } catch (Exception e) { Console.ForegroundColor = ConsoleColor.Red; Console.WriteLine("-- Error (" + e.GetType() + "): " + e.Message); Console.ResetColor(); } }
public SetTileAction Evaluate(int x, int y) { try { MockupTile tu = EditorEngine.Instance.CurrentMap.GetTile(x, y - 1, EditorEngine.Instance.SelectedLayer); MockupTile td = EditorEngine.Instance.CurrentMap.GetTile(x, y + 1, EditorEngine.Instance.SelectedLayer); MockupTile tl = EditorEngine.Instance.CurrentMap.GetTile(x - 1, y, EditorEngine.Instance.SelectedLayer); MockupTile tr = EditorEngine.Instance.CurrentMap.GetTile(x + 1, y, EditorEngine.Instance.SelectedLayer); MockupTile tul = EditorEngine.Instance.CurrentMap.GetTile(x - 1, y - 1, EditorEngine.Instance.SelectedLayer); MockupTile tur = EditorEngine.Instance.CurrentMap.GetTile(x + 1, y - 1, EditorEngine.Instance.SelectedLayer); MockupTile tdl = EditorEngine.Instance.CurrentMap.GetTile(x - 1, y + 1, EditorEngine.Instance.SelectedLayer); MockupTile tdr = EditorEngine.Instance.CurrentMap.GetTile(x + 1, y + 1, EditorEngine.Instance.SelectedLayer); bool u = isSameType(tu); bool d = isSameType(td); bool l = isSameType(tl); bool r = isSameType(tr); bool ul = isSameType(tul); bool ur = isSameType(tur); bool dl = isSameType(tdl); bool dr = isSameType(tdr); LogicEvalInfo _info = new LogicEvalInfo("", 0); script.Invoke("Eval", this, _info, u, d, l, r, ul, ur, dl, dr); int zt = EditorEngine.Instance.SelectedLayer; MockupTile t = EditorEngine.Instance.CurrentMap.GetTile(x, y, zt); if (t == null) { return(null); } SetTileAction act = new SetTileAction(x, y, zt, EditorEngine.Instance.World.TilesetContainer.IndexOf(EditorEngine.Instance.GetTilesetByName(_info.s1)), _info.s2); return(act); } catch (Exception e) { Console.ForegroundColor = ConsoleColor.Red; Console.WriteLine("-- Error (" + e.GetType() + "): " + e.Message); //GameConsole.WriteLine("Info: " + e.Value.Value); Console.WriteLine("\r\n\r\n"); Console.ResetColor(); } return(null); }
public void Draw(GameTime gameTime) { spriteBatch.Begin(); engine.Invoke("Draw", gameTime); spriteBatch.End(); }