Пример #1
0
 public override void RunInteractAction()
 {
     if (Selected is BaseShopItem item && !isOpen)
     {
         item.InteractEvent();
         openShop = item;
         isOpen   = true;
     }
Пример #2
0
    public virtual void OpenItem(Image image, Button button, GameObject price, BaseShopItem shopItem)
    {
        image.sprite = Sprite;
        image.color  = new Color(1, 1, 1, 1);

        price.SetActive(false);

        button.onClick.AddListener(() => ChooseItem(shopItem));
    }
Пример #3
0
 public virtual void TryToBuy(BaseShopItem shopItemOnClick)
 {
     Mediator.Publish(new TryTobuyItemCommand((ShopItemForGold)shopItemOnClick));
 }
Пример #4
0
 public virtual void ChooseItem(BaseShopItem shopItem)
 {
     Mediator.Publish(new ChooseItemCommand(shopItem));
 }
Пример #5
0
    public void SpawnShopItems()
    {
        // set special item
        List <GameObject> availableSpecialItems = new List <GameObject>();

        for (int i = 0, n = mSpecialItemPool.Length; i < n; ++i)
        {
            BaseShopItem shopItem = mSpecialItemPool[i].GetComponent <BaseShopItem>();
            if (shopItem != null && shopItem.CanBePurchased())
            {
                availableSpecialItems.Add(mSpecialItemPool[i]);
            }
        }

        if (availableSpecialItems.Count > 0)
        {
            SetShopItem(availableSpecialItems[Random.Range(0, availableSpecialItems.Count)], mSpecialItemSlot);
        }

        // set gift item
        for (int i = 0, n = mGiftItemPool.Length; i < n; ++i)
        {
            BaseShopItem shopItem = mGiftItemPool[i].GetComponent <BaseShopItem>();
            if (shopItem != null && shopItem.CanBePurchased())
            {
                SetShopItem(mGiftItemPool[i], mGiftItemSlot);
                break;
            }
        }

        /*
         * int numAlwaysAvailableItems = mAlwaysAvailableItems.Length;
         * List<GameObject> availableSpecialItems = new List<GameObject>();
         * for(int i = 0, n = mSpecialItemPool.Length; i < n; ++i)
         * {
         *  BaseShopItem shopItem = mSpecialItemPool[i].GetComponent<BaseShopItem>();
         *  if(shopItem != null && shopItem.CanBePurchased())
         *  {
         *      availableSpecialItems.Add(mSpecialItemPool[i]);
         *  }
         * }
         *
         * for (int i = 0, n = mShopItemSlots.Length; i < n; ++i)
         * {
         *  if(i < numAlwaysAvailableItems)
         *  {
         *      SetShopItem(mAlwaysAvailableItems[i], i);
         *  }
         *  else
         *  {
         *      if(availableSpecialItems.Count > 0)
         *      {
         *          GameObject randomItem = availableSpecialItems[Random.Range(0, availableSpecialItems.Count)];
         *          availableSpecialItems.Remove(randomItem);
         *          SetShopItem(randomItem, i);
         *      }
         *      else
         *      {
         *          break;
         *      }
         *  }
         * }
         */
    }