Ejemplo n.º 1
0
        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;
                    });
                }
            };
        }
Ejemplo n.º 2
0
 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();
     };
 }
Ejemplo n.º 3
0
 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();
     };
 }
Ejemplo n.º 4
0
        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);
        }
Ejemplo n.º 5
0
 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();
 }
Ejemplo n.º 6
0
 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();
 }
Ejemplo n.º 7
0
 public SceneWin(PositronGame game)
     : base(game)
 {
     SceneEntry += (sender, e) => {
         if(_Game.Player1 != null)
         {
             Follow(null);
             _Game.Player1.Derez();
         }
         WinThing.StartAnimation(WinThing.AnimationDefault);
         DerpTimer.Start();
     };
 }
Ejemplo n.º 8
0
 public SceneWin(PositronGame game) :
     base(game)
 {
     SceneEntry += (sender, e) => {
         if (_Game.Player1 != null)
         {
             Follow(null);
             _Game.Player1.Derez();
         }
         WinThing.StartAnimation(WinThing.AnimationDefault);
         DerpTimer.Start();
     };
 }
Ejemplo n.º 9
0
 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;
     //                });
     //            };
 }
Ejemplo n.º 10
0
        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();
        }
Ejemplo n.º 11
0
        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;
//                });
//            };
        }
Ejemplo n.º 12
0
 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();
 }
Ejemplo n.º 13
0
 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();
 }
Ejemplo n.º 14
0
        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);
                        }
                    });
                }
            };
        }
Ejemplo n.º 15
0
 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();
 }
Ejemplo n.º 16
0
 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();
 }
Ejemplo n.º 17
0
        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;
                     * });*/
                }
            };
        }
Ejemplo n.º 18
0
		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);
		}
Ejemplo n.º 19
0
        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);
                        }
                    });
                }
            };
        }
Ejemplo n.º 20
0
 protected SceneBasicBox(PositronGame game)
     : base(game)
 {
 }
Ejemplo n.º 21
0
 protected Scene(PositronGame game)
     : this(game, "Scene")
 {
     _Name = GetType ().Name;
 }
Ejemplo n.º 22
0
 protected SceneTwo(PositronGame game) :
     base(game)
 {
 }
Ejemplo n.º 23
0
 protected SceneFive(PositronGame game) :
     base(game)
 {
 }
Ejemplo n.º 24
0
 protected SceneSeven(PositronGame game) :
     base(game)
 {
 }
Ejemplo n.º 25
0
 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();
 }
Ejemplo n.º 26
0
 protected SceneSeven(PositronGame game)
     : base(game)
 {
 }
Ejemplo n.º 27
0
 /// <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);
     }
 }
Ejemplo n.º 28
0
 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);
 }
Ejemplo n.º 29
0
 protected SceneSix(PositronGame game) :
     base(game)
 {
 }
Ejemplo n.º 30
0
 protected Scene(PositronGame game) :
     this(game, "Scene")
 {
     _Name = GetType().Name;
 }
Ejemplo n.º 31
0
 protected SceneFour(PositronGame game)
     : base(game)
 {
 }
Ejemplo n.º 32
0
 protected SceneSix(PositronGame game)
     : base(game)
 {
 }
Ejemplo n.º 33
0
 protected SceneTwo(PositronGame game)
     : base(game)
 {
 }
Ejemplo n.º 34
0
 protected SceneBasicBox(PositronGame game) : base(game)
 {
 }
Ejemplo n.º 35
0
 protected SceneFour(PositronGame game) :
     base(game)
 {
 }