Пример #1
0
        public void LodLevel()
        {
            imgGameOver      = new ImgGameOver();
            intervalGameOver = SizeGame.HeighWindowGame;
            StateOfLevel     = StateOfLevel.Game;

            for (int i = 1; i <= 10; i++)
            {
                listInformationTank.Add(new InformationTank(new Point(540, i * 18)));
                listInformationTank.Add(new InformationTank(new Point(560, i * 18)));
            }

            string[] linesTileMap = Properties.Resources.Level_1.Split(new char[] { '\n', '\r' }, StringSplitOptions.RemoveEmptyEntries);

            int x = 0, y = 0;

            foreach (string line in linesTileMap)
            {
                foreach (char c in line)
                {
                    if (c == 'B')
                    {
                        listBrickWall.Add(new BrickWall(new Point(x, y)));
                    }

                    x += SizeGame.WidtchSmoll;
                }
                x  = 0;
                y += SizeGame.HeighSmoll;
            }

            eagle = new Eagle(respawnEagle);

            tankPlayer = new SmallTankPlayer(respawnPlayer, Direction.Up);

            tankEnemy = new PlainTankEnemy(respawnEnemy1, Direction.Down);
            listTankEnemy.Add(tankEnemy);

            tankEnemy = new PlainTankEnemy(respawnEnemy2, Direction.Down);
            listTankEnemy.Add(tankEnemy);

            tankEnemy = new PlainTankEnemy(respawnEnemy3, Direction.Down);
            listTankEnemy.Add(tankEnemy);

            listTankPlayer.Add(tankPlayer);
            listEagle.Add(eagle);

            countEnemy = 3;
        }
Пример #2
0
        public void Update()
        {
            if (StateOfLevel == StateOfLevel.Download)
            {
                if (!informationDownloadLevel.IsShow())
                {
                    listInformation.Remove(informationDownloadLevel);

                    tankPlayer = new SmallTankPlayer(respawnPlayer, Direction.Up);
                    new AppearanceOfTank(respawnPlayer, tankPlayer);

                    enemyTanks = new EnemyTanks(TanksEnemy);
                    enemyTanks.AddEnemy();

                    StateOfLevel = StateOfLevel.Game;
                }
                else
                {
                    informationDownloadLevel.Update();
                }
            }
            if (StateOfLevel != StateOfLevel.GameOver)
            {
                for (int i = 0; i < listPlayer.Count; i++)
                {
                    listPlayer[i].Update();
                }
            }
            for (int i = 0; i < listOther.Count; i++)
            {
                listOther[i].Update();
            }
            foreach (var item in listWater)
            {
                item.Update();
            }
            for (int i = 0; i < listTankEnemy.Count; i++)
            {
                listTankEnemy[i].Update();
            }
            for (int i = 0; i < listShell.Count; i++)
            {
                listShell[i].Update();
            }


            if (StateOfLevel == StateOfLevel.GameOver)
            {
                if (imgGameOver == null)
                {
                    SoundGame.Stop();
                    imgGameOver = new ImgGameOver();
                    listInformation.Add(imgGameOver);
                }
                else
                {
                    imgGameOver.Update();
                }
            }

            if (StateOfLevel == StateOfLevel.Game)
            {
                // Если вражиских танков неосталось
                if (listTankEnemy.Count == 0 && !enemyTanks.IsTanks())
                {
                    if (timerWin == 0)
                    {
                        SoundGame.Stop();
                        TimerWin();
                    }
                    else
                    {
                        timerWin--;
                    }
                }
                else if (listTankEnemy.Count < 3)
                {
                    enemyTanks.AddEnemy();
                }
            }
        }