Advertisement
Guest User

wccd62018

a guest
Jun 20th, 2018
95
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 5.28 KB | None | 0 0
  1. using Microsoft.Xna.Framework;
  2. using Microsoft.Xna.Framework.Input;
  3. using System;
  4. using ScreenManager = LoveLace.Screens.ScreenManager;
  5. using StateManager = LoveLace.GameStates.StateManager;
  6. using Splash = LoveLace.GameStates.Load.Splash;
  7. using Engine = LoveLace.UX.Engine;
  8. using Microsoft.Xna.Framework.Audio;
  9.  
  10. namespace LoveLace
  11. {
  12.     public class Game : SadConsole.Game
  13.     {
  14.         //SpriteBatch spriteBatch;
  15.         public static Game MyGame;
  16.         public static Random ORandom = new Random();
  17.         public const int ProgramWidth = 100; // * 8 = 800
  18.         public const int ProgramHeight = 38; // * 16 = 608
  19.         public SoundEffect AudioClick;
  20.  
  21.         public Game() : base("IBM.font", ProgramWidth, ProgramHeight, null)
  22.         {
  23.             Content.RootDirectory = "Content";
  24.         }
  25.  
  26.         /// <summary>
  27.         /// Allows the game to perform any initialization it needs to before starting to run.
  28.         /// This is where it can query for any required services and load any non-graphic
  29.         /// related content.  Calling base.Initialize will enumerate through any components
  30.         /// and initialize them as well.
  31.         /// </summary>
  32.         protected override void Initialize()
  33.         {
  34.             // Generally you don't want to hide the mouse from the user
  35.             IsMouseVisible = true;
  36.  
  37.             // Finish the initialization of SadConsole
  38.             base.Initialize();
  39.  
  40.             // Initialize LoveLace, this order of initialization is not arbitrary
  41.             // 0 - Initialize states, this mostly consists of initializing consoles, but not exclusively
  42.             //   0.a - Initializes Splash Console
  43.             //   0.b - Initializes Menu Consoles, and Context Objects, and Config Options
  44.             //   0.c - For now, it Initializes Engine Consoles... TODO Consoles for other aspects of Root State
  45.             // 1 - Now that the consoles are available, Initialize screens, so that we can display them to the user
  46.             // 2 - Initialize User Array in Registrar
  47.             // 3 - Initialize the individual components of the UX Engine, Such as Inspector & Store
  48.  
  49.             MyGame = this;
  50.  
  51.             StateManager.Initialize.States();   // 0
  52.             ScreenManager.Initialize.Screens(); // 1
  53.             Registrar.Initialize.Users();       // 2
  54.             Engine.Initialize.Components();     // 3
  55.  
  56.             PromptInstallationStatus(true);
  57.         }
  58.  
  59.         /// <summary>
  60.         /// LoadContent will be called once per game and is the place to load
  61.         /// all of your content.
  62.         /// </summary>
  63.         protected override void LoadContent()
  64.         {
  65.             // Create a new SpriteBatch, which can be used to draw textures.
  66.             //spriteBatch = new SpriteBatch(GraphicsDevice);
  67.  
  68.             // TODO: use this.Content to load your game content here
  69.             this.AudioClick = Content.Load<SoundEffect>("click");
  70.         }
  71.  
  72.         /// <summary>
  73.         /// UnloadContent will be called once per game and is the place to unload
  74.         /// game-specific content.
  75.         /// </summary>
  76.         protected override void UnloadContent()
  77.         {
  78.             // TODO: Unload any non ContentManager content here
  79.         }
  80.  
  81.         protected override void Update(GameTime gameTime)
  82.         {
  83.             if (GamePad.GetState(PlayerIndex.One).Buttons.Back == ButtonState.Pressed || Keyboard.GetState().IsKeyDown(Keys.Escape))
  84.                 Exit();
  85.  
  86.             if (IO.IOController.State != IO.IOController.States.Idle)
  87.             {
  88.                 switch (IO.IOController.State)
  89.                 {
  90.                     case IO.IOController.States.LoadUsers:
  91.                         IO.IOController.LoadUsers();
  92.                         break;
  93.                     case IO.IOController.States.LoadSession:
  94.                         IO.IOController.LoadSession();
  95.                         break;
  96.                 }
  97.             }
  98.             else if (Registrar.Global.SessionIsActive())
  99.             {
  100.                 UX.Engine.Update(gameTime.ElapsedGameTime.TotalSeconds);
  101.             }
  102.             // the else if prevents updates from happening while the io.controller is loading data?
  103.             // Todo - clean this shit up
  104.             base.Update(gameTime);
  105.         }
  106.  
  107.         void PromptInstallationStatus(bool forceInstallation = false)
  108.         {
  109.             GameStates.StateManager.SelectState(0);
  110.  
  111.             if (forceInstallation)
  112.             {
  113.                 Splash.Display.PrintInstallPrompt();
  114.             }
  115.             else
  116.             {
  117.                 if (IO.Install.Parity.ConfirmInstallationExists())
  118.                 {
  119.                     Splash.PrintUsrLoadBar(0);
  120.                     IO.IOController.Boot();
  121.                 }
  122.                 else
  123.                 {
  124.                     Splash.Display.PrintInstallPrompt();
  125.                 }
  126.             }
  127.         }
  128.     }
  129. }
  130.  
  131. /// I dont think I need this part of monogame?
  132. ///// <summary>
  133. ///// This is called when the game should draw itself.
  134. ///// </summary>
  135. ///// <param name="gameTime">Provides a snapshot of timing values.</param>
  136. //protected override void Draw(GameTime gameTime)
  137. //{
  138. //    GraphicsDevice.Clear(Color.CornflowerBlue);
  139.  
  140. //    // TODO: Add your drawing code here
  141.  
  142. //    base.Draw(gameTime);
  143. //}
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement