public int CompareBagItem(XItem x1, XItem x2) { DItem itemDB1 = ReadCfgItem.GetDataById(x1.Id); DItem itemDB2 = ReadCfgItem.GetDataById(x2.Id); if (itemDB1.ItemType != itemDB2.ItemType) { return(itemDB1.ItemType - itemDB2.ItemType); } if (itemDB1.Quality != itemDB2.Quality) { return(itemDB2.Quality - itemDB1.Quality); } if (itemDB1.ItemType == EItemType.EQUIP) { XEquip xe1 = DataDBSEquip.GetDataById(x1.Instance); XEquip xe2 = DataDBSEquip.GetDataById(x2.Instance); return(CompareBagEquip(xe1, xe2)); } if (itemDB1.Id != itemDB2.Id) { return(itemDB2.Id - itemDB1.Id); } return(x1.Instance - x2.Instance); }
public bool UseItemById(int id, int num = 1) { DItem itemDB = ReadCfgItem.GetDataById(id); switch (itemDB.ItemType) { case EItemType.MONEY: return(UseMoney(id, num)); case EItemType.ACTION: return(UseAction(id, num)); case EItemType.PETSOUL: return(UseSoul(id, num)); case EItemType.BOX: case EItemType.DRUG: case EItemType.KEY: case EItemType.MAT: return(UseBagItem(id, num)); case EItemType.EXP: return(false); case EItemType.CHIP: return(UseBagChip(id, num)); default: return(false); } }
public bool IsActionFull(int key) { DItem db = ReadCfgItem.GetDataById(key); int count = GTDataManager.Instance.GetItemCountById(key); return(count >= db.Data1); }
private void OnAck_UseItem(MessageRecv obj) { System.IO.MemoryStream ms = new System.IO.MemoryStream(obj.Data); AckUseItem ack = Serializer.Deserialize <AckUseItem>(ms); int pos = ack.Pos; int num = ack.Num; int id = ack.ID; XItem item = DataDBSBagItem.GetDataById(pos); DItem itemDB = ReadCfgItem.GetDataById(item.Id); switch (itemDB.ItemType) { case EItemType.DRUG: GTDataManager.Instance.AddNewItem(itemDB.Data2, itemDB.Data1 * num); GTDataManager.Instance.UseItemById(itemDB.Id, num); break; case EItemType.BOX: break; } GTEventCenter.FireEvent(GTEventID.TYPE_BAG_USE_ITEM, id, num); }
public static void ShowItemDialogById(int itemID) { DItem db = ReadCfgItem.GetDataById(itemID); switch (db.ItemType) { case EItemType.EQUIP: break; case EItemType.DRUG: case EItemType.MAT: case EItemType.ACTION: case EItemType.MONEY: case EItemType.KEY: GTWindowManager.Instance.OpenWindow(EWindowID.UIItemInfo); UIItemInfo itemInfo = (UIItemInfo)GTWindowManager.Instance.GetWindow(EWindowID.UIItemInfo); itemInfo.ShowViewById(itemID); break; case EItemType.GEM: break; case EItemType.CHIP: break; case EItemType.FASHION: break; case EItemType.EXP: break; case EItemType.BOX: break; } }
public bool IsActionFull(EAction type) { DAction actDB = ReadCfgAction.GetDataById(type); DItem db = ReadCfgItem.GetDataById(actDB.ItemID); int count = GTDataManager.Instance.GetActionCountByType(type); return(count >= db.Data1); }
private void ShowDialogueContent(DDialogue db) { string replaceName = string.Empty; switch (db.ContentType) { case EDialogueContentType.TYPE_NONE: { replaceName = string.Empty; } break; case EDialogueContentType.TYPE_PLAYER: { Character c = GTWorld.Main; replaceName = c == null ? string.Empty : c.Name; } break; case EDialogueContentType.TYPE_ACTOR: { DActor actorDB = ReadCfgActor.GetDataById(db.ContentID); replaceName = actorDB == null ? string.Empty : actorDB.Name; } break; case EDialogueContentType.TYPE_ITEM: { DItem itemDB = ReadCfgItem.GetDataById(db.ContentID); replaceName = itemDB == null ? string.Empty : itemDB.Name; } break; case EDialogueContentType.TYPE_MAP: { DCopyMainChapter worldDB = ReadCfgCopyMainChapter.GetDataById(db.ContentID); replaceName = worldDB == null ? string.Empty : worldDB.Name; } break; } dlgContent.text = db.Content.Replace("%p%", replaceName); switch (db.ContentShowType) { case EDialogueContentShowType.Normal: dlgContent.GetComponent <TypewriterEffect>().enabled = false; break; case EDialogueContentShowType.Effect: dlgContent.GetComponent <TypewriterEffect>().enabled = true; dlgContent.GetComponent <TypewriterEffect>().ResetToBeginning(); break; } }
private void ShowCurrRelicsView2() { int targetID = mCards[mCenterIndex].id; DRelics db = ReadCfgRelics.GetDataById(targetID); XRelics relics = DataDBSRelics.GetDataById(targetID); for (int i = 0; i < mRelicsCharges.Count; i++) { RelicsCharge tab = mRelicsCharges[i]; int itemID = db.ArtificeCostID[i]; DItem itemDB = ReadCfgItem.GetDataById(itemID); GTItemHelper.ShowItemName(tab.itemName, itemID); GTItemHelper.ShowItemTexture(tab.itemTexture, itemID); GTItemHelper.ShowItemQuality(tab.itemQuality, itemID); tab.itemNum.text = GTTools.Format("当前拥有:[d96016]{0}[-]", GTDataManager.Instance.GetItemCountById(itemID)); tab.tip.text = GTTools.Format("充能一次加 [d96916]{0}[-] 点经验", itemDB.Data1); if (relics == null) { tab.chargeProgressValue.value = 0; tab.chargeProgressNum.text = GTTools.Format("{0}/{1}", 0, db.LevelExp[0]); } else { int curExp = 0; switch (i + 1) { case 1: curExp = relics.CurExp1; break; case 2: curExp = relics.CurExp2; break; case 3: curExp = relics.CurExp3; break; } int maxExp = db.LevelExp[relics.Level]; GTItemHelper.ShowProgressSlider(tab.chargeProgressValue, curExp, maxExp); tab.chargeProgressNum.text = GTTools.Format("{0}/{1}", curExp, maxExp); } int index = i + 1; UIEventListener.Get(tab.btn).onClick = delegate(GameObject go) { GTAudioManager.Instance.PlayEffectAudio(GTAudioKey.SOUND_UI_CLICK); GTNetworkSend.Instance.TryChargeRelics(targetID, index); }; } }
public void ShowInfoById(int itemID) { DItem itemDB = ReadCfgItem.GetDataById(itemID); itemDesc.text = itemDB.Desc; itemNum.text = string.Empty; GTItemHelper.ShowItemTexture(itemTexture, itemID); GTItemHelper.ShowItemName(itemName, itemID); GTItemHelper.ShowItemQuality(itemQuality, itemID); btnBatchUse.SetActive(false); btnUse.SetActive(false); }
public static void ShowItemQuality(UISprite sprite, int itemID) { if (sprite == null) { return; } DItem itemDB = ReadCfgItem.GetDataById(itemID); DQuality db = ReadCfgQuality.GetDataById(itemDB.Quality); sprite.gameObject.SetActive(true); sprite.spriteName = db.Icon; }
public static bool CheckItemEnongh(int itemID, int costNum) { if (itemID == 0) { return(true); } if (GTDataManager.Instance.GetItemCountById(itemID) < costNum) { DItem itemDB = ReadCfgItem.GetDataById(itemID); GTItemHelper.ShowTip("物品不足:" + itemDB.Name); return(false); } return(true); }
private void OnComposeClick(GameObject go) { GTAudioManager.Instance.PlayEffectAudio(GTAudioKey.SOUND_UI_CLICK); XItem item = DataDBSBagChip.Dict[pos]; int itemID = item.Id; DItem sourceDB = ReadCfgItem.GetDataById(itemID); if (item.Num < sourceDB.Data1) { GTItemHelper.ShowTip("数量不足,无法合成"); return; } GTNetworkSend.Instance.TryComposeChip(pos); }
public static void ShowItemChip(GameObject go, int itemID) { if (go == null) { return; } DItem itemDB = ReadCfgItem.GetDataById(itemID); if (itemDB == null) { return; } go.SetActive(itemDB.ItemType == EItemType.CHIP); }
public static void ShowItemDialogByBagType(EBagType bagType, int pos) { Dictionary <int, XItem> dict = GTDataManager.Instance.GetBagDataByBagType(bagType); if (!dict.ContainsKey(pos)) { return; } XItem item = dict[pos]; DItem db = ReadCfgItem.GetDataById(item.Id); switch (db.ItemType) { case EItemType.EQUIP: GTWindowManager.Instance.OpenWindow(EWindowID.UIEquipInfo); UIEquipInfo w1 = (UIEquipInfo)GTWindowManager.Instance.GetWindow(EWindowID.UIEquipInfo); w1.ShowViewByPos(EPosType.BagItem, pos); break; case EItemType.MAT: GTWindowManager.Instance.OpenWindow(EWindowID.UIItemInfo); UIItemInfo w2 = (UIItemInfo)GTWindowManager.Instance.GetWindow(EWindowID.UIItemInfo); w2.ShowViewByPos(pos, false); break; case EItemType.DRUG: case EItemType.BOX: case EItemType.KEY: GTWindowManager.Instance.OpenWindow(EWindowID.UIItemInfo); UIItemInfo w3 = (UIItemInfo)GTWindowManager.Instance.GetWindow(EWindowID.UIItemInfo); w3.ShowViewByPos(pos, true); break; case EItemType.EXP: break; case EItemType.CHIP: GTWindowManager.Instance.OpenWindow(EWindowID.UIChipInfo); UIChipInfo w4 = (UIChipInfo)GTWindowManager.Instance.GetWindow(EWindowID.UIChipInfo); w4.ShowViewByPos(pos); break; case EItemType.GEM: GTWindowManager.Instance.OpenWindow(EWindowID.UIGemInfo); UIGemInfo w5 = (UIGemInfo)GTWindowManager.Instance.GetWindow(EWindowID.UIGemInfo); w5.ShowViewByPos(EPosType.BagGem, pos); break; } }
public XItem GetItemDataById(int id) { DItem itemDB = ReadCfgItem.GetDataById(id); Dictionary <int, XItem> items = GetBagDataByBagType(itemDB.BagType); XItem item = null; foreach (KeyValuePair <int, XItem> pair in items) { if (pair.Value.Id == id) { item = pair.Value; } } return(item); }
public int CompareBagFashion(XItem x1, XItem x2) { DItem itemDB1 = ReadCfgItem.GetDataById(x1.Id); DItem itemDB2 = ReadCfgItem.GetDataById(x2.Id); if (itemDB1.Quality != itemDB2.Quality) { return(itemDB2.Quality - itemDB1.Quality); } if (itemDB1.Id != itemDB2.Id) { return(itemDB2.Id - itemDB1.Id); } return(x1.Instance - x2.Instance); }
public static void ShowItemName(UILabel lab, int itemID) { if (lab == null) { return; } DItem itemDB = ReadCfgItem.GetDataById(itemID); if (itemDB == null) { return; } string encode = ReadCfgQuality.GetDataById(itemDB.Quality).Encode; lab.text = GTTools.Format("[{0}]{1}[-]", encode, itemDB.Name); }
List <DStore> GetProductListByCurRole(List <DStore> pList) { List <DStore> list = new List <DStore>(); DActor db = ReadCfgActor.GetDataById(RoleModule.Instance.GetCurPlayer().Id); ECarrer carrer = db.Carrer; for (int i = 0; i < pList.Count; i++) { DItem itemDB = ReadCfgItem.GetDataById(pList[i].ItemID); if (itemDB.Carrer == carrer || itemDB.Carrer == ECarrer.O) { list.Add(pList[i]); } } return(list); }
List <DStore> GetProductListByCurRole(List <DStore> pList) { List <DStore> list = new List <DStore>(); DRole db = ReadCfgRole.GetDataById(GTGlobal.CurPlayerCarrerID); int carrer = db.Carrer; for (int i = 0; i < pList.Count; i++) { DItem itemDB = ReadCfgItem.GetDataById(pList[i].ItemID); if (itemDB.Carrer == carrer || itemDB.Carrer == 0) { list.Add(pList[i]); } } return(list); }
public void ShowViewByPos(int pos, bool canUse) { this.pos = pos; XItem item = DataDBSBagItem.GetDataById(pos); int itemID = item.Id; DItem itemDB = ReadCfgItem.GetDataById(itemID); itemDesc.text = itemDB.Desc; itemNum.text = GTTools.Format("拥有数量:{0}", item.Num); GTItemHelper.ShowItemTexture(itemTexture, itemID); GTItemHelper.ShowItemName(itemName, itemID); GTItemHelper.ShowItemQuality(itemQuality, itemID); btnBatchUse.SetActive(canUse); btnUse.SetActive(canUse); btnSure.SetActive(!canUse); }
public void TryComposeChip(int srcPos) { XItem item = DataDBSBagChip.Dict[srcPos]; DItem itemDB = ReadCfgItem.GetDataById(item.Id); int composeNum = item.Num / itemDB.Data1; if (GTItemHelper.CheckBagFull(composeNum, EBagType.GEM)) { return; } ReqComposeChip req = new ReqComposeChip(); req.SrcPos = srcPos; req.Num = composeNum; NetworkManager.Instance.Send <ReqComposeChip>(MessageID.MSG_REQ_COMPOSE_CHIP, req); }
public void ShowInfoByPos(int pos, bool canUse) { this.mPos = pos; XItem item = DataDBSBagItem.GetDataById(pos); int itemID = item.Id; DItem itemDB = ReadCfgItem.GetDataById(itemID); itemDesc.text = itemDB.Desc; int hasNum = GTDataManager.Instance.GetItemCountById(itemID); itemNum.text = GTTools.Format("拥有数量:{0}", hasNum); GTItemHelper.ShowItemTexture(itemTexture, itemID); GTItemHelper.ShowItemName(itemName, itemID); GTItemHelper.ShowItemQuality(itemQuality, itemID); btnBatchUse.SetActive(canUse); btnUse.SetActive(canUse); }
public int GetOneRemainSeconds(EAction actionType) { int index = 0; for (int i = 0; i < mActionKeyList.Count; i++) { int key = mActionKeyList[i]; DItem db = ReadCfgItem.GetDataById(key); EAction type = GetActionType(key); if (type == actionType) { index = i; break; } } return((int)(mActionNextTimes[index] - CurServerTime)); }
private void RefreshView() { List <DStore> pList = MLStore.Instance.GetSelectProductListByStoreType(mStoreType); for (int i = 0; i < 40; i++) { StoreItem tab = mStoreList[i]; if (i >= pList.Count) { tab.obj.SetActive(false); continue; } tab.obj.SetActive(true); DStore db = pList[i]; DItem itemDB = ReadCfgItem.GetDataById(db.ItemID); GTItemHelper.ShowItemTexture(tab.itemTexture, db.ItemID); GTItemHelper.ShowItemQuality(tab.itemQuality, db.ItemID); GTItemHelper.ShowItemName(tab.itemName, db.ItemID); tab.itemNum.text = db.ItemNum.ToString(); if (db.CostMoneyID > 0) { tab.costMoneyNum.text = db.CostMoneyNum.ToString(); GTItemHelper.ShowItemTexture(tab.costMoneyTexture, db.CostMoneyID); } else { tab.costMoneyNum.text = string.Empty; tab.costMoneyTexture.gameObject.SetActive(false); } UIEventListener.Get(tab.btnBuy).onClick = delegate(GameObject go) { GTAudioManager.Instance.PlayEffectAudio(GTAudioKey.SOUND_UI_CLICK); GTNetworkSend.Instance.TryBuyStore(mStoreType, db.Id, 1); }; UIEventListener.Get(tab.itemBtn).onClick = delegate(GameObject go) { GTAudioManager.Instance.PlayEffectAudio(GTAudioKey.SOUND_UI_CLICK); GTItemHelper.ShowItemDialogById(itemDB.Id); }; } }
public void ShowAwardById(int award, int rewardState, UIEventListener.VoidDelegate doReceive) { List <KStruct> list = AwardModule.Instance.GetAwardDataByID(award); DAward db = ReadCfgAward.GetDataById(award); for (int i = 0; i < items.Count; i++) { Item it = items[i]; if (i < list.Count) { KStruct vo = list[i]; it.itemBtn.SetActive(true); it.itemNum.text = vo.Num > 1 ? vo.Num.ToString() : string.Empty; GTItemHelper.ShowItemTexture(it.itemTexture, vo.Id); GTItemHelper.ShowItemQuality(it.itemQuality, vo.Id); GTItemHelper.ShowItemName(it.itemName, vo.Id); DItem itemDB = ReadCfgItem.GetDataById(vo.Id); it.chip.SetActive(itemDB.ItemType == EItemType.CHIP); } else { it.itemBtn.SetActive(false); } } switch (rewardState) { case ERewardState.NOT_RECEIVE: btnReceive.GetComponent <UISprite>().color = Color.black; btnReceive.transform.Find("Label").GetComponent <UILabel>().text = "领取"; break; case ERewardState.CAN_RECEIVE: btnReceive.GetComponent <UISprite>().color = Color.white; btnReceive.transform.Find("Label").GetComponent <UILabel>().text = "领取"; break; case ERewardState.HAS_RECEIVE: btnReceive.GetComponent <UISprite>().color = Color.black; btnReceive.transform.Find("Label").GetComponent <UILabel>().text = "已领取"; break; } labTitle.text = db.Name; DoReceive = doReceive; }
void ChangeWeapon(int id) { DItem itemDB = ReadCfgItem.GetDataById(id); if (itemDB == null) { return; } GTResourceManager.Instance.DestroyObj(mWeaponMat1); GTResourceManager.Instance.DestroyObj(mWeaponMat2); GTResourceManager.Instance.DestroyObj(mWeapon1); GTResourceManager.Instance.DestroyObj(mWeapon2); if (mHand1 != null && !string.IsNullOrEmpty(itemDB.Model_R)) { mWeapon1 = GTResourceManager.Instance.Load <GameObject>(itemDB.Model_R, true); if (mWeapon1 != null) { NGUITools.SetLayer(mWeapon1, mRoot.gameObject.layer); GTTools.ResetLocalTransform(mWeapon1.transform, mHand1); MeshRenderer renderer = mWeapon1.GetComponent <MeshRenderer>(); if (renderer == null) { renderer = mWeapon1.GetComponentInChildren <MeshRenderer>(); } mWeaponMat1 = renderer == null ? null : renderer.material; mWeaponShader1 = mWeaponMat1 == null ? null : mWeaponMat1.shader; } } if (mHand2 != null && !string.IsNullOrEmpty(itemDB.Model_L)) { mWeapon2 = GTResourceManager.Instance.Load <GameObject>(itemDB.Model_L, true); if (mWeapon2 != null) { NGUITools.SetLayer(mWeapon2, mRoot.gameObject.layer); GTTools.ResetLocalTransform(mWeapon2.transform, mHand2); MeshRenderer renderer = mWeapon2.GetComponent <MeshRenderer>(); if (renderer == null) { renderer = mWeapon2.GetComponentInChildren <MeshRenderer>(); } mWeaponMat2 = renderer == null ? null : renderer.material; mWeaponShader2 = mWeaponMat2 == null ? null : mWeaponMat2.shader; } } }
public int GetExpByItemList(List <XItem> list) { int exp = 0; if (list == null) { return(0); } for (int i = 0; i < list.Count; i++) { XItem tab = list[i]; if (IsFood(tab.Id)) { exp += ReadCfgItem.GetDataById(tab.Id).Data1; } } return(exp); }
public List <XItem> GetAllEquipMatList() { mAllStrengthenMatList.Clear(); Dictionary <int, XItem> .Enumerator em = DataDBSBagItem.Dict.GetEnumerator(); while (em.MoveNext()) { XItem item = em.Current.Value;; DItem itemDB = ReadCfgItem.GetDataById(item.Id); if (itemDB.ItemType != EItemType.EQUIP) { continue; } mAllStrengthenMatList.Add(item); } em.Dispose(); mAllStrengthenMatList.Sort(CompareStrengthMat); return(mAllStrengthenMatList); }
public static void ShowItemTexture(UITexture tex, int itemID) { if (tex == null) { return; } DItem itemDB = ReadCfgItem.GetDataById(itemID); Texture2D t2d = GTResourceManager.Instance.Load <Texture2D>(string.Format("Textures/Item/{0}", itemDB.Icon)); if (t2d == null) { t2d = new Texture2D(64, 64, TextureFormat.ARGB32, false); t2d.wrapMode = TextureWrapMode.Clamp; t2d.name = "None"; } tex.mainTexture = t2d; tex.gameObject.SetActive(true); }
public List <XItem> GetBagSameEquipList(XEquip equip) { List <XItem> list = new List <XItem>(); Dictionary <int, XItem> .Enumerator em = DataDBSBagItem.Dict.GetEnumerator(); while (em.MoveNext()) { XItem item = em.Current.Value; DItem itemDB = ReadCfgItem.GetDataById(item.Id); if (itemDB.ItemType != EItemType.EQUIP) { continue; } XEquip e = DataDBSEquip.GetDataById(item.Instance); if (e.Id != equip.Id) { continue; } if (e.Instance == equip.Instance) { continue; } if (e.StarLevel > 0) { continue; } if (e.StrengthenLevel > 0) { continue; } if (e.StrengthenExp > 0) { continue; } if (e.AdvanceLevel > 0) { continue; } list.Add(item); } em.Dispose(); return(list); }