コード例 #1
0
        /// <summary>
        /// Find an item in an area.
        /// </summary>
        /// <param name="searcherAreaId">The area ID of the searcher.</param>
        /// <param name="itemType">The type of item required.</param>
        /// <param name="searcherPosition">The position of the searcher.</param>
        /// <returns>Returns an item if one exists, otherwise returns null.</returns>
        public Item GetClosestItem(int searcherAreaId, string itemType, Point searcherPosition)
        {
            //TODO: Incorporate the searcher Area ID
            SpatialObjectKey spatialObjectKey = new SpatialObjectKey()
            {
                ObjectType = SpatialObjectType.Item, ObjectSubtype = itemType
            };

            return((Item)Owner.SpatialTreeIndex.FindClosestObject(searcherPosition, spatialObjectKey));
        }
コード例 #2
0
        /// <summary>
        /// Checks to see if a particular item exists in the game world.
        /// </summary>
        /// <param name="searcherAreaId">The area ID of the searcher.</param>
        /// <param name="itemType">The type of item to search for.</param>
        /// <returns>Returns true if at least one item exists.</returns>
        public bool ValidItemExists(int searcherAreaId, string itemType)
        {
            var spatialObjectKey = new SpatialObjectKey()
            {
                ObjectType = SpatialObjectType.Item, ObjectSubtype = itemType
            };

            if (Owner.SpatialTreeIndex.TopNode.ResourceCount.ContainsKey(spatialObjectKey))
            {
                if (Owner.SpatialTreeIndex.TopNode.ResourceCount[spatialObjectKey] > 0)
                {
                    return(true);
                }
            }
            return(false);
        }