Advertisement
Guest User

Untitled

a guest
May 23rd, 2019
62
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 2.39 KB | None | 0 0
  1. namespace BoardGame {
  2.     //TODO UnityEngine.Vector2/UnityEngine.Vector2Int
  3.     public struct Coordinate {
  4.         public int x;
  5.         public int y;
  6.     }
  7.  
  8.     //TODO UnityEngine.Color
  9.     public struct Color {
  10.         public float r;
  11.         public float g;
  12.         public float b;
  13.     }
  14.  
  15.     public abstract class Board {
  16.         public delegate void ButtonEventHandler(int x, int y);
  17.         public event ButtonEventHandler OnButtonUp;
  18.         public event ButtonEventHandler OnButtonDown;
  19.  
  20.         public abstract int Width { get; } //TODO add setter?
  21.         public abstract int Height { get; } //TODO add setter?
  22.  
  23.         /// <summary>
  24.         /// As communicating with the board hardware may take some time it should only be done
  25.         /// in update. Update then caches all relevant information which can be accessed by the
  26.         /// other methods of this class.
  27.         /// This means Update should not be called every frame but in it´s own loop on a background Thread
  28.         /// </summary>
  29.         public abstract void Update();
  30.  
  31.         /// <summary>
  32.         /// Turns off all LEDs and resents all button states
  33.         /// </summary>
  34.         public abstract void Reset();
  35.  
  36.  
  37.         /// <summary>
  38.         /// Automatically detects the board size.
  39.         /// Time intensive but should only be called once anyway
  40.         /// </summary>
  41.         public abstract void DetectSize();
  42.         public abstract void GetSize(out int width, out int height);
  43.         public abstract void SetSize(int width, int height);
  44.  
  45.         public abstract void SetLEDColor(Color color, Coordinate coordinate);
  46.         public void SetLEDColor(Color color, IList<Coordinate> coordinates) {
  47.             SetLEDColor(color, coordinates, 0, coordinates.Count);
  48.         }
  49.         public abstract void SetLEDColor(Color color, IList<Coordinate> coordinates, int offset, int count);
  50.         public abstract Color GetLEDColor(Coordinate coordinate);
  51.         /// <summary>
  52.         /// Turns off all LEDs
  53.         /// </summary>
  54.         public abstract void ClearAllLEDS();
  55.  
  56.         //TODO not sure if they should be used as Board.Update probably should not happen every frame (it´s time intensive)
  57.         public abstract bool GetButton(Coordinate coordinate);
  58.         public abstract bool GetButtonUp(Coordinate coordinate);
  59.         public abstract bool GetButtonDown(Coordinate coordinate);
  60.     }
  61. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement