Exemple #1
0
        public npcMenu(gamemain parent)
        {
            game = parent;
            menuMaxIndex = Enum.GetValues(typeof(menuItems)).Length;
            keyMapping_ = new Dictionary<ConsoleKey, Action>() { { ConsoleKey.UpArrow  , () => this.Next()        },
                                                                 { ConsoleKey.DownArrow, () => this.Previous()    },
                                                                 { ConsoleKey.Enter    , () => this.executeMenu() } };

            executeMenuDic = new Dictionary<menuItems, Action>(){ {menuItems.EndTurn, () => game.runturn()},
                                                                  {menuItems.Move   , () => game.move()   },
                                                                  {menuItems.Select , () => game.select() } };
        }
Exemple #2
0
        public grid(int x, int y, gamemain parent)
        {
            keyMapping = new Dictionary<ConsoleKey, Action>() {  { ConsoleKey.UpArrow, () => this.Up() },
                                                                 { ConsoleKey.DownArrow, () => this.Down() },
                                                                 { ConsoleKey.RightArrow, () => this.Right() },
                                                                 { ConsoleKey.LeftArrow, () => this.Left() },
                                                                 { ConsoleKey.Enter, () => this.exec()} };

            grid_ = new gridcell[x, y];
            selectedindex = Tuple.Create(0, 0);
            game = parent;
        }
Exemple #3
0
        public static void Main(string[] args)
        {
            Console.Title           = "Tactical Grid";
            Console.CursorVisible   = false;
            Console.CancelKeyPress += new ConsoleCancelEventHandler(Console_CancelKeyPress);


            gamemain game   = new gamemain();
            TimeSpan deltaT = new TimeSpan();
            //List<TimeSpan> List = new List<TimeSpan>();
            //List<TimeSpan> List2 = new List<TimeSpan>();
            //List2.Add(TimeSpan.Zero);
            //List<TimeSpan> List3 = new List<TimeSpan>();
            var AbsTime = Stopwatch.StartNew();

            while (!_s_stop)
            {
                var stopwatch   = System.Diagnostics.Stopwatch.StartNew();
                var timetosleep = new TimeSpan(0, 0, 0, 0, 100) - sleeperror;
                game.Update(deltaT);
                game.PrintGame();
                if (Console.KeyAvailable)
                {
                    ConsoleKeyInfo a = Console.ReadKey(true);

                    game.keyInput(a.Key);

                    while (Console.KeyAvailable)
                    {
                        Console.ReadKey(true);
                    }
                }
                Thread.Sleep(timetosleep); // this can be omitted but CPU Utilization skyrockets
                //List.Add(timetosleep);
                //List2.Add(AbsTime.Elapsed);
                //List3.Add(game.GameTime);
                stopwatch.Stop();
                sleeperror = stopwatch.Elapsed - timetosleep;
                deltaT     = stopwatch.Elapsed;
            }


            //var compound= List2.Zip(List3, (first, second) => first.ToString() + "--" + second.ToString());

            //foreach( var a in compound)
            //    Console.WriteLine(a);
            Console.WriteLine("\n See ya, Space Cowboy...");
            Thread.Sleep(3000);
        }
Exemple #4
0
        public grid(int x, int y, gamemain parent)
        {
            keyMapping = new Dictionary <ConsoleKey, Action>()
            {
                { ConsoleKey.UpArrow, () => this.Up() },
                { ConsoleKey.DownArrow, () => this.Down() },
                { ConsoleKey.RightArrow, () => this.Right() },
                { ConsoleKey.LeftArrow, () => this.Left() },
                { ConsoleKey.Enter, () => this.exec() }
            };

            grid_         = new gridcell[x, y];
            selectedindex = Tuple.Create(0, 0);
            game          = parent;
        }
Exemple #5
0
        public static void Main(string[] args)
        {
            Console.Title = "Tactical Grid";
            Console.CursorVisible = false;
            Console.CancelKeyPress += new ConsoleCancelEventHandler(Console_CancelKeyPress);

            gamemain game = new gamemain();
            TimeSpan deltaT = new TimeSpan();
            //List<TimeSpan> List = new List<TimeSpan>();
            //List<TimeSpan> List2 = new List<TimeSpan>();
            //List2.Add(TimeSpan.Zero);
            //List<TimeSpan> List3 = new List<TimeSpan>();
            var AbsTime = Stopwatch.StartNew();
            while (!_s_stop)
            {

                var stopwatch = System.Diagnostics.Stopwatch.StartNew();
                var timetosleep = new TimeSpan(0, 0, 0, 0, 100) - sleeperror;
                game.Update(deltaT);
                game.PrintGame();
                if (Console.KeyAvailable)
                {
                    ConsoleKeyInfo a = Console.ReadKey(true);

                    game.keyInput(a.Key);

                    while (Console.KeyAvailable)
                        Console.ReadKey(true);

                }
                Thread.Sleep(timetosleep); // this can be omitted but CPU Utilization skyrockets
                //List.Add(timetosleep);
                //List2.Add(AbsTime.Elapsed);
                //List3.Add(game.GameTime);
                stopwatch.Stop();
                sleeperror = stopwatch.Elapsed - timetosleep;
                deltaT = stopwatch.Elapsed;

            }

            //var compound= List2.Zip(List3, (first, second) => first.ToString() + "--" + second.ToString());

            //foreach( var a in compound)
            //    Console.WriteLine(a);
            Console.WriteLine("\n See ya, Space Cowboy...");
            Thread.Sleep(3000);
        }
Exemple #6
0
        public npcMenu(gamemain parent)
        {
            game         = parent;
            menuMaxIndex = Enum.GetValues(typeof(menuItems)).Length;
            keyMapping_  = new Dictionary <ConsoleKey, Action>()
            {
                { ConsoleKey.UpArrow, () => this.Next() },
                { ConsoleKey.DownArrow, () => this.Previous() },
                { ConsoleKey.Enter, () => this.executeMenu() }
            };

            executeMenuDic = new Dictionary <menuItems, Action>()
            {
                { menuItems.EndTurn, () => game.runturn() },
                { menuItems.Move, () => game.move() },
                { menuItems.Select, () => game.select() }
            };
        }
Exemple #7
0
 public npc(gamemain parent)
 {
     mymenu = new npcMenu(parent);
 }
Exemple #8
0
 public npc(gamemain parent)
 {
     mymenu = new npcMenu(parent);
 }