Exemple #1
0
 public Player()
 {
     _coordinates = new List <Coordinate>(16);
     Score        = 0;
     Dead         = false;
     EventDispatchThread.AddKeyListener(Directions);
 }
Exemple #2
0
 /// <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;
 }
Exemple #3
0
 /// <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;
 }
Exemple #4
0
        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);
        }
Exemple #5
0
 public void Dispose()
 {
     EventDispatchThread.RemoveKeyListener(Directions);
 }
Exemple #6
0
 public override void Dispose()
 {
     _map.Dispose();
     EventDispatchThread.RemoveTickListener(OnTick);
 }