コード例 #1
0
        private void MoveEnemy(Point newPlace)
        {
            int sx = 0, sy = 0;

            if (enemyPlace.X < newPlace.X)
            {
                sx = newPlace.X - enemyPlace.X > step ? step : newPlace.X - enemyPlace.X;
            }
            else
            {
                sx = enemyPlace.X - newPlace.X < step ? newPlace.X - enemyPlace.X : -step;
            }
            if (enemyPlace.Y < newPlace.Y)
            {
                sy = newPlace.Y - enemyPlace.Y > step ? step : newPlace.Y - enemyPlace.Y;
            }
            else
            {
                sy = enemyPlace.Y - newPlace.Y < step ? newPlace.Y - enemyPlace.Y : -step;
            }

            moving.Move(sx, sy);

            enemyPlace = moving.MyNowPoint();

            //При уровне сложности 2, если противник видит огонь или бомбу, то ищет новое местоположение
            if (level >= 2 && (map[newPlace.X, newPlace.Y] == Condition.bomb || map[newPlace.X, newPlace.Y] == Condition.fire))
            {
                GetNewPlace();
            }
        }
コード例 #2
0
 public Enemy(PictureBox picEnemy, PictureBox[,] _mapPic, Condition[,] _map, Bomber _bomber)
 {
     enemy        = picEnemy;
     map          = _map;
     bomber       = _bomber;
     fmap         = new int[map.GetLength(0), map.GetLength(1)];
     path         = new Point[map.GetLength(0) * map.GetLength(1)];
     moving       = new MovingClass(picEnemy, _mapPic, _map, AddBonus);
     enemyPlace   = moving.MyNowPoint();
     destinePlace = enemyPlace;
     CreateTimer();
     timer.Enabled = true;
 }
コード例 #3
0
 public Point MyNowPoint()
 {
     return(moving.MyNowPoint());
 }