コード例 #1
0
 public void PlaceTreasure(GameObject treasure, Vector2 location)
 {
     treasures.Add(new KeyValuePair <Vector2, GameObject>(location, treasure));
     CountChangedEvent?.Invoke(treasures.Count);
     treasure.transform.position = location;
     treasure.SetActive(true);
 }
コード例 #2
0
    public void DropTreasure(GameObject treasure, Vector2 location)
    {
        KeyValuePair <Vector2, GameObject> found = treasures.FirstOrDefault(obj => obj.Value == treasure);

        if (found.Key != null)
        {
            CountChangedEvent?.Invoke(treasures.Count);
            treasure.transform.position = location;
            treasure.SetActive(true);
        }
    }
コード例 #3
0
    public bool DestoryTreasure(GameObject treasure)
    {
        KeyValuePair <Vector2, GameObject> found = treasures.FirstOrDefault(obj => obj.Value == treasure);

        if (found.Key != null)
        {
            treasures.Remove(found);
            Destroy(found.Value);
            CountChangedEvent?.Invoke(treasures.Count);
            return(true);
        }

        return(false);
    }