예제 #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() } };
        }
예제 #2
0
파일: grid.cs 프로젝트: mdxbhmt/taticlearn
        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;
        }
예제 #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);
        }
예제 #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;
        }
예제 #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);
        }
예제 #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() }
            };
        }
예제 #7
0
파일: npc.cs 프로젝트: mdxbhmt/taticlearn
 public npc(gamemain parent)
 {
     mymenu = new npcMenu(parent);
 }
예제 #8
0
 public npc(gamemain parent)
 {
     mymenu = new npcMenu(parent);
 }