Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Drawing;
- using System.Windows.Forms;
- namespace PixelWarfare
- {
- /// <summary>
- /// An abstract class that all game screens need to conform too.
- /// </summary>
- abstract class Screen
- {
- #region Fields
- private bool invalid; // Whether the screen is invalid and needs to switch to nextScreen.
- private Screen nextScreen; // The screen you switch too when invalid is true.
- #endregion
- #region Abstract Methods
- /// <summary>
- /// Draw the screen.
- /// </summary>
- /// <param name="g">Graphics to be drawn on.</param>
- public abstract void Draw(Graphics g);
- /// <summary>
- /// Update the state of the screen.
- /// </summary>
- public abstract void Update();
- /// <summary>
- /// Do any action associated with the mouse moving over the screen.
- /// </summary>
- /// <param name="x">X coordinate.</param>
- /// <param name="y">Y coordinate.</param>
- public abstract void MouseMove(int x, int y);
- /// <summary>
- /// Do any action associated with the mouse getting pressed.
- /// </summary>
- /// <param name="x">X coordinate.</param>
- /// <param name="y">Y coordinate.</param>
- public abstract void MousePress(int x, int y);
- /// <summary>
- /// Do any action associated with the mouse getting released.
- /// </summary>
- /// <param name="x">X coordinate.</param>
- /// <param name="y">Y coordinate.</param>
- public abstract void MouseRelease(int x, int y);
- /// <summary>
- /// Do any action associated with a key getting pressed.
- /// </summary>
- /// <param name="x">X coordinate.</param>
- /// <param name="y">Y coordinate.</param>
- public abstract void KeyPress(Keys key);
- /// <summary>
- /// Do any action associated with a key getting released.
- /// </summary>
- /// <param name="x">X coordinate.</param>
- /// <param name="y">Y coordinate.</param>
- public abstract void KeyRelease(Keys key);
- #endregion
- #region Public Methods
- /// <summary>
- /// Returns the next screen that needs to be switched too.
- /// Will return null until the screen has expired and
- /// Expired is set to true.
- /// </summary>
- /// <returns>The next screen to switch too.</returns>
- public Screen NextScreen() { return nextScreen; }
- /// <summary>
- /// Returns whether the screen is invalid and needs to be switched.
- /// </summary>
- /// <returns>Whether the screen is invalid.</returns>
- public bool IsInvalid()
- {
- return invalid;
- }
- /// <summary>
- /// Sets the screen to valid when you ever you need to reload it.
- /// </summary>
- public void ValidateScreen()
- {
- invalid = false;
- }
- #endregion
- #region Protected Methods
- /// <summary>
- /// Sets the screen to invalid, and sets the next screen
- /// to switch too.
- /// </summary>
- /// <param name="next">The next screen.</param>
- protected void InvalidateScreen(Screen next)
- {
- nextScreen = next;
- invalid = true;
- }
- #endregion
- }
- }
Add Comment
Please, Sign In to add comment