Пример #1
0
        private bool HasNearPointOrSelf(List<HexPoint> checkList, HexPoint pointToCheck)
        {
            // Check if the list contains the point
            if (checkList.Contains(pointToCheck)) return true;

            // Check if the list contains any of the neightbours
            List<HexPoint> neighbours = pointToCheck.GetNeighbours();
            if (neighbours.Count != 3) Console.WriteLine("whoa");
            foreach (HexPoint neighbour in neighbours)
                if (checkList.Contains(neighbour)) return true;

            // Nope! the list doesnt contains the point or any of its neighbours
            return false;
        }
Пример #2
0
        /// <summary>
        /// Checks given HexPoint location and its neighbours if a city or town
        /// is placed
        /// </summary>
        /// <param name="location"></param>
        /// <returns></returns>
        public bool IsTownCityPresent(HexPoint location)
        {
            //make a list of each point to check for
            List<HexPoint> points = new List<HexPoint>();
            points.Add(location);
            points.AddRange(location.GetNeighbours());

            // check the list against all towns and cities
            foreach (HexPoint point in points)
            {
                foreach (GamePlayer player in _Players)
                {
                    if (player.Towns.Contains(point)) return true;
                    if (player.Cities.Contains(point)) return true;
                }
            }
            return false;
        }