예제 #1
0
        protected override void OnPaint(PaintEventArgs e)
        {
            base.OnPaint(e);


            var h       = game.player.Health;
            var s       = game.player.Scores;
            var health  = new Rectangle(new Point(42 + healthText.Width, 14), new Size((675 * h) / 100, 12));
            var health2 = new Rectangle(new Point(40 + healthText.Width, 12), new Size(139, 16));

            e.Graphics.FillRectangle(Brushes.LightGreen, 0, 0, 390, 70);
            e.Graphics.FillRectangle(Brushes.Black, health2);
            e.Graphics.FillRectangle(Brushes.Red, health);
            e.Graphics.DrawString(s.ToString(), new Font(new FontFamily("Segoe UI Symbol"), 18, FontStyle.Bold), Brushes.Black, 40 + scoreText.Width, 31);
            e.Graphics.DrawImage(healthText, 12, 12);
            e.Graphics.DrawImage(scoreText, 12, 41);
            e.Graphics.DrawImage(grannysImage, 50, 60, 64, 79);
            e.Graphics.DrawImage(houseImage, 210, 0, 150, 140);
            e.Graphics.DrawImage(fieldImage, 0, 134, game.field.Width * cellWidth, game.field.Height * cellHeight);


            foreach (var weed in game.field.weeds)
            {
                var k = Weed.BossSearch(game.field, new FieldCell(weed.X, weed.Y, FieldCellStates.Weed),
                                        game.player.CurrentPos);
                var path = GetPath(k);
                foreach (var item in path)
                {
                    weed.X = item.X;
                    weed.Y = item.Y;

                    if (weed.WeedState == WeedStates.Alive)
                    {
                        e.Graphics.DrawImage(zombImage, weed.X * cellWidth + 5, weed.Y * cellHeight + 134);
                    }

                    if (weed.WeedState == WeedStates.Dead)
                    {
                        e.Graphics.DrawImage(deadZomb, weed.X * cellWidth, weed.Y * cellHeight + 134);
                    }

                    if (weed.WeedState == WeedStates.Freezed)
                    {
                        e.Graphics.DrawImage(freezedZomb, weed.X * cellWidth + 5, weed.Y * cellHeight + 134,
                                             zombImage.Width * 1.5f, zombImage.Height * 1.5f);
                    }
                }
            }

            foreach (var bullet in bullets)
            {
                if (bullet.state == BulletState.Exist)
                {
                    e.Graphics.DrawImage(bulletImage, bullet.X * cellWidth + 21, bullet.Y * cellHeight - 40 + 114, 30, 30);
                }
            }
            e.Graphics.DrawImage(playerImage, game.player.CurrentPos.X * cellWidth, game.player.CurrentPos.Y * cellHeight + 134f, 70, 93);
        }
예제 #2
0
        public void SmallBossSearchTest()
        {
            var textField = new[]
            {
                "W#",
                "#P"
            };
            var field = Field.FromLines(textField);
            var expectedPathLength = 3;
            var realPathLength     = Weed.BossSearch(
                field,
                GetCurrentPosition(FieldCellStates.Weed, field),
                GetCurrentPosition(FieldCellStates.Player, field)).Length;

            Assert.AreEqual(expectedPathLength, realPathLength);
        }