Exemplo n.º 1
0
        /// <summary>
        /// Get a random point near player
        /// </summary>
        /// <returns> available point in area of player</returns>
        public FieldPoint RandomPointNearPlayer(int area, PacmanEssence player)
        {
            int x_start, y_start, x_end, y_end;

            #region Fridges
            if (player.Point.X - area > 0)
            {
                x_start = player.Point.X - area;
            }
            else
            {
                x_start = 0;
            }
            if (player.Point.X + area < _fieldRange)
            {
                x_end = player.Point.X + area;
            }
            else
            {
                x_end = _fieldRange - 1;
            }
            if (player.Point.Y + area < _fieldRange)
            {
                y_end = player.Point.Y + area;
            }
            else
            {
                y_end = _fieldRange - 1;
            }
            if (player.Point.Y - area > 0)
            {
                y_start = player.Point.Y - area;
            }
            else
            {
                y_start = 0;
            }

            #endregion
            int        count = 5;
            FieldPoint tempPoint;
            do
            {
                tempPoint = new FieldPoint(_r.Next(x_start, x_end), _r.Next(y_start, y_end));
                if (IsAvailablePoint(tempPoint))
                {
                    return(tempPoint);
                }
                count++;
            } while (count < 5);
            return(AvailableFieldPoints[_r.Next(AvailableFieldPoints.Count)]);
        }
Exemplo n.º 2
0
 /// <summary>
 /// Get player point
 /// </summary>
 /// <param name="player">Pacman</param>
 /// <returns>player point </returns>
 public FieldPoint PlayerPoint(PacmanEssence player)
 {
     return(new FieldPoint(player.Point.X, player.Point.Y));
 }