public Player() { _coordinates = new List <Coordinate>(16); Score = 0; Dead = false; EventDispatchThread.AddKeyListener(Directions); }
/// <summary> /// Removes a HotKey from this item. /// </summary> /// <param name="listener">The listener to be removed.</param> public void RemoveHotKeyListener(HotKeyListener listener) { if (HotKeyPressed == null) { return; } EventDispatchThread.RemoveKeyListener(OnKeyPressed); HotKeyPressed -= listener; }
/// <summary> /// Adds a HotKey to this item. /// </summary> /// <param name="binder">The console key to be binded.</param> /// <param name="listener">The listener that registers the event.</param> public void AddHotKeyListener(ConsoleKey binder, HotKeyListener listener) { if (HotKeyPressed != null) { return; } EventDispatchThread.AddKeyListener(OnKeyPressed); Binder = binder; HotKeyPressed += listener; }
public Snake() : base("Snake", Application.Theme) { int ticks = new Prompt("Game Speed (50-200)", Application.Theme).GetInt(new Range(50, 200)); EventDispatchThread.SetTick(ticks); Remove(ViewFactory.HEADER, true); Remove(ViewFactory.CONTENT, true); View footer = Get(ViewFactory.FOOTER); footer.Draw(); Add("score_view", new View( new Rectangle(footer.Rectangle.X + 20, footer.Rectangle.Y, footer.Rectangle.Width - 20, footer.Rectangle.Height), Application.Theme)); Get("score_view").Add(new Item("Player Score: ", Item.Alignment.CENTER, 0)); Rectangle bounds = new Rectangle(0, 0, Console.WindowWidth - 2, Console.WindowHeight - 2 - footer.Rectangle.Height); _map = new Map(bounds); EventDispatchThread.AddTickListener(OnTick); }
public void Dispose() { EventDispatchThread.RemoveKeyListener(Directions); }
public override void Dispose() { _map.Dispose(); EventDispatchThread.RemoveTickListener(OnTick); }