Exemplo n.º 1
0
        public bool TryAdd(InventoryColor inventoryColor)
        {
            Debug.Log("Trying to add " + inventoryColor.Color + "to inventory");
            var result = "";

            foreach (var inventoryItem in InventoryItems)
            {
                if (inventoryItem is InventoryColor ic)
                {
                    result += ic.Color + " ";
                }
            }
            Debug.Log("Content of inventory: " + result);

            if (InventoryItems.Contains(inventoryColor))
            {
                Debug.Log("Inventory already contain this color");

                return(false);
            }

            inventoryColor.InventoryColorChanged += InventoryColorChanged;
            InventoryItems.Add(inventoryColor);
            return(true);
        }
Exemplo n.º 2
0
 // Use this for initialization
 void OnTriggerEnter(Collider col)
 {
     if (col.tag.Equals("Player"))
     {
         if (InventoryColor.goldCount > 0)
         {
             InventoryColor.NoGold();
         }
         else
         {
             col.gameObject.GetComponent <Reseter>().ResetPlayer();
         }
     }
 }
Exemplo n.º 3
0
 private void OnTriggerEnter(Collider other)
 {
     if (other.gameObject.tag == "Player")
     {
         Destroy(gameObject);
         if (color.Equals("blue"))
         {
             InventoryColor.addCount(color, ballnum + 2);
         }
         if (color.Equals("gold"))
         {
             InventoryColor.addCount(color, ballnum + 6);
         }
         InventoryColor.addCount(color, ballnum);
     }
 }
Exemplo n.º 4
0
        public bool TryRemove(InventoryColor inventoryColor)
        {
            var result = InventoryItems.Remove(inventoryColor);

            if (!result)
            {
                Debug.Log("Inventory do not contain this color");
            }

            if (result)
            {
                inventoryColor.InventoryColorChanged -= InventoryColorChanged;
            }

            return(result);
        }
Exemplo n.º 5
0
 private void InventoryColorChanged(InventoryColor inventoryColor)
 {
     ContentChanged.Invoke(InventoryItems);
 }