daily pastebin goal
65%
SHARE
TWEET

Untitled

a guest Jan 13th, 2018 54 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Drawing;
  6. using System.Windows.Forms;
  7.  
  8. namespace PixelWarfare
  9. {
  10.     /// <summary>
  11.     /// An abstract class that all game screens need to conform too.
  12.     /// </summary>
  13.     abstract class Screen
  14.     {
  15.         #region Fields
  16.  
  17.         private bool invalid;           // Whether the screen is invalid and needs to switch to nextScreen.
  18.         private Screen nextScreen;      // The screen you switch too when invalid is true.
  19.  
  20.         #endregion
  21.  
  22.         #region Abstract Methods
  23.  
  24.         /// <summary>
  25.         /// Draw the screen.
  26.         /// </summary>
  27.         /// <param name="g">Graphics to be drawn on.</param>
  28.         public abstract void Draw(Graphics g);
  29.  
  30.         /// <summary>
  31.         /// Update the state of the screen.
  32.         /// </summary>
  33.         public abstract void Update();
  34.  
  35.         /// <summary>
  36.         /// Do any action associated with the mouse moving over the screen.
  37.         /// </summary>
  38.         /// <param name="x">X coordinate.</param>
  39.         /// <param name="y">Y coordinate.</param>
  40.         public abstract void MouseMove(int x, int y);
  41.  
  42.         /// <summary>
  43.         /// Do any action associated with the mouse getting pressed.
  44.         /// </summary>
  45.         /// <param name="x">X coordinate.</param>
  46.         /// <param name="y">Y coordinate.</param>
  47.         public abstract void MousePress(int x, int y);
  48.  
  49.         /// <summary>
  50.         /// Do any action associated with the mouse getting released.
  51.         /// </summary>
  52.         /// <param name="x">X coordinate.</param>
  53.         /// <param name="y">Y coordinate.</param>
  54.         public abstract void MouseRelease(int x, int y);
  55.  
  56.         /// <summary>
  57.         /// Do any action associated with a key getting pressed.
  58.         /// </summary>
  59.         /// <param name="x">X coordinate.</param>
  60.         /// <param name="y">Y coordinate.</param>
  61.         public abstract void KeyPress(Keys key);
  62.  
  63.         /// <summary>
  64.         /// Do any action associated with a key getting released.
  65.         /// </summary>
  66.         /// <param name="x">X coordinate.</param>
  67.         /// <param name="y">Y coordinate.</param>
  68.         public abstract void KeyRelease(Keys key);
  69.  
  70.         #endregion
  71.  
  72.         #region Public Methods
  73.  
  74.         /// <summary>
  75.         /// Returns the next screen that needs to be switched too.
  76.         /// Will return null until the screen has expired and
  77.         /// Expired is set to true.
  78.         /// </summary>
  79.         /// <returns>The next screen to switch too.</returns>
  80.         public Screen NextScreen() { return nextScreen; }
  81.  
  82.         /// <summary>
  83.         /// Returns whether the screen is invalid and needs to be switched.
  84.         /// </summary>
  85.         /// <returns>Whether the screen is invalid.</returns>
  86.         public bool IsInvalid()
  87.         {
  88.             return invalid;
  89.         }
  90.  
  91.         /// <summary>
  92.         /// Sets the screen to valid when you ever you need to reload it.
  93.         /// </summary>
  94.         public void ValidateScreen()
  95.         {
  96.             invalid = false;
  97.         }
  98.  
  99.         #endregion
  100.  
  101.         #region Protected Methods
  102.  
  103.         /// <summary>
  104.         /// Sets the screen to invalid, and sets the next screen
  105.         /// to switch too.
  106.         /// </summary>
  107.         /// <param name="next">The next screen.</param>
  108.         protected void InvalidateScreen(Screen next)
  109.         {
  110.             nextScreen = next;
  111.             invalid = true;
  112.         }
  113.  
  114.         #endregion
  115.     }
  116. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top