/// <summary> /// 初始化 /// </summary> public void Init(List <ShopItemData> list) { // Debug.Log("初始化" + gameObject.name); for (int i = 0; i < list.Count; i++) { GameObject item = selfList[i]; ShopItemData data = list[i]; UILabel name = item.transform.Find("Name").GetComponent <UILabel>(); UISprite pinzhi = item.transform.Find("Pinzhi").GetComponent <UISprite>(); UISprite icon = item.transform.Find("Pinzhi/Icon").GetComponent <UISprite>(); UILabel num = item.transform.Find("Pinzhi/Num").GetComponent <UILabel>(); UISprite activityIcon = item.transform.Find("ActivetyIcon").GetComponent <UISprite>(); UILabel pic = item.transform.Find("Price").GetComponent <UILabel>(); name.text = data.name; num.text = data.num.ToString(); pic.text = data.pic.ToString(); item.name = "Shop_" + data.id.ToString(); } if (list.Count < selfList.Count) { int num = selfList.Count - list.Count; for (int i = selfList.Count - 1; i >= selfList.Count - num; i--) { GameObject item = selfList[i]; item.SetActive(false); } } }
public void UpdateData(ShopItemData data) { this.Data = data; this.GetComponent <Image>().sprite = Resources.Load <Sprite>("ShopItems/" + data.SpriteName); UpdateItem(); }
void InitItem(GameObject item, int index) { SelfShopItem self = item.GetComponent <SelfShopItem>(); foreach (GameObject obj in self.selfList) { UIEventListener listener = UIEventListener.Get(obj); //UIEventListener lisParent = UIEventListener.Get(item.transform.parent.parent.gameObject); //lisParent.onDrag = listener.onDrag(obj, Vector2.one); listener.onClick += (e) => { ItemClick(e); return; }; } List <ShopItemData> list = new List <ShopItemData>(); int nowListIndex = index * moneLineNum; int forNum = moneLineNum; if (index == mline - 1 && mRemainder != moneLineNum) { forNum = mRemainder; } for (int i = 0; i < forNum; i++) { ShopItemData data = mData[nowListIndex + i]; list.Add(data); } self.Init(list); }
public RTShopGridData(EShopType shopType, ShopItemData data, RTShopGridData.ShopItemCallback buyCallback, RTShopGridData.ShopItemCallback showCallback) { this.ShopType = shopType; this.shopData = data; this.AVData = Globals.Instance.Player.ActivitySystem.GetValueMod(7); if (this.shopData.InfoType == 1) { this.itemInfo = Globals.Instance.AttDB.ItemDict.GetInfo(this.shopData.InfoID); if (this.itemInfo.Type == 3 && this.itemInfo.SubType == 0) { this.petInfo = Globals.Instance.AttDB.PetDict.GetInfo(this.itemInfo.Value2); } else if (this.itemInfo.Type == 3 && this.itemInfo.SubType == 3) { this.lopetInfo = Globals.Instance.AttDB.LopetDict.GetInfo(this.itemInfo.Value2); } } else if (this.shopData.InfoType == 2) { this.petInfo = Globals.Instance.AttDB.PetDict.GetInfo(this.shopData.InfoID); } else if (this.shopData.InfoType == 3) { this.lopetInfo = Globals.Instance.AttDB.LopetDict.GetInfo(this.shopData.InfoID); } this.BuyShopItemEvent = buyCallback; this.ShowShopItemEvent = showCallback; }
List <ShopItemData> MoNiData(int nums) { List <ShopItemData> list = new List <ShopItemData>(); for (int i = 0; i < nums; i++) { ShopItemData data = new ShopItemData(); data.id = Random.Range(100, 199); if (data.id >= 100 && data.id < 120) { data.type = 0; } if (data.id >= 120 && data.id < 140) { data.type = 1; } if (data.id >= 140 && data.id < 160) { data.type = 2; } if (data.id >= 160 && data.id < 180) { data.type = 3; } if (data.id >= 180 && data.id < 200) { data.type = 4; } data.num = Random.Range(1, 99); data.name = "商品" + data.id.ToString(); data.pic = Random.Range(100, 999); list.Add(data); } return(list); }
private static void UpdateShop(Shop shop, bool toggle, string itemName, ShopItemData shopItemData) { ShopItemData storedItem = null; foreach (ShopItemData loopItem in shop.Items) { if (loopItem.Name.Equals(itemName)) { storedItem = loopItem; break; } } if (toggle) { if (storedItem == null) { shop.Items.Add(shopItemData); } else { shop.Items.Remove(storedItem); shop.Items.Add(shopItemData); } } else if (storedItem != null) { shop.Items.Remove(storedItem); } }
void Start() { RectTransform shopItemRect = shopItemReference.GetComponent <RectTransform>(); float shopItemWidth = shopItemRect.sizeDelta.x; float shopItemHeight = shopItemRect.sizeDelta.y; float xOffset = 15; float yOffset = 25; short itemsPerColumn = 3; for (int i = 0; i < items.Length; i++) { Vector3 pos = new Vector3((i % itemsPerColumn) * (shopItemWidth + xOffset), (i / itemsPerColumn) * -(shopItemHeight + yOffset), 0); GameObject o = UI.createInstance3D(shopItemReference, pos); ShopItem item = o.GetComponent <ShopItem>(); item.setData(items[i]); item.getData().createModel(o); o.SetActive(true); /*GameObject o = Instantiate(shopItemReference); * o.transform.SetParent(shopItemReference.transform.parent); * o.GetComponent<RectTransform>().anchoredPosition3D = new Vector3((i%itemsPerColumn)*(shopItemWidth+xOffset), (i/itemsPerColumn)*-(shopItemHeight+yOffset), 0); * o.GetComponent<RectTransform>().rotation = shopItemReference.GetComponent<RectTransform>().rotation; * o.GetComponent<RectTransform>().localScale = Vector3.one; * o.GetComponent<ShopItem>().setData(items[i]); * o.SetActive(true);*/ } cheapestItem = findCheapestItem(); }
public void Activate(ShopItemData data) { if (data.item != null) { this.item = data.item; ConstructItemDataString(); infoPanel.SetActive(true); buyButton.SetActive(true); buyButton.GetComponent <ButtonScript>().shopItemData = data; infoPanel.transform.GetChild(0).GetComponent <Image>().sprite = item.Sprite; } if (data.weapon != null) { this.weapon = data.weapon; ConstructWeaponDataString(); infoPanel.SetActive(true); buyButton.SetActive(true); buyButton.GetComponent <ButtonScript>().shopItemData = data; infoPanel.transform.GetChild(0).GetComponent <Image>().sprite = weapon.Sprite; } if (data.armor != null) { this.armor = data.armor; ConstructWeaponDataString(); infoPanel.SetActive(true); buyButton.SetActive(true); buyButton.GetComponent <ButtonScript>().shopItemData = data; infoPanel.transform.GetChild(0).GetComponent <Image>().sprite = armor.Sprite; } }
public void EnterBuildMode(Building _eBuilding) { m_dataCurrent = ShopItemManager.Instance.GetBuildingData(_eBuilding); EnterState(ControlState.Build); m_placementVisual.SetSprite(m_dataCurrent.Sprite); m_placementVisual.gameObject.SetActive(true); }
private void InitComponentsByLockLevel(ShopItemData shopItemData){ if (shopItemData.UnlockLevel == ShopItemData.UNLOCK_LEVEL_LOCKED) { descriptionLabel.text = shopItemData.Description; lockObject.SetActive(true); } else if (shopItemData.UnlockLevel == ShopItemData.UNLOCK_LEVEL_UNLOCKED) { descriptionLabel.text = "ddddddddddddddd"; } }
protected override void Start() { base.Start(); m_itemData = new ShopItemData(); m_itemData.eType = Building.Rocket; GetComponentInChildren <SpriteRenderer>().sortingOrder = 1; PlayerResources.s_instance.Rocket = this; }
public void SetData(ShopItemData data, Action buyItemMethod, Func <bool> canBuyItemMethod) { this.data = data; this.buyItemMethod = buyItemMethod; this.canBuyItemMethod = canBuyItemMethod; this.labelText.text = data.itemName; this.costText.text = data.cost.ToString(); }
private void EnterIdleMode() { DeHighlightCurrentBuilding(); m_placementVisual.gameObject.SetActive(false); EnterState(ControlState.Idle); m_dataCurrent = null; m_currentBuildTile = null; m_buildingCurrent = null; }
public void Initialize(ShopItemData _itemData) { m_itemData = _itemData; m_visual = Instantiate(ShopItemManager.Instance.buildingVisualPrefab, transform, false); m_visual.SetSprite(_itemData.Sprite); _audioSource = GetComponent <AudioSource>(); _audioSource.PlayOneShot(m_itemData.PlacementSfx); StartCoroutine(LateStart(1)); }
public void Initialize(Wallet wallet, ShopItemData item) { _wallet = wallet; _item = item; _nameSlot.text = item.Name; _iconSlot.sprite = item.NewSprite; _priceSlot.text = item.Price.ToString(); }
public void SetOrderAmount(ShopItemData shopItem) { var item = ShoppingCart.First(c => c.Id == shopItem.Id); item.OrderAmount = shopItem.OrderAmount; ShoppingCart[GetIndexOfShoppingCartItem(item)] = item; NotifyStateChanged(); }
public void SetItem(ShopItemData shopItemData) { ItemData = shopItemData; ItemNameLabel.UpdateTranslation(new TranslationData(shopItemData.GetTranslationKey("NAME"))); Price = $"${shopItemData.Price}"; ItemIcon.Style.BackgroundImage = Texture.Load(FileSystem.Mounted, $"assets/icons/{shopItemData.Name}.png") ?? Texture.Load(FileSystem.Mounted, $"assets/none.png"); }
public void AddStoreItem(int id) { //Debug.Log (storeDatabase == null); // Database is not null //Debug.Log(id); StoreItem itemToAdd = storeDatabase.FetchItemByID(id); // Get the item from the database. //Debug.Log(itemToAdd == null); // itemToAdd is returning null; why? // Works for stackable items // Do we have it in our inventory already? Is it stackable? if (itemToAdd.Stackable && CheckIfItemInStore(itemToAdd)) { for (int i = 0; i < items.Count; i++) { if (items [i].ID == id) { ShopItemData data = slots[i].transform.GetChild(0).GetComponent <ShopItemData> (); data.amount++; // We gained 1 of this item. data.transform.GetChild(0).GetComponent <Text> ().text = data.amount.ToString(); // Set stack amnt break; } } // So we don't have it in our inventory. We should add it! } else { for (int i = 0; i < items.Count; i++) { if (items [i].ID == -1) // Check for next empty slot. { items [i] = itemToAdd; GameObject itemObject = Instantiate(storeInventoryItem); // Put this new item in the slot // Set the item instance's itemData attributes. itemObject.GetComponent <ShopItemData>().item = itemToAdd; itemObject.GetComponent <ShopItemData>().slot = i; // 'i' is the inventory slot we're adding to itemObject.transform.SetParent(slots [i].transform); // Set parent to be corresponding slot itemObject.GetComponent <Image> ().sprite = itemToAdd.Sprite; itemObject.name = itemToAdd.Title; // The name of item in each slot ShopItemData data = itemObject.GetComponent <ShopItemData> (); data.amount = 1; itemObject.transform.position = slots [i].transform.position; //Debug.Log (itemObject.transform.position.x); //Debug.Log (itemObject.transform.position.y); break; // We found and processed the item. Time to leave the loop. } } } }
public void Initialize(ShopItemData _data) { m_eType = _data.eType; m_data = _data; m_iCost = m_data.iCost; m_image.sprite = m_data.Sprite; m_resourceCost.SetValue(m_iCost); m_goLevel.SetActive(_data.bHasLevel); m_goWorker.SetActive(_data.bHasWorker); m_txtWorkerCount.text = _data.iWorkerCost.ToString(); }
public static void SaveShopItem(ShopItem item) { BinaryFormatter formatter = new BinaryFormatter(); FileStream stream = new FileStream(shopItemPath + item.name + ".fun", FileMode.Create); ShopItemData data = new ShopItemData(item); formatter.Serialize(stream, data); stream.Close(); }
// 아이템 상세 화면의 내용을 갱신하는 메서드 public void UpdateContent(ShopItemData itemData) { // 아이템의 데이터를 저장해둔다 this.itemData = itemData; iconImage.sprite = SpriteSheetManager.GetSpriteByName("IconAtlas", itemData.iconName); nameLabel.text = itemData.name; priceLabel.text = itemData.price.ToString(); descriptionLabel.text = itemData.description; }
// アイテム詳細画面の内容を更新するメソッド public void UpdateContent(ShopItemData itemData) { // アイテムのデータを保持しておく this.itemData = itemData; iconImage.sprite = SpriteSheetManager.GetSpriteByName("IconAtlas", itemData.iconName); nameLabel.text = itemData.name; priceLabel.text = itemData.price.ToString(); descriptionLabel.text = itemData.description; }
private void SpawnItemInHand(GameObject itemSlot) { ShopItemData shopItem = itemSlot.GetComponent <ShopItemDataContainer>()._item; if (shopItem != null && _itemEntity != null) { Debug.Log("Item Grabbed: " + shopItem.ItemName); GameObject refr = Instantiate(_itemEntity, new Vector3(-15.5f, -0.61f, 0f), Quaternion.identity, _pData.transform); refr.GetComponent <ItemEntityData>()._itemData = shopItem; } }
public void LoadShopItemList() { string dataPath = Application.dataPath; dataPath = Path.Combine(dataPath, "ShopList.csv"); if (File.Exists(dataPath) == false) { return; } FileStream fStream = new FileStream(dataPath, FileMode.Open); if (fStream != null) { StreamReader streamReader = new StreamReader(fStream); string list = streamReader.ReadToEnd(); string[] lines = list.Split("\r\n".ToCharArray()); foreach (string line in lines) { if (line.Length > 0) { string[] data = line.Split(','); ShopItemData iData = new ShopItemData(); iData.itemID = int.Parse(data[0]); iData.itemName = data[1]; int category = int.Parse(data[2]); if (category == 0) { iData.itemCategory = ItemCategory.Weapon; } else if (category == 1) { iData.itemCategory = ItemCategory.Armor; } else if (category == 2) { iData.itemCategory = ItemCategory.Potion; } iData.cost = int.Parse(data[3]); mShopList[iData.itemID] = iData; } } streamReader.Close(); fStream.Close(); } }
public bool TryToBuy(ShopItemData item) { if (_amount < item.Price) { return(false); } item.ApplyEffect(); ProcessPurchase(item.Price); _itemsBought.Add(item); return(true); }
public Entity purchaseItem(ShopItemData data) { Debug.Log("IS IT NULL: " + data); if (Game.instance.getCurrentPlayer().gold >= data.cost) { return(data.createItem()); } else { return(null); } }
public ShopItemData findCheapestItem() { ShopItemData itemToBuy = items[0]; foreach (ShopItemData item in items) { if (item.cost <= itemToBuy.cost) { itemToBuy = item; } } return(itemToBuy); }
public void Load(ShopItemData shopItemData) { this.title.text = shopItemData.entityData.entityName.ToDescription(); this.price.text = "$" + shopItemData.entityData.cost; this.info.ShowInfo(shopItemData); this.buyButton.RegisterOnClickEvent(() => { if (Player.Instance.money < shopItemData.entityData.cost) { //Show some stupid message here return; } if (isBuying && listener != null) { listener.SignalOnCancel(); return; } if (ObjectPlacerListener.IsWorking()) { return; } buybuttonText.SetText("X Buy"); isBuying = true; UI.Instance.ShopItem = shopItemData; if (shopItemData.entityData.name.Equals("Teleporter")) { telBuyRot = UI.Instance.planetCamera.transform.rotation; listener = ObjectPlacerListener.create(); listener.OnCancelListener(OnCancelTeleport); listener.OnPlaceListener(OnTeleportPlace); UI.Instance.planetCamera.SetState(CameraState.TELEPORT); UI.Instance.planetCamera.PivotTranslate(Player.Instance.Planet.transform.position + new Vector3(0, 300, 0)); UI.Instance.planetCamera.PivotTranslateRotation(Quaternion.Euler(90, 0, 0)); UI.Instance.planetCamera.DisableRotation(true); UI.Instance.ShowArea(Player.Instance.Planet.transform.position, ((TeleporterData)shopItemData.entityData.externalData).radius * 2); } else { listener = ObjectPlacerListener.create(); listener.OnCancelListener(OnCancel); listener.OnPlaceListener(OnPlace); Player.Instance.Planet.GetComponent <PlanetObjectPlacer>().PlaceObject(listener, shopItemData.entityData.entityName, () => { Player.Instance.money -= shopItemData.entityData.cost; }); } }); }
void Update() { if (!isHolding) { _currCreatureData = null; _currCreature = null; _currItemData = null; _currItem = null; } if (_pi != null) { CheckInv(); } }
private ShopItemData ParseItems(string itemsString, string mode) { ShopItemData tempItemsData = new ShopItemData(); switch (mode) { case "remove": foreach (ShopItemData itemData in itemsData) { if (itemData.englishName.Equals(itemsString)) { itemData.isOnSale = false; tempItemsData = itemData; Debug.Log("Item Deselected Successfully: " + itemData.englishName); } } break; case "add": foreach (ShopItemData itemData in itemsData) { if (itemData.englishName.Equals(itemsString)) { itemData.isOnSale = true; tempItemsData = itemData; Debug.Log("Item Selected Successfully: " + itemData.englishName); } } break; case "purchase": foreach (ShopItemData itemData in itemsData) { if (itemData.englishName.Equals(itemsString)) { itemData.purchased = true; tempItemsData = itemData; Debug.Log("Item Purchased Successfully: " + itemData.englishName); } } break; default: Debug.Log("ParseItems(single string version) got error"); break; } return(tempItemsData); }
public void LoadShopItem() { ShopItemData data = SaveSystem.LoadShopItem(this.name); if (data == null) { return; } price = data.price; value = data.value; priceMultiplier = data.priceMultiplier; counterToAd = data.counterToAd; numberToAd = data.numberToAd; videoAgainstMoney = data.videoAgainstMoney; }
private void initShop(List <Item> shopItems) { for (int i = 0; i < shopItems.Count; i++) { shopSlots.Add(Instantiate(shopSlotPrefab)); shopSlots[i].transform.SetParent(this.transform); Image itemImg = shopSlots[i].transform.GetChild(1).GetComponent <Image>(); itemImg.sprite = shopItems[i].sprite; Text priceText = shopSlots[i].transform.GetChild(3).GetComponent <Text>(); priceText.text = shopItems[i].buyPrice.ToString(); ShopItemData itemData = shopSlots[i].transform.GetChild(1).GetComponent <ShopItemData>(); itemData.slotIndex = i; itemData.item = shopItems[i]; } }
public void OnEnter(Transform transform, int UIType) { ItemData data = transform.GetComponent <ItemData>(); Item item = null; if (data == null) { ShopItemData data2 = transform.GetComponent <ShopItemData>(); item = data2.item; } else { item = data.item; } if (item == null) { return; } if (item.id == -1) { return; } string text = ""; if (UIType == 0) { text = GetTooltipText(item); } else if (UIType == 1) { text = GetShopTipText(item); } tipText.text = text; tipImage.sprite = item.sprite; contentSizeFitter.SetLayoutVertical(); Vector2 position; RectTransformUtility.ScreenPointToLocalPointInRectangle(GameObject.FindGameObjectWithTag("Canvas").GetComponent <RectTransform>(), Input.mousePosition, null, out position); // Debug.Log(position.x); // Debug.Log(Input.mousePosition.x); // StartCoroutine(Asyn(position)); PanelManager.SetPosition(GetType().ToString(), position); // PanelManager.UnHide(name); }
public List<ShopItemData> GetShopItemDataList () { SQLiteDB sqliteDB = OpenDatabase (); string sql = "select * from " + SHOP_ITEM_DATA_LIST_TABLE + ";"; Debug.Log("sql = "+ sql); SQLiteQuery sqliteQuery = new SQLiteQuery (sqliteDB, sql); List<ShopItemData> shopItemDataList = new List<ShopItemData> (); while(sqliteQuery.Step()){ ShopItemData shopItemData = new ShopItemData(); shopItemData.Id = sqliteQuery.GetInteger(ShopItemDataField.ID); shopItemData.Name = sqliteQuery.GetString(ShopItemDataField.NAME); shopItemData.Description = sqliteQuery.GetString(ShopItemDataField.DESCRIPTION); shopItemData.Tag = sqliteQuery.GetString(ShopItemDataField.TAG); shopItemData.Price = sqliteQuery.GetInteger(ShopItemDataField.PRICE); shopItemData.UnlockLevel = sqliteQuery.GetInteger(ShopItemDataField.UNLOCK_LEVEL); shopItemData.UnLockCondition = sqliteQuery.GetInteger(ShopItemDataField.UNLOCK_CONDITION); shopItemData.TargetRoomId = sqliteQuery.GetInteger(ShopItemDataField.TARGET_ROOM_ID); shopItemData.Effect = sqliteQuery.GetInteger(ShopItemDataField.EFFECT); shopItemDataList.Add(shopItemData); } CloseDatabase (sqliteDB, sqliteQuery); return shopItemDataList; }
void Init (ShopItemData shopItemData) { mShopItemData = shopItemData; InitComponentsByLockLevel(); }
void Init (ShopItemData shopItemData) { nameLabel.text = shopItemData.Name; priceLabel.text = shopItemData.Price + "\u5186"; itemSprite.spriteName = "shop_item_"+ shopItemData.Id; InitComponentsByLockLevel(shopItemData); }
public static void ShopBuyItemEvent(ShopItemData data) { if (!GameAnalytics.IsValide()) { return; } if (data.Type == 1) { GameAnalytics.OnPurchase(GameAnalytics.PurchaseType.ShopBuyItem, data.Price); } }
List<ShopItemData> MoNiData(int nums) { List<ShopItemData> list = new List<ShopItemData>(); for (int i = 0; i < nums; i++) { ShopItemData data = new ShopItemData(); data.id = Random.Range(100, 199); if (data.id >= 100 && data.id < 120) { data.type = 0; } else if (data.id >= 120 && data.id < 140) { data.type = 1; } else if (data.id >= 140 && data.id < 160) { data.type = 2; } else if (data.id >= 160 && data.id < 180) { data.type = 3; } else if (data.id >= 180 && data.id < 200) { data.type = 4; } data.num = Random.Range(1, 99); data.name = "商品" + data.id.ToString(); data.price = data.id + 666; list.Add(data); } return list; }
// 確認画面の内容を更新するメソッド public void UpdateContent(ShopItemData itemData) { messageLabel.text = string.Format("Buy {0} for {1} coins?", itemData.name, itemData.price.ToString()); }