private void SetUpUnlockedItem(Transform unlockedItem, UnlockScroll unlockScroll) { ItemModel im = GameManager.Instance.gameDataCenter.allItemModels.Find(delegate(ItemModel obj) { return(obj.itemId == unlockScroll.unlockedItemId); }); Sprite itemSprite = GameManager.Instance.gameDataCenter.allItemSprites.Find(delegate(Sprite obj) { return(obj.name == im.spriteName); }); Image itemIcon = unlockedItem.Find("ItemIcon").GetComponent <Image> (); Text itemName = unlockedItem.Find("ItemName").GetComponent <Text> (); itemIcon.sprite = itemSprite; itemIcon.enabled = true; itemName.text = im.itemName; unlockedItem.GetComponent <Button> ().onClick.RemoveAllListeners(); unlockedItem.GetComponent <Button> ().onClick.AddListener(delegate { Item item = Item.NewItemWith(im, 1); GetComponent <UnlockedItemsViewController>().itemToCreate = im; SetUpUnlockedItemDetailHUD(item); }); }
// public void OnRefreshButtonClick(){ // queryType = QueryType.Refresh; // ShowQueryHUD (); // } // public void OnHomeButtonClick(){ // queryType = QueryType.Quit; // ShowQueryHUD (); // } // public void OnSettingsButtonClick(){ // GameManager.Instance.UIManager.SetUpCanvasWith (CommonData.settingCanvasBundleName, "SettingCanvas", () => { // TransformManager.FindTransform("SettingCanvas").GetComponent<SettingViewController>().SetUpSettingView(); // },false,true); // QuitPauseHUD (); // } // public void ShowQueryHUD(){ // pauseHUD.SetUpPauseHUD (); // } // public void QuitQueryHUD(){ // pauseHUD.QuitPauseHUD (); // } private void UnlockItemCallBack() { UnlockScroll currentSelectedUnlockScroll = unlockScrollDetail.unlockScroll; currentSelectedUnlockScroll.unlocked = true; Player.mainPlayer.RemoveItem(currentSelectedUnlockScroll, 1); string tint = string.Format("解锁拼写 <color=orange>{0}</color>", currentSelectedUnlockScroll.itemName); SetUpTintHUD(tint, null); }
public void SetUpUnlockScrollDetailHUD(Item item) { SoundManager.Instance.PlayAudioClip("UI/sfx_UI_Paper"); Time.timeScale = 0; UnlockScroll unlockScrollInBag = item as UnlockScroll; this.unlockScroll = unlockScrollInBag; ItemModel itemModel = GameManager.Instance.gameDataCenter.allItemModels.Find(delegate(ItemModel obj) { return(obj.itemId == unlockScrollInBag.unlockedItemId); }); Sprite itemSprite = GameManager.Instance.gameDataCenter.allItemSprites.Find(delegate(Sprite obj) { return(obj.name == itemModel.spriteName); }); unlockedItemIcon.sprite = itemSprite; unlockedItemIcon.enabled = itemSprite != null; unlockedItemName.text = itemModel.itemName; bool hasScrollUnlocked = false; List <UnlockScroll> sameUnlockScrollsInBag = Player.mainPlayer.allUnlockScrollsInBag.FindAll(delegate(UnlockScroll obj) { return(obj.itemId == unlockScroll.itemId); }); for (int i = 0; i < sameUnlockScrollsInBag.Count; i++) { if (sameUnlockScrollsInBag [i].unlocked) { hasScrollUnlocked = true; break; } } statusText.text = hasScrollUnlocked ? "<color=green>已解锁</color>" : "<color=red>未解锁</color>"; unlockedItemDescription.text = itemModel.itemGeneralDescription; unlockButton.gameObject.SetActive(!hasScrollUnlocked); resolveButton.gameObject.SetActive(hasScrollUnlocked); unlockScrollContainer.localScale = new Vector3(0.1f, 0.1f, 1); gameObject.SetActive(true); zoomInCoroutine = UnlockScrollHUDZoomIn(); StartCoroutine(zoomInCoroutine); }
private void UnlockItemCallBack() { UnlockScroll currentSelectedUnlockScroll = unlockScrollDetail.unlockScroll; currentSelectedUnlockScroll.unlocked = true; player.RemoveItem(currentSelectedUnlockScroll, 1); GetComponent <BagViewController> ().AddItemInWait(); string tint = string.Format("解锁拼写 <color=orange>{0}</color>", currentSelectedUnlockScroll.itemName); SetUpTintHUD(tint, null); SetUpBagItemsPlane(currentBagIndex); }
/// <summary> /// 检查物品是否已经被玩家解锁 /// </summary> /// <returns><c>true</c>, if item unlocked was checked, <c>false</c> otherwise.</returns> /// <param name="item">Item.</param> public bool CheckItemUnlocked(int itemId) { for (int i = 0; i < allUnlockScrollsInBag.Count; i++) { UnlockScroll unlockScroll = allUnlockScrollsInBag [i]; if (unlockScroll.unlocked && unlockScroll.unlockedItemId == itemId) { return(true); } } return(false); }
private void ResolveScrollCallBack() { UnlockScroll currentSelectUnlockScroll = unlockScrollDetail.unlockScroll; List <char> charactersReturn = Player.mainPlayer.ResolveItemAndGetCharacters(currentSelectUnlockScroll, 1); StringBuilder tint = new StringBuilder(); tint.Append("获得字母碎片"); for (int i = 0; i < charactersReturn.Count; i++) { tint.Append(charactersReturn [i]); } tintHUD.SetUpTintHUD(tint.ToString(), null); }
/// <summary> /// 通过物品id和数量初始化物品 /// </summary> public static Item NewItemWith(int itemId, int itemCount) { ItemModel itemModel = null; Item newItem = null; if (itemId < 200) { itemModel = GameManager.Instance.gameDataCenter.allItemModels.Find(delegate(ItemModel obj) { return(obj.itemId == itemId); }); if (itemModel == null) { string error = string.Format("未找到id为{0}的物品", itemId); Debug.LogError(error); } switch (itemModel.itemType) { case ItemType.Equipment: newItem = new Equipment(itemModel, itemCount); break; case ItemType.Consumables: newItem = new Consumables(itemModel, itemCount); break; } } else if (itemId < 400) { itemModel = GameManager.Instance.gameDataCenter.allItemModels.Find(delegate(ItemModel obj) { return(obj.itemId == itemId - 200); }); newItem = new UnlockScroll(itemModel); } else { itemModel = GameManager.Instance.gameDataCenter.allItemModels.Find(delegate(ItemModel obj) { return(obj.itemId == itemId - 400); }); newItem = new CraftingRecipe(itemModel); } return(newItem); }
public void SetUpUnlockedItemsView(UnlockScrollType unlockScrollType) { switch (unlockScrollType) { case UnlockScrollType.Equipment: unlockEquipmentTitle.GetComponent <Image> ().sprite = selectedSprite; unlockEquipmentTitle.GetComponentInChildren <Text> ().color = new Color( CommonData.selectedColor.x, CommonData.selectedColor.y, CommonData.selectedColor.z); unlockConsumablesTitle.GetComponent <Image> ().sprite = normalSprite; unlockConsumablesTitle.GetComponentInChildren <Text>().color = new Color( CommonData.deselectedColor.x, CommonData.deselectedColor.y, CommonData.deselectedColor.z); break; case UnlockScrollType.Consumables: unlockConsumablesTitle.GetComponent <Image> ().sprite = selectedSprite; unlockConsumablesTitle.GetComponentInChildren <Text> ().color = new Color( CommonData.selectedColor.x, CommonData.selectedColor.y, CommonData.selectedColor.z); unlockEquipmentTitle.GetComponent <Image> ().sprite = normalSprite; unlockEquipmentTitle.GetComponentInChildren <Text>().color = new Color( CommonData.deselectedColor.x, CommonData.deselectedColor.y, CommonData.deselectedColor.z); break; } unlockedItemsPool.AddChildInstancesToPool(unlockedItemsContainer); for (int i = 0; i < Player.mainPlayer.allUnlockScrollsInBag.Count; i++) { UnlockScroll unlockScroll = Player.mainPlayer.allUnlockScrollsInBag [i]; if (unlockScroll.unlocked && unlockScroll.unlockScrollType == unlockScrollType) { Transform unlockedItem = unlockedItemsPool.GetInstance <Transform> (unlockedItemModel.gameObject, unlockedItemsContainer); SetUpUnlockedItem(unlockedItem, unlockScroll); } } GetComponent <Canvas> ().enabled = true; }
public void RemoveItem(Item item, int removeCount) { switch (item.itemType) { case ItemType.Equipment: Equipment equipment = allEquipmentsInBag.Find(delegate(Equipment obj) { return(obj == item); }); if (equipment.equiped) { for (int i = 0; i < allEquipedEquipments.Length; i++) { if (allEquipedEquipments [i] == equipment) { allEquipedEquipments [i] = new Equipment(); } } } allEquipmentsInBag.Remove(equipment); allItemsInBag.Remove(equipment); // TransformManager.FindTransform ("BagCanvas").GetComponent<BagViewController> ().RemoveItem (item); break; // 如果是消耗品,且背包中已经存在该消耗品,则只合并数量 case ItemType.Consumables: Consumables consumablesInBag = allConsumablesInBag.Find(delegate(Consumables obj) { return(obj == item); }); consumablesInBag.itemCount -= removeCount; if (consumablesInBag.itemCount <= 0) { allConsumablesInBag.Remove(consumablesInBag); allItemsInBag.Remove(consumablesInBag); // TransformManager.FindTransform ("BagCanvas").GetComponent<BagViewController> ().RemoveItem (item); } break; case ItemType.UnlockScroll: UnlockScroll unlockScroll = allUnlockScrollsInBag.Find(delegate(UnlockScroll obj) { return(obj == item); }); if (!unlockScroll.unlocked) { allUnlockScrollsInBag.Remove(unlockScroll); } allItemsInBag.Remove(unlockScroll); break; case ItemType.CraftingRecipes: allItemsInBag.Remove(item); allCraftingRecipesInBag.Remove(item as CraftingRecipe); break; case ItemType.CharacterFragment: CharacterFragment characterFragment = item as CharacterFragment; int characterIndex = (int)(characterFragment.character) - CommonData.aInASCII; if (charactersCount [characterIndex] > 0) { charactersCount [characterIndex]--; } break; } // return removeFromBag; }
/// <summary> /// 添加物品到背包中 /// </summary> /// <param name="item">Item.</param> public void AddItem(Item item) { if (item == null) { string error = "添加的物品为null"; Debug.LogError(error); return; } switch (item.itemType) { case ItemType.Equipment: for (int i = 0; i < item.itemCount; i++) { Equipment equipment = Item.NewItemWith(item, 1) as Equipment; allEquipmentsInBag.Add(equipment); allItemsInBag.Add(equipment); } break; // 如果是消耗品,且背包中已经存在该消耗品,则只合并数量 case ItemType.Consumables: Consumables consumablesInBag = allConsumablesInBag.Find(delegate(Consumables obj) { return(obj.itemId == item.itemId); }); if (consumablesInBag != null) { consumablesInBag.itemCount += item.itemCount; } else { consumablesInBag = new Consumables(item as Consumables, item.itemCount); allConsumablesInBag.Add(item as Consumables); allItemsInBag.Add(item); } break; // case ItemType.FuseStone: // allFuseStonesInBag.Add (item as FuseStone); // allItemsInBag.Add (item); // break; // case ItemType.Task: // allTaskItemsInBag.Add (item as TaskItem); // allItemsInBag.Add (item); // break; case ItemType.UnlockScroll: UnlockScroll unlockScroll = item as UnlockScroll; allUnlockScrollsInBag.Add(unlockScroll); allItemsInBag.Add(unlockScroll); break; case ItemType.CraftingRecipes: allItemsInBag.Add(item); allCraftingRecipesInBag.Add(item as CraftingRecipe); break; case ItemType.CharacterFragment: CharacterFragment characterFragment = item as CharacterFragment; int characterIndex = (int)(characterFragment.character) - CommonData.aInASCII; charactersCount [characterIndex]++; break; } }