/// <summary> /// loads an entity from a file /// </summary> /// <param name="filename">lua file name</param> /// <returns>the platform from the file</returns> public static Platform LoadFromFile(string filename, SSCGame game) { Platform platform = new Platform(); platform.State.LoadCLRPackage(); platform.State.DoFile(filename); platform.State.GetFunction("OnCreation")?.Call(platform, game); platform.OnUpdate = platform.State.GetFunction("OnUpdate"); platform.OnCollision = platform.State.GetFunction("OnCollision"); return(platform); }
/// <summary> /// loads an entity from a file /// </summary> /// <param name="filename">lua file name</param> /// <returns>the entity from the file</returns> public static Entity LoadFromFile(string filename, SSCGame game) { Entity entity = new Entity(); entity.game = game; entity.State.LoadCLRPackage(); entity.State.DoFile(filename); entity.State.GetFunction("OnCreation")?.Call(entity, game); entity.OnUpdate = entity.State.GetFunction("OnUpdate"); game.Events.On("update", () => { entity.OnUpdate?.Call(); }); entity.OnEntityCollision = entity.State.GetFunction("OnEntityCollision"); entity.OnSolidCollision = entity.State.GetFunction("OnSolidCollision"); return(entity); }
/// <summary> /// loads a gamemode from a lua file /// </summary> /// <param name="filename">the lua file to load the gamemode from</param> /// <param name="game">the game</param> /// <returns>the created gamemode</returns> public static Gamemode LoadFromFile(string filename, SSCGame game) { Lua state = new Lua(); state.LoadCLRPackage(); state.DoFile(filename); Gamemode gamemode = new Gamemode(); state.GetFunction("OnCreation")?.Call(gamemode, game); gamemode.OnStart = state.GetFunction("OnStart"); gamemode.OnUpdate = state.GetFunction("OnUpdate"); game.Events.On("update", () => { gamemode.OnUpdate?.Call(); }); gamemode.OnNewUser = state.GetFunction("OnNewUser"); return(gamemode); }
/// <summary> /// constructs an entity with default values /// </summary> public Entity() { X = 0; Y = 0; DX = 0; DY = 0; Width = 0; Height = 0; RepelAmount = 0; OnUpdate = null; OnEntityCollision = null; OnSolidCollision = null; State = new Lua(); Image = null; imageName = ""; Color = new Color(255, 255, 255); CollideWithPlatforms = true; CollideWithEntities = true; Friction = 0.1; this.game = null; }
static void Main() { //Debug.WriteLine("test"); using (var game = new SSCGame()) game.Run(); }
/// <summary> /// creates a user /// </summary> /// <param name="game">the game</param> /// <param name="number">the number of the user</param> /// <param name="input">input module for the user</param> public User(SSCGame game, int number, InputModule input) { Number = number; Input = input; this.game = game; }