/* TEMPORARY METHODS */ /*public void addGold() { * DataAndSettingsManager.setGoldAmount(DataAndSettingsManager.getGoldAmount() + 100); * this.updateGoldLabel(); * } * * public void subtractGold() { * DataAndSettingsManager.setGoldAmount(DataAndSettingsManager.getGoldAmount() - 1); * this.updateGoldLabel(); * }*/ /* * * * Private methods * * * */ ///<summary>Populates the list of store items with `StoreListItem`s /// and adjusts the heights of the content rects.</summary> private void setupList() { // expendables for (int i = 0; i < StoreManager.getNumExpendables(); i++) { StoreListItem item = Instantiate(this.listItemPrefab, new Vector2(0f, -LIST_ITEM_HEIGHT * i - LIST_TITLE_HEIGHT), Quaternion.identity) as StoreListItem; RectTransform itemRect = item.gameObject.GetComponent <RectTransform>(); itemRect.SetParent(this.expendablesListContentRect.transform, false); item.setup(i, true, this.updateGoldLabel); } // unlockables for (int i = StoreManager.getNumExpendables(); i < StoreManager.getNumItems(); i++) { StoreListItem item = Instantiate(this.listItemPrefab, new Vector2(0f, -LIST_ITEM_HEIGHT * (i - StoreManager.getNumExpendables()) - LIST_TITLE_HEIGHT), Quaternion.identity) as StoreListItem; RectTransform itemRect = item.gameObject.GetComponent <RectTransform>(); itemRect.SetParent(this.unlockablesListContentRect.transform, false); item.setup(i, false, this.updateGoldLabel); } // adjust content rect heights and positions - anchors are at top left and top right RectTransform expendablesRect = this.expendablesListContentRect.GetComponent <RectTransform>(); float expendablesRectHeight = LIST_ITEM_HEIGHT * StoreManager.getNumExpendables() + LIST_TITLE_HEIGHT; expendablesRect.sizeDelta = new Vector2(0f, expendablesRectHeight); RectTransform unlockablesRect = this.unlockablesListContentRect.GetComponent <RectTransform>(); float unlockablesRectHeight = LIST_ITEM_HEIGHT * (StoreManager.getNumItems() - StoreManager.getNumExpendables()) + LIST_TITLE_HEIGHT; unlockablesRect.sizeDelta = new Vector2(0f, unlockablesRectHeight); RectTransform purchasablesRect = this.purchasablesListContentRect.GetComponent <RectTransform>(); float purchasablesRectHeight = LIST_ITEM_HEIGHT * IAPManager.getNumIAPs() + LIST_TITLE_HEIGHT; purchasablesRect.sizeDelta = new Vector2(0f, purchasablesRectHeight); }
void PresentStore() { SetupData(); ItemTitle.text = ""; ItemDescription.text = ""; CoinsCostText.Text = ""; StoreItem storeItem = null; int i; // add purchased items for (i = 0; i < Database.Instance.CurrentGearList.Count; i++) { if (Database.Instance.CurrentGearList[i].Purchased) { StoreListItem item = (StoreListItem)GameObject.Instantiate(ItemPrefab, Vector3.zero, Quaternion.identity); item.Type = (GearType)Enum.Parse(typeof(GearType), Database.Instance.CurrentGearList[i].Type, true); item.Setup(Database.Instance.CurrentGearList[i]); StoreList.AddListElement(item); } } // add non-purchased items for (i = 0; i < Database.Instance.CurrentGearList.Count; i++) { if (!Database.Instance.CurrentGearList[i].Purchased) { StoreListItem item = (StoreListItem)GameObject.Instantiate(ItemPrefab, Vector3.zero, Quaternion.identity); item.Type = (GearType)Enum.Parse(typeof(GearType), Database.Instance.CurrentGearList[i].Type, true); item.Setup(Database.Instance.CurrentGearList[i]); StoreList.AddListElement(item); } } }
void SetUnequipped(StoreItem storeItem) { Type itemType = storeItem.GetType(); if (itemType == typeof(StoreItem)) { StoreItem item = storeItem as StoreItem; UnequipGear(item); SetupBuyButton(storeItem); _currentItem.Unselect(); AvatarView.Instance.RemoveGear(_currentItem.Object as StoreItem); _currentItem = null; SetupBuyButton(null); } }
void ShowTypeItems(GearType gearType) { //Debug.Log("show item types " + gearType); for (int i = 0; i < StoreList.ListItems.Count; i++) { StoreListItem storeListItem = StoreList.ListItems[i] as StoreListItem; if (storeListItem.Type == gearType) { StoreList.ListItems[i].gameObject.SetActive(true); } else { StoreList.ListItems[i].gameObject.SetActive(false); } } _filter = gearType; }
void ItemSelected(StoreListItem obj) { //Debug.Log("ItemSelected 1 - currentItem = "); SoundManager.Instance.PlaySoundEffect(SoundType.SOFT_CLICK); //Debug.Log("ItemSelected 2"); if (_currentItem) { AvatarView.Instance.RemoveGear(_currentItem.Object as StoreItem); _currentItem.Unselect(); } _currentItem = obj; StoreItem storeItem = _currentItem.Object as StoreItem; //Debug.Log("ItemSelected 3 " + storeItem.AssetName); ItemTitle.text = storeItem.DisplayName; ItemDescription.text = storeItem.Description; SetupBuyButton(storeItem); if (!storeItem.Equipped) { AvatarView.Instance.SetGearBonusWithoutItemsOfType(storeItem.Type); } else { AvatarView.Instance.SetGearBonus(); } //AvatarView.Instance.SetGearBonus(); //Debug.Log(Avatar.Instance.Health + " + " + Avatar.Instance.HealthBonus); AvatarView.Instance.ResetStats(); AvatarView.Instance.DisplayGear(_currentItem.Object as StoreItem); if (!storeItem.Equipped) { //Debug.Log(storeItem.Name + " " + storeItem.AssetName + " " + storeItem.HealthBonus); AvatarView.Instance.AdjustStats(storeItem.HealthBonus, storeItem.SpeedBonus, storeItem.RangeBonus, storeItem.Type); } }
void CheckCurrentItemForFilter() { if (_currentItem != null) { StoreItem gearItem = _currentItem.Object as StoreItem; if (gearItem.Type != _filter.ToString()) { if (_currentItem != null) { AvatarView.Instance.RemoveGear(_currentItem.Object as StoreItem); _currentItem.Unselect(); _currentItem.SetBackground(); _currentItem = null; } ItemTitle.text = ""; ItemDescription.text = ""; CoinsCostText.Text = ""; CoinsImage.Deactivate(); GemCostText.Text = ""; GemImage.Deactivate(); BuyButton.Deactivate(); } } }