Beispiel #1
0
    //Updating the dummy data


    public void UpdateData(int index, StoreItemData data = null)
    {
        if (data != null)
        {
            if (objectType == ObjectType.HITCOIN)
            {
                cost.text       = "$" + data.cost.ToString();
                coinAmount.text = data.amount.ToString();
            }
            else if (objectType == ObjectType.MUSKETEER)
            {
                cost.text               = "$" + cost.ToString();
                coinAmount.text         = data.timePeriod + " MONTHS";
                discountPercentage.text = "SAVE " + Random.Range(15, 50) + "%";
            }
        }

        // Incase data is coming null--> we will set default random data
        else
        {
            if (objectType == ObjectType.HITCOIN)
            {
                cost.text       = "$" + (20 * index).ToString();
                coinAmount.text = (50 * index).ToString();
            }
            else if (objectType == ObjectType.MUSKETEER)
            {
                cost.text               = "$" + (10 * index).ToString();
                coinAmount.text         = index + " MONTHS";
                discountPercentage.text = "SAVE " + Random.Range(15, 50) + "%";
            }
        }
    }
Beispiel #2
0
 public void setData(StoreItemData item)
 {
     if (item == null)
     {
         return;
     }
     id                 = item.itemId;
     countTF.text       = item.count.ToString();
     priceTF.text       = item.price.ToString("C");
     descriptionTF.text = item.description;
     icon.changeImage(item.iconPath);
 }
Beispiel #3
0
    public void AddItem(int id)
    {
        Item itemToAdd = database.FindItemByID(id);

        if (itemToAdd.Stackable && CheckIfItemIsInInventory(itemToAdd))            //stack가능할 경우
        {
            for (int i = 0; i < items.Count; i++)
            {
                if (items [i].ID == id)
                {
                    StoreItemData data = slots [i].transform.GetChild(0).GetComponent <StoreItemData> ();
                    data.amount++;
                    data.transform.GetChild(0).GetComponent <Text> ().text = data.amount.ToString();
                    break;
                }
            }
        }
        else
        {
            for (int i = 0; i < items.Count; i++)
            {
                if (items [i].ID == -1)
                {
                    items [i] = itemToAdd;
                    GameObject itemObj = Instantiate(inventoryItem);

                    itemObj.GetComponent <StoreItemData> ().item  = itemToAdd;
                    itemObj.GetComponent <StoreItemData> ().slot  = i;
                    itemObj.GetComponent <StoreItemData>().amount = 1;
                    itemObj.transform.SetParent(slots [i].transform);
                    itemObj.GetComponent <RectTransform>().anchoredPosition = new Vector2(0, 0);
                    //itemObj.GetComponent<Image> ().sprite = itemToAdd.Sprite;
                    itemObj.name = itemToAdd.Title;

                    itemObj.transform.parent.GetChild(0).SetAsLastSibling();

                    save();

                    break;
                }
            }
        }
    }
Beispiel #4
0
        public void Setup(StoryCollectionData data)
        {
            StoryChargerData chargerData   = resourceService.GetStoryCharger(data.chargerId);
            StoreItemData    storeItemData = resourceService.GetStoreItem(chargerData.storeItemId);

            if (storeItemData == null)
            {
                Debug.Log($"storeItemData null for charger {chargerData.id}:{chargerData.storeItemId}");
                return;
            }

            priceImage.overrideSprite = resourceService.GetPriceSprite(storeItemData.price);
            priceText.text            = storeItemData.price.price.ToString();

            buyButton.SetListener(() => {
                playerService.Buy(storeItemData);
            }, engine.GetService <IAudioService>());
            askButton.SetListener(() => {
                netService.Ask(chargerData);
            }, engine.GetService <IAudioService>());
        }
Beispiel #5
0
 public bool Buy(StoreItemData data)
 {
     if (HasCoins(data.price))
     {
         RemoveCoins(data.price);
         var itemData = resourceService.GetInventoryItemData(data.itemType, data.itemId);
         if (itemData != null)
         {
             AddItem(new InventoryItem(itemData, data.count));
             Debug.Log($"After buy StoreItemData items was added {data.count}{itemData.id}");
             return(true);
         }
         else
         {
             throw new System.ArgumentException("data");
         }
     }
     else
     {
         viewService.ShowView(RavenhillViewType.bank);
         return(false);
     }
 }
Beispiel #6
0
 public StoreItemDataViewModel(StoreItemData model)
 {
     this.model = model;
 }
 public void OnEnable()
 {
     m_Instance = target as StoreItemData;
 }