Esempio n. 1
0
        static internal void DoMove(Keys key)
        {
            switch (key)
            {
            case Keys.Up:
            {
                if (_hero.HeroPositionY > 0 && _labyrinth.GeneratedLabirint()[_hero.HeroPositionX, _hero.HeroPositionY - 1] != CellType.wall)
                {
                    Draw.ReDrawHero(_hero.HeroPositionX, _hero.HeroPositionY, _hero.HeroPositionX, --_hero.HeroPositionY, _hero.Level);
                }
                break;
            }

            case Keys.Down:
            {
                if (_hero.HeroPositionY < _hero.Level * 2 - 2 &&
                    _labyrinth.GeneratedLabirint()[_hero.HeroPositionX, _hero.HeroPositionY + 1] != CellType.wall)
                {
                    Draw.ReDrawHero(_hero.HeroPositionX, _hero.HeroPositionY, _hero.HeroPositionX, ++_hero.HeroPositionY, _hero.Level);
                }
                break;
            }

            case Keys.Right:
            {
                if (_hero.HeroPositionX < _hero.Level * 2 - 2 &&
                    _labyrinth.GeneratedLabirint()[_hero.HeroPositionX + 1, _hero.HeroPositionY] != CellType.wall)
                {
                    Draw.ReDrawHero(_hero.HeroPositionX, _hero.HeroPositionY, ++_hero.HeroPositionX, _hero.HeroPositionY, _hero.Level);
                }
                break;
            }

            case Keys.Left:
            {
                if (_hero.HeroPositionX > 0 &&
                    _labyrinth.GeneratedLabirint()[_hero.HeroPositionX - 1, _hero.HeroPositionY] != CellType.wall)
                {
                    Draw.ReDrawHero(_hero.HeroPositionX, _hero.HeroPositionY, --_hero.HeroPositionX, _hero.HeroPositionY, _hero.Level);
                }
                break;
            }
            }

            if ((_hero.HeroPositionX == _labyrinth.GetFinish().X) & (_hero.HeroPositionY == _labyrinth.GetFinish().Y))
            {
                MessageBox.Show("Поздравляю, Вы победили. \n Наджмите \"ОК\" чтобы начать следующий уровень", "Победа");

                HERO_LEVEL++;
                InitializeControl();
            }
        }
Esempio n. 2
0
        internal static void DrawBackgroundImage(Labyrinth labyrinth, int Level)
        {
            Graphics g = Graphics.FromImage(backgroundBitmap);



            g.FillRectangle(Brushes.White, 0, 0, LAB_SIZE, LAB_SIZE);
            g.DrawRectangle(new Pen(Color.Red, 1.0f), 0, 0, (LAB_SIZE - 1), (LAB_SIZE - 1));
            float cellWeight = (float)LAB_SIZE / ((float)Level * 2.0f - 1.0f);

            g.FillRectangle(Brushes.Blue, cellWeight * labyrinth.Finish.X, cellWeight * labyrinth.Finish.Y, cellWeight, cellWeight);


            DrawGeneratedLabirinth(labyrinth.GeneratedLabirint(), g, Level);
        }