Beispiel #1
0
        private static void Main(string[] args)
        {
            aTank      = new MyTank();
            MyMissiles = new List <Rocket>();
            Vragi      = new List <Enemy>();
            long MyTimeCount = 0;

            Console.SetWindowSize(battleground.Width, battleground.Height);
            //Console.SetBufferSize(battleground.Width+5, battleground.Height+5);
            Console.CursorVisible = false;
            Console.BufferHeight  = battleground.Height;
            Console.BufferWidth   = battleground.Width;


            int  cEnemy         = 0;
            long EnemyTimeCount = 0;


            while (true)
            {
                if (Win32Interop._kbhit() != 0)
                {
                    ConsoleKeyInfo code = Console.ReadKey(true);
                    MoveMyTank(code);
                }


                if (DateTime.Now.Ticks - MyTimeCount > 260000)
                {
                    MyTimeCount = DateTime.Now.Ticks;
                    for (int i = 0; i < MyMissiles.LongCount(); i++)
                    {
                        MyMissiles[i].Go();
                    }
                }
                //if (DateTime.Now.Ticks - EnemyTimeCount > 2000000)
                //{
                //    EnemyTimeCount = DateTime.Now.Ticks;

                //    if (cEnemy < 5)
                //    {
                //        Enemy tmp = new Enemy();

                //        Vragi.Add(tmp);
                //        cEnemy++;
                //    }

                //    Random rnd = new Random(DateTime.Now.Millisecond);

                //    for (int i = 0; i < Vragi.LongCount(); i++)
                //    {

                //        int tmp = rnd.Next(0, 3);
                //        if (tmp == 2)
                //        {
                //            tmp = rnd.Next(1, 4);
                //            Vragi[i].Direction = tmp;
                //        }

                //        Vragi[i].Go();
                //    }
                //}
            }
        }
Beispiel #2
0
        private static void Main(string[] args)
        {
            Console.CursorVisible = false;
            Console.Title         = "You have " + battleground.live.ToString() + ' ' + "live ";
            long MyTimeCount     = 0;
            long VragiTimeCoun   = 0;
            long EnemyTimeCreate = 0;
            long EnemyTimeGo     = 0;

            Random rnd = new Random();

            while (battleground.live > 0)
            {
                if (Win32Interop._kbhit() != 0)
                {
                    ConsoleKeyInfo code = Console.ReadKey(true);
                    MoveMyTank(code);
                }


                if (DateTime.Now.Ticks - MyTimeCount > 490000)
                {
                    MyTimeCount = DateTime.Now.Ticks;

                    for (int i = 0; i < battleground.MyMissiles.LongCount(); i++)
                    {
                        battleground.MyMissiles[i].Go();
                    }
                }

                //--------------------
                if (DateTime.Now.Ticks - VragiTimeCoun > 490000)
                {
                    VragiTimeCoun = DateTime.Now.Ticks;

                    for (int i = 0; i < battleground.VragiMissiles.LongCount(); i++)
                    {
                        battleground.VragiMissiles[i].Go();
                    }
                }
                //----------------------

                if (DateTime.Now.Ticks - EnemyTimeCreate > 60000000)
                {
                    EnemyTimeCreate = DateTime.Now.Ticks;

                    if (battleground.cEnemy < 10)
                    {
                        int live  = 0;
                        int tlife = rnd.Next(3) + 1;
                        switch (tlife)
                        {
                        case 1:
                            live = 1;
                            break;

                        case 2:
                            live = 3;
                            break;

                        case 3:
                            live = 5;
                            break;
                        }

                        Enemy tmp = new Enemy(live);
                        battleground.Vragi.Add(tmp);
                        battleground.cEnemy++;
                    }
                }
                if (DateTime.Now.Ticks - EnemyTimeGo > 2000000)
                {
                    EnemyTimeGo = DateTime.Now.Ticks;
                    if (battleground.cEnemy > 0)
                    {
                        for (int i = 0; i < battleground.cEnemy; i++)
                        {
                            battleground.Vragi[i].Go();
                            int tmp = rnd.Next(5);
                            if (tmp == 1)
                            {
                                battleground.Vragi[i].Shooting();
                            }
                        }
                    }
                }
            }
        }