示例#1
0
    override public void Set(PurchasableData shopData)
    {
        _shopData = (ShopData)shopData;
        _title.SetText(_shopData.ShopName);
        _cost.SetText(_shopData.InitialCostString);
        _income.SetText(_shopData.InitialIncomeString);
        _incomeRate.SetText(_shopData.InitialIncomeDropSpeedString);
        _background.sprite = _shopData.UiSprite;

        _button = GetComponent <Button>();
        _button.onClick.AddListener(SetPanel);
    }
    public void CheckSlotForItem()
    {
        if (this.transform.childCount <= 0)
        {
            //get the parent item of the slot
            GameObject parent = this.gameObject.transform.parent.transform.parent.gameObject;
            //get the purchasable data from parent so we can modify it.
            PurchasableData purchasable = parent.GetComponent <PurchasableData>();

            if (purchasable != null)
            {
                purchasable.Purchasable.RemoveBonus();
            }
            return;
        }
        if (this.transform.childCount > 0)
        {
            //get the parent item of the slot
            GameObject parent = this.gameObject.transform.parent.transform.parent.gameObject;
            //get the purchasable data from parent so we can modify it.
            PurchasableData purchasable = parent.GetComponent <PurchasableData>();
            if (purchasable != null)
            {
                //get the item in our child
                GameObject child = this.gameObject.transform.GetChild(0).gameObject;

                //get child item data
                Item childItem = child.GetComponent <ItemData>().Item;

                //this will throw error for slots that are not part of an parent with Purchasable, ie inventory items
                purchasable.Purchasable.AddBonus(childItem);
            }
            return;
        }
        else
        {
        }
    }
示例#3
0
 abstract public void Set(PurchasableData shopData);
示例#4
0
 public override void Set(PurchasableData data)
 {
 }