public void SetItemData(ItemSlotData data) { ItemBGBtn.Data = data; setIconQiangHuaVisible(false); if (data.IsUnLock()) { if (null == data.MItemData) { if (data.SlotType == ItemSlotType.SHIP_EQUIPMENT) { Icon.PlayAnim(IconShipEquipNulls[data.LocationID]); Plus.transform.localScale = Vector3.one; } else if (data.SlotType == ItemSlotType.CLOTH_BAG) { Icon.PlayAnim(IconNullNormal); Plus.transform.localScale = Vector3.zero; } else { Plus.transform.localScale = Vector3.zero; } Count.transform.localScale = Vector3.zero; } else { Plus.transform.localScale = Vector3.zero; Icon.PlayAnim(data.MItemData.BasicData.Icon); SetItemCount(data); } } else { Icon.PlayAnim(IconLock); } }
/** * tzz added * set the item icon sub-function * * @param _itemIcon item icon prefab * @param _itemInfo item data information */ public static void SetItemIcon(Transform _itemIcon, ItemSlotData _itemInfo, bool _lockedOrEmpty = true) { //SpriteText numTex = _itemIcon.FindChild("Count").GetComponent<SpriteText>(); // SpriteText newTex = _itemIcon.FindChild("NewText").GetComponent<SpriteText>(); PackedSprite sprite = _itemIcon.Find("Icon").GetComponent <PackedSprite>(); PackedSprite Plus = _itemIcon.Find("PlusIndicator").GetComponent <PackedSprite>(); PackedSprite sprite1 = _itemIcon.Find("IconQiangHua1").GetComponent <PackedSprite>(); PackedSprite sprite2 = _itemIcon.Find("IconQiangHua2").GetComponent <PackedSprite>(); PackedSprite sprite3 = _itemIcon.Find("IconQiangHua3").GetComponent <PackedSprite>(); PackedSprite sprite4 = _itemIcon.Find("IconQiangHua4").GetComponent <PackedSprite>(); PackedSprite sprite5 = _itemIcon.Find("IconQiangHua5").GetComponent <PackedSprite>(); List <PackedSprite> iconQianghuaList = new List <PackedSprite>(); iconQianghuaList.Add(sprite1); iconQianghuaList.Add(sprite2); iconQianghuaList.Add(sprite3); iconQianghuaList.Add(sprite4); iconQianghuaList.Add(sprite5); for (int i = 0; i < iconQianghuaList.Count; i++) { PackedSprite packeQianghua = iconQianghuaList[i]; packeQianghua.transform.localScale = Vector3.zero; } if (!InitializedPos) { InitializedPos = true; VisiblePos = new Vector3(0, 0, 0); //numTex.transform.localPosition; } // the PlayAnim has adjust whether gameobject is actived otherwise no effect // bool tFormerSpriteActive = sprite.gameObject.active; sprite.gameObject.active = true; if (_itemInfo != null && _itemInfo.IsUnLock()) { if (null != _itemInfo.MItemData) { if (_itemInfo.MItemData.BasicData.Count > 1) { //numTex.transform.localPosition = VisiblePos; //numTex.Text = _itemInfo.MItemData.BasicData.Count.ToString(); //if(numTex.transform.localScale.x == 1 && Globals.Instance.MGUIManager.widthRatio != 1){ //numTex.transform.localScale = new Vector3(1/Globals.Instance.MGUIManager.widthRatio, //1/Globals.Instance.MGUIManager.heightRatio,1); //} } else { //numTex.transform.localPosition = InvisiblePos; } // newText.Text = "New!"; sprite.Hide(false); sprite.PlayAnim(_itemInfo.MItemData.BasicData.Icon); if (_itemInfo.MItemData.BasicData.StrengthenLevel > 1) { int qianghuaXingLeve = (_itemInfo.MItemData.BasicData.StrengthenLevel - 1) / 20; for (int i = 0; i <= qianghuaXingLeve; i++) { PackedSprite packeQianghua = iconQianghuaList[i]; packeQianghua.transform.localScale = Vector3.one; } } } else { //numTex.transform.localPosition = InvisiblePos; Plus.transform.localPosition = InvisiblePos; sprite.PlayAnim(PackageItemIconSlot.IconNullNormal); } } else { //numTex.transform.localPosition = InvisiblePos; Plus.transform.localPosition = InvisiblePos; sprite.PlayAnim(_lockedOrEmpty ? PackageItemIconSlot.IconLock : PackageItemIconSlot.IconNullNormal); } // restore the active of gameobject sprite.gameObject.active = tFormerSpriteActive; }
/// <summary> /// Shows the op button. /// </summary> /// <param name='_itemData'> /// _item data. hide the all operation button if null /// </param> private void ShowOpBtn(ItemSlotData iItemData) { if (ShopSellItemPackage || HideOperationBtnAlways) { // just return if it's shop sell item pacage // operate outside this class return; } if (iItemData == null || iItemData.MItemData == null) { if (iItemData != null && !iItemData.IsUnLock()) { OperationBtn.transform.localScale = Vector3.zero; OperationBtn.GetComponent <GUIText>().text = Globals.Instance.MDataTableManager.GetWordText(21000006); } else { OperationBtn.transform.localScale = Vector3.one; } SellBtn.transform.localScale = Vector3.one; } else { if (!HideRightOperationBtn) { SellBtn.transform.localScale = Vector3.zero; } if (iItemData.MItemData.BasicData.MajorType == ItemMajorType.MATERIAL || HideLeftOperationBtn) { // mat type item will not display the operation button OperationBtn.transform.localScale = Vector3.one; } else { OperationBtn.transform.localScale = Vector3.zero; } if (iItemData.MItemData.BasicData.MajorType == ItemMajorType.SHIP_EQUIP || iItemData.MItemData.BasicData.MajorType == ItemMajorType.GENERAL_EQUIP) { OperationBtn.GetComponent <GUIText>().text = Globals.Instance.MDataTableManager.GetWordText(21000007); } else if (iItemData.MItemData.BasicData.MajorType == ItemMajorType.JUNHUN) { OperationBtn.GetComponent <GUIText>().text = Globals.Instance.MDataTableManager.GetWordText(23700016); SellBtn.GetComponent <GUIText>().text = Globals.Instance.MDataTableManager.GetWordText(23700001); } else if (iItemData.MItemData.BasicData.MajorType == ItemMajorType.SHIP_CARD || iItemData.MItemData.BasicData.MajorType == ItemMajorType.EQUIPMENT_CARD || iItemData.MItemData.BasicData.MajorType == ItemMajorType.FEMULAR_CARD) { OperationBtn.GetComponent <GUIText>().text = Globals.Instance.MDataTableManager.GetWordText(21000007); // OperationBtn.Text = Globals.Instance.MDataTableManager.GetWordText(21600005); } else if (iItemData.MItemData.BasicData.MajorType == ItemMajorType.GIFT_PACKAGE || iItemData.MItemData.BasicData.MajorType == ItemMajorType.EXPENDABLE || iItemData.MItemData.BasicData.MajorType == ItemMajorType.ZHENTU) { OperationBtn.GetComponent <GUIText>().text = Globals.Instance.MDataTableManager.GetWordText(21000007); } } }