protected SceneOne(PositronGame game) : base(game) { SceneEntry += (sender, e) => { if(!(e.From is SceneTwo)) { var stanzas = new List<DialogStanza>(); DialogSpeaker protagonist = DialogSpeaker.Get("protagonist"); DialogSpeaker radio = DialogSpeaker.Get("radio"); stanzas.Add(new DialogStanza(protagonist, "Where... Where am I?")); stanzas.Add(new DialogStanza(radio, "*bzzsk*")); stanzas.Add(new DialogStanza(protagonist, "Is this a two-way radio?")); stanzas.Add(new DialogStanza(radio, "*vvvVVVVzzzzt*")); stanzas.Add(new DialogStanza(radio, "Greetings life form!")); stanzas.Add(new DialogStanza(protagonist, "Hey! Does this thing work?")); stanzas.Add(new DialogStanza(radio, "I hear you just fine.")); stanzas.Add(new DialogStanza(radio, "You need to make your way out of this area\nas soon as you possibly can.")); stanzas.Add(new DialogStanza(protagonist, "Who are you?!\nWhy do I need to leave?")); stanzas.Add(new DialogStanza(radio, "There's no time to explain.\nPlease just trust me.")); stanzas.Add(new DialogStanza(protagonist, "Okay, but why should I trust you?")); stanzas.Add(new DialogStanza(radio, "I've got to go...")); stanzas.Add(new DialogStanza(radio, "*clk-hsssss*")); var dialog = new Dialog(e.To.HUD, "Dialog", stanzas); dialog.Begin(); _Game.AddUpdateEventHandler(this, (sender2, e2) => { _Game.Player1.PositionX = FirstTile.PositionX; _Game.Player1.PositionY = FirstTile.PositionY + 0.5 * (FirstTile.SizeY + _Game.Player1.Texture.DefaultRegion.SizeY); return true; }); } }; }
protected SceneThree(PositronGame game) : base(game) { SceneEntry += (sender, e) => { var stanzas = new List<DialogStanza>(); DialogSpeaker speaker = DialogSpeaker.Get("protagonist"); stanzas.Add(new DialogStanza(speaker, "This room is eerily empty...")); var dialog = new Dialog(e.To.HUD, "Dialog", stanzas); dialog.Begin(); }; }
protected SceneThree(PositronGame game) : base(game) { SceneEntry += (sender, e) => { var stanzas = new List <DialogStanza>(); DialogSpeaker speaker = DialogSpeaker.Get("protagonist"); stanzas.Add(new DialogStanza(speaker, "This room is eerily empty...")); var dialog = new Dialog(e.To.HUD, "Dialog", stanzas); dialog.Begin(); }; }
void RenderLoop() { MakeCurrent(); // The context now belongs to this thread. No other thread may use it! while (!Exiting) { using (_Game = new PositronGame(this)) { //Game setup // Since we don't use OpenTK's timing mechanism, we need to keep time ourselves; UpdateWatch.Start(); RenderWatch.Start(); FrameWatch.Start(); TestWatch.Start(); RenderDrawingWatch.Start(); while (!Reset && !Exiting) { // Store this in a local variable because accessors have overhead! // Bear with me...this will get a bit tricky to explain pefrectly... // Sleep the thread for the most milliseconds less than the frame limit time double time_until = FrameLimitTime - Configuration.ThreadSleepTimeStep * 0.001; while (FrameWatch.Elapsed.TotalSeconds < time_until) { Thread.Sleep(Configuration.ThreadSleepTimeStep); // Does this help? } // Hard-loop the remainder while (FrameWatch.Elapsed.TotalSeconds < FrameLimitTime) { ; } _LastFrameTime = FrameWatch.Elapsed.TotalSeconds; //Console.WriteLine(_LastFrameTime); FrameWatch.Restart(); UpdateWatch.Restart(); lock (_Game.UpdateLock) Update(_LastFrameTime); _LastUpdateTime = UpdateWatch.Elapsed.TotalSeconds; RenderWatch.Restart(); lock (_Game.UpdateLock) RenderView(_LastFrameTime); // TODO: Figure out why this does wild shit if FPS > 60 SwapBuffers(); _LastRenderTime = UpdateWatch.Elapsed.TotalSeconds; } Sound.KillTheNoise(); // I don't know where a better place for this could be... Reset = false; } } Context.MakeCurrent(null); }
protected SceneFirstMenu(PositronGame game) : base(game) { UIGroup = new UIElementGroup(); SceneEntry += (sender, e) => { _Game.SetInputAccepters("Main Menu", new IInputAccepter[] { UIGroup }); }; SceneExit += (sender, e) => { _Game.RemoveInputAccepters("Main Menu"); }; SetupPlayerOnExit(); }
public SceneWin(PositronGame game) : base(game) { SceneEntry += (sender, e) => { if(_Game.Player1 != null) { Follow(null); _Game.Player1.Derez(); } WinThing.StartAnimation(WinThing.AnimationDefault); DerpTimer.Start(); }; }
public SceneWin(PositronGame game) : base(game) { SceneEntry += (sender, e) => { if (_Game.Player1 != null) { Follow(null); _Game.Player1.Derez(); } WinThing.StartAnimation(WinThing.AnimationDefault); DerpTimer.Start(); }; }
protected SceneEight(PositronGame game) : base(game) { // Debugging purposes // SceneEntry += (sender, e) => { // Program.MainGame.AddUpdateEventHandler(this, (sender1, e1) => { // if(Program.MainGame.Player1 != null) // { // Program.MainGame.Player1.Position = DoorToNextScene.Position; // return true; // } // return false; // }); // }; }
public static void Main() { // Instantiate the main window // this also sets up OpenGL var main_window = new ThreadedRendering(); // Prepare game resources // This makes OpenGL calls PositronGame.InitialSetup(); // TEST: Dump all the settings: //Configuration.DumpEverything (); // Run the window thread // Game will be set up by render/update thread -because reasons- main_window.Run(); }
public SceneIntro(PositronGame game) : base(game) { SceneEntry += (sender, e) => { var stanzas = new List<DialogStanza>(); DialogSpeaker speaker = null;//DialogSpeaker.Get("protagonist"); stanzas.Add(new DialogStanza(speaker, ">electrical humming")); stanzas.Add(new DialogStanza(speaker, ">electrical humming\n...")); var dialog = new Dialog(e.To.HUD, "Dialog", stanzas); dialog.DialogEnd += (sender2, e2) => { _Game.CurrentScene = ((Scene)_Game.Scenes["SceneOne"]); }; dialog.Begin(); }; SetupPlayerOnExit(); }
public SceneIntro(PositronGame game) : base(game) { SceneEntry += (sender, e) => { /*var stanzas = new List<DialogStanza>(); * DialogSpeaker speaker = null;//DialogSpeaker.Get("protagonist"); * stanzas.Add(new DialogStanza(speaker, ">electrical humming")); * stanzas.Add(new DialogStanza(speaker, ">electrical humming\n...")); * var dialog = new Dialog(e.To.HUD, "Dialog", stanzas); * dialog.DialogEnd += (sender2, e2) => * { * _Game.CurrentScene = ((Scene)_Game.Scenes["SceneOne"]); * }; * dialog.Begin();*/ _Game.CurrentScene = ((Scene)_Game.Scenes["SceneOne"]); }; SetupPlayerOnExit(); }
protected Scene(PositronGame game, string name) { _Game = game; _Name = name; // TODO: This is awful. Fix it. // TODO: Actually fix this. // TODO: Seriously, make this -not suck- ViewWidth = _Game.Window.CanvasWidth; ViewHeight = _Game.Window.CanvasHeight; Background = new RenderSet(this); Rear = new RenderSet(this); Stage = new RenderSet(this); Tests = new RenderSet(this); Front = new RenderSet(this); WorldBlueprint = new RenderSet(this); HUD = new RenderSet(this); HUDBlueprint = new RenderSet(this); HUDDebug = new RenderSet(this); // This should contain everything AllRenderSetsInOrder would contain // This is an optimization over using an enumerable //All = new RenderSet(this, Background, Rear, Stage, Tests, Front, HUD, HUDBlueprint, HUDDebug); SceneEntry += (sender, e) => { foreach (RenderSet render_set in AllRenderSetsInOrder()) { render_set.ForEach(element => { if (element is IWorldObject) { IWorldObject w_o = (IWorldObject)element; //Console.WriteLine("Rotation for {0} sprite with rotation {1}", w_o, w_o.Theta); } }); } }; }
public SceneCredits(PositronGame game) : base(game) { SceneEntry += (sender, e) => { var stanzas = new List <DialogStanza>(); DialogSpeaker speaker = null;//DialogSpeaker.Get("protagonist"); stanzas.Add(new DialogStanza(speaker, "Artwork: Music: Programming:\n" + "Fernando Corrales A-Zu-Ra Vince BG \n" + "Megan Groden Laurence Simmonds Will Pham \n" + "Vince BG Vince BG \n" + " Will Pham \n")); var dialog = new Dialog(e.To.HUD, "Dialog", stanzas); dialog.DialogEnd += (sender2, e2) => { _Game.CurrentScene = ((Scene)_Game.Scenes["SceneFirstMenu"]); }; dialog.Begin(); }; SetupPlayerOnExit(); MainTimer.Restart(); }
public SceneCredits(PositronGame game) : base(game) { SceneEntry += (sender, e) => { var stanzas = new List<DialogStanza>(); DialogSpeaker speaker = null;//DialogSpeaker.Get("protagonist"); stanzas.Add(new DialogStanza(speaker, "Artwork: Music: Programming:\n" + "Fernando Corrales A-Zu-Ra Vince BG \n" + "Megan Groden Laurence Simmonds Will Pham \n" + "Vince BG Vince BG \n" + " Will Pham \n")); var dialog = new Dialog(e.To.HUD, "Dialog", stanzas); dialog.DialogEnd += (sender2, e2) => { _Game.CurrentScene = ((Scene)_Game.Scenes["SceneFirstMenu"]); }; dialog.Begin(); }; SetupPlayerOnExit(); MainTimer.Restart(); }
protected SceneOne(PositronGame game) : base(game) { SceneEntry += (sender, e) => { if (!(e.From is SceneTwo)) { /*var stanzas = new List<DialogStanza>(); * DialogSpeaker protagonist = DialogSpeaker.Get("protagonist"); * DialogSpeaker radio = DialogSpeaker.Get("radio"); * stanzas.Add(new DialogStanza(protagonist, "Where... Where am I?")); * stanzas.Add(new DialogStanza(radio, "*bzzsk*")); * stanzas.Add(new DialogStanza(protagonist, "Is this a two-way radio?")); * stanzas.Add(new DialogStanza(radio, "*vvvVVVVzzzzt*")); * stanzas.Add(new DialogStanza(radio, "Greetings life form!")); * stanzas.Add(new DialogStanza(protagonist, "Hey! Does this thing work?")); * stanzas.Add(new DialogStanza(radio, "I hear you just fine.")); * stanzas.Add(new DialogStanza(radio, "You need to make your way out of this area\nas soon as you possibly can.")); * stanzas.Add(new DialogStanza(protagonist, "Who are you?!\nWhy do I need to leave?")); * stanzas.Add(new DialogStanza(radio, "There's no time to explain.\nPlease just trust me.")); * stanzas.Add(new DialogStanza(protagonist, "Okay, but why should I trust you?")); * stanzas.Add(new DialogStanza(radio, "I've got to go...")); * stanzas.Add(new DialogStanza(radio, "*clk-hsssss*"));*/ //var dialog = new Dialog(e.To.HUD, "Dialog", stanzas); //dialog.Begin(); /*_Game.AddUpdateEventHandler(this, (sender2, e2) => * { * _Game.Player1.PositionX = FirstTile.PositionX; * _Game.Player1.PositionY = * FirstTile.PositionY + 0.5 * (FirstTile.SizeY + _Game.Player1.Texture.DefaultRegion.SizeY); * return true; * });*/ } }; }
void RenderLoop () { MakeCurrent (); // The context now belongs to this thread. No other thread may use it! while (!Exiting) { using (_Game = new PositronGame (this)) { //Game setup // Since we don't use OpenTK's timing mechanism, we need to keep time ourselves; UpdateWatch.Start (); RenderWatch.Start (); FrameWatch.Start (); TestWatch.Start (); RenderDrawingWatch.Start (); while (!Reset && !Exiting) { // Store this in a local variable because accessors have overhead! // Bear with me...this will get a bit tricky to explain pefrectly... // Sleep the thread for the most milliseconds less than the frame limit time double time_until = FrameLimitTime - Configuration.ThreadSleepTimeStep * 0.001; while (FrameWatch.Elapsed.TotalSeconds < time_until) Thread.Sleep (Configuration.ThreadSleepTimeStep); // Does this help? // Hard-loop the remainder while (FrameWatch.Elapsed.TotalSeconds < FrameLimitTime); _LastFrameTime = FrameWatch.Elapsed.TotalSeconds; //Console.WriteLine(_LastFrameTime); FrameWatch.Restart (); UpdateWatch.Restart (); lock (_Game.UpdateLock) Update (_LastFrameTime); _LastUpdateTime = UpdateWatch.Elapsed.TotalSeconds; RenderWatch.Restart (); lock (_Game.UpdateLock) RenderView (_LastFrameTime); // TODO: Figure out why this does wild shit if FPS > 60 SwapBuffers (); _LastRenderTime = UpdateWatch.Elapsed.TotalSeconds; } Sound.KillTheNoise (); // I don't know where a better place for this could be... Reset = false; } } Context.MakeCurrent(null); }
protected Scene(PositronGame game, string name) { _Game = game; _Name = name; // TODO: This is awful. Fix it. // TODO: Actually fix this. // TODO: Seriously, make this -not suck- ViewWidth = _Game.Window.CanvasWidth; ViewHeight = _Game.Window.CanvasHeight; Background = new RenderSet(this); Rear = new RenderSet(this); Stage = new RenderSet(this); Tests = new RenderSet(this); Front = new RenderSet(this); WorldBlueprint = new RenderSet(this); HUD = new RenderSet(this); HUDBlueprint = new RenderSet(this); HUDDebug = new RenderSet(this); // This should contain everything AllRenderSetsInOrder would contain // This is an optimization over using an enumerable //All = new RenderSet(this, Background, Rear, Stage, Tests, Front, HUD, HUDBlueprint, HUDDebug); SceneEntry += (sender, e) => { foreach(RenderSet render_set in AllRenderSetsInOrder()) { render_set.ForEach (element => { if(element is IWorldObject) { IWorldObject w_o = (IWorldObject)element; //Console.WriteLine("Rotation for {0} sprite with rotation {1}", w_o, w_o.Theta); } }); } }; }
protected SceneBasicBox(PositronGame game) : base(game) { }
protected Scene(PositronGame game) : this(game, "Scene") { _Name = GetType ().Name; }
protected SceneTwo(PositronGame game) : base(game) { }
protected SceneFive(PositronGame game) : base(game) { }
protected SceneSeven(PositronGame game) : base(game) { }
public static void InitializeScenes(ref PositronGame game) { foreach(Scene scene in game.Scenes.Values) scene.InstantiateConnections(); foreach(Scene scene in game.Scenes.Values) scene.InitializeScene(); }
/// <summary> /// Instantiates and initializes one instnace /// of every subclass of Scene in this assembly /// </summary> public static void InstantiateScenes(ref PositronGame game) { // Brave new world: game.WorldMain = new World(new Microsoft.Xna.Framework.Vector2(0.0f, (float)Configuration.ForceDueToGravity)); // This is EVIL: IEnumerable<Type> model_enum = typeof(Scene).FindAllEndClasses (); foreach (Type m in model_enum) { Console.WriteLine("Picked {0}", m.Name); } foreach (Type m in model_enum) { BindingFlags flags = BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance; ConstructorInfo ctor = m.GetConstructor(flags, null, new Type[] { }, null); object instanace = ctor.Invoke(null); Scene scene = (Scene)instanace; game.Scenes.Add(scene.Name, scene); } }
public static void SetupScenes(ref PositronGame game) { Scene.InstantiateScenes(ref game); // Instantiate one of each of the scenes defined in this entire assembly game.CurrentScene = (Scene)Program.MainGame.Scenes["SceneFirstMenu"]; Scene.InitializeScenes(ref game); }
protected SceneSix(PositronGame game) : base(game) { }
protected Scene(PositronGame game) : this(game, "Scene") { _Name = GetType().Name; }
protected SceneFour(PositronGame game) : base(game) { }