コード例 #1
0
         float distance = Vector2.Distance(bLoc, pos);
            if (distance<0.2)
                return item;
        }
        return null;
    }
    internal void DestroyItem(ActiveItemType item)
    {
        var bLoc = item.transform.position;
        _activeItems.Remove(item);
        Destroy(item.gameObject);
        //Todo: also delete other items in that radius 
        foreach (var cacheItem in _cache.Find("Item", bLoc, 1, true))
            print("DestroyItem:  item:" + cacheItem.Content + cacheItem.ObjectType + cacheItem.Location );
    }
    //Logic should match with BuildingDropItem
 public void TerrainDropItem(Vector3 pos, float chance, string dropItems)
    {
        int itemId;
     if (RandomHelper.GetLucky(pos, chance))
            itemId = _itemDatabase.GetItemIdBasedOnRarity(pos, dropItems);
        else //Drop coin/Gem/Recipe  
            itemId = _itemDatabase.GetItemIdBasedOnRarity(pos);
        //print("itemId = "+ itemId +" in pos ="+ pos);
        if (itemId != -1)
        {
            _terrainManager.CreateItem(pos, itemId);
            _cache.Add(new CacheContent()
                {
                    Location = pos,
                    Content = itemId.ToString(),
                    ObjectType = "Item"
                }
            );
        }
 }