Example #1
0
        private void FillInGroupBox(Map map)
        {
            CurrentMap = map;
            CurrentMap.SetPackMan();
            this.GroupBox.Controls.Add(map.Pacman);

            Level level = Level.Low;
            if (SelectLevelCb.SelectedItem != null)
            {
                Enum.TryParse(SelectLevelCb.SelectedItem.ToString(), out level);
            }
            Enemy enemyAI1 = new Enemy(map.Pacman, EnemyType.Chasing, new Point(540, 300), level);
            GroupBox.Controls.Add(enemyAI1);
            Enemy enemyAI2 = new Enemy(map.Pacman, EnemyType.Chasing, new Point(140, 300), level);
            GroupBox.Controls.Add(enemyAI2);

            Enemy enemyRandom = new Enemy(map.Pacman, EnemyType.Scatter, new Point(140, 300), level);
            GroupBox.Controls.Add(enemyRandom);
            Enemy enemyRandom2 = new Enemy(map.Pacman, EnemyType.Scatter, new Point(540, 500), level);
            GroupBox.Controls.Add(enemyRandom2);

            this.GroupBox.Controls.Add(new Block(20, 20, map.Entrance) { BackColor = Color.DarkGray });
            this.GroupBox.Controls.Add(new Block(20, 20, map.Exit) { BackColor = Color.Green });

            foreach (var block in map.Blocks)
            {
                this.GroupBox.Controls.Add(block);
            }
            foreach (var dot in map.Dots)
            {
                this.GroupBox.Controls.Add(dot);
            }
        }
Example #2
0
        /// <summary>
        /// when packmen is catched by enemy
        /// </summary>
        /// <param name="sender"></param>
        public void Catched(Enemy sender)
        {
            if (IsCatched)
            {
                return;
            }
            Graphics g = this.CreateGraphics();

            g.FillEllipse(System.Drawing.Brushes.Red, 0, 0, Width, Height);
            g.FillEllipse(System.Drawing.Brushes.Black, 20, 10, 5, 5);
            g.FillEllipse(System.Drawing.Brushes.Transparent, 35, 20, 10, 5);

            IsCatched = true;

            if (PacmanMessages != null)
                PacmanMessages(this, "Pacman has been catched by an enemy.");
            TotalPoints = 0;
        }