public static async void AddScripts() { //Get every c# file in our scripts folder string[] names = Directory.GetFiles(@"..\..\..\..\..\Scripts\", "*.cs"); foreach (var name in names) { string body = ""; if (File.Exists(name) == false) { Console.WriteLine("file not found: " + name); continue; } else { // I use CSSCript to load the cs files which has its own tag for adding or removing refrences // CSScript uses reflection to create a temporary type which creates refrence conflicts, so i // force only one refrence to most xna libraries and a refrence to this namespace using the css_ tags try { string header = "//css_ignore_namespace Microsoft.Xna.Framework " + "\n//css_ignore_namespace Microsoft.Xna.Framework.Graphics " + "\n//css_ignore_namespace Microsoft.Xna.Framework.Input " + "\n//css_ref MonoGame.Framework.dll " + "\nusing EmergingTech; " + "\nusing Microsoft.Xna.Framework; " + "\nusing Microsoft.Xna.Framework.Graphics; " + "\nusing Microsoft.Xna.Framework.Input; \n"; body = await ReadFileAsync(name); body = header + body; } catch (Exception e) { Console.WriteLine(e.Message); } } //Used to create dynamic assemblies AsmHelper assembly = null; try { //Load code into our assembly and put this assembly on our app domain // use of 'using' to make sure we dispose our temp files using (assembly = new AsmHelper(CSScript.LoadCode(body, null, true))) { //create our object from our assembly as a gamescript GameScript script = (GameScript)assembly.CreateObject("*"); script.name = name; gameScripts.Add(script); } } catch (Exception e) { Console.WriteLine(e.Message); } } Start(); }
public Transform(GameScript _owner, Vector2?_position = null) { owner = _owner; position = (_position == null) ? Vector2.Zero : _position.Value; scale = Vector2.One; }
public Collider(GameScript _owner, Rectangle _rect) { owner = _owner; rect = _rect; }
public virtual void OnCollision(GameScript other) { }