public List <NItemInfo> GetBuildingUpgradeCost(NDictionary args) { if (args == null) { return(null); } int fromConfigID = args.Value <int>("configID"); List <NItemInfo> costInfoList = new List <NItemInfo>(); var buildingConfigDataMap = ConfigDataStatic.GetConfigDataTable("BUILDING"); BUILDING buildingConfigData = buildingConfigDataMap[fromConfigID] as BUILDING; for (int i = 0; i < buildingConfigData.CostTableCount; i++) { var costData = buildingConfigData.GetCostTable(i); int configID = costData.CostId; if (configID == 0) { continue; } int number = costData.CostQty; NItemInfo info = new NItemInfo(); info.configID = configID; info.number = number; costInfoList.Add(info); } return(costInfoList); }
public override void DrawCell(int i, int index, int count = 0) { base.DrawCell(i, index, count); var dataList = dynamicPackage.GetFilteredTradeInfoList(); if (mIndex >= dataList.Count) { return; } NTradeInfo tradeInfo = dataList[mIndex]; ITEM_RES config = itemPackage.GetItemDataByConfigID(tradeInfo.configID); nameLabel.text = config.MinName; iconSprite.spriteName = config.IconName; NItemInfo info = itemPackage.GetItemInfo(tradeInfo.configID); if (info == null) { numLabel.text = "0"; } else { numLabel.text = GlobalFunction.NumberFormat(info.number); } }
public void AddItem(ResourceInfo resInfo) { //Debug.Log(string.Format("item add , id={0}", resInfo.ConfigId)); if (mItemInfoMap.ContainsKey(resInfo.ConfigId)) { NItemInfo info = mItemInfoMap[resInfo.ConfigId]; info.number = resInfo.Number; } else { NItemInfo info = new NItemInfo(resInfo); mItemInfoMap[info.configID] = info; } }
public NItemInfo GetItemInfo(int configID) { if (!mItemInfoMap.ContainsKey(configID)) { //Debug.Log(string.Format("item{0} not exist", GetItemDataByConfigID(configID))); return(null); } NItemInfo info = mItemInfoMap[configID]; if (info.number <= 0) { return(null); } return(info); }
public int GetResourceTotolNumber() { int sum = 0; foreach (var pair in mItemInfoMap) { NItemInfo info = pair.Value; ItemType type = GetItemTypeByConfigID(info.configID); if (type == ItemType.Food || type == ItemType.Product) { //ITEM_RES config = GetItemDataByConfigID(info.configID); sum += info.number; } } return(sum); }
public override void DrawCell(int index, int count = 0) { int dataIndex = index; UICostResPanel panel = FacadeSingleton.Instance.RetrievePanel("UICostResPanel") as UICostResPanel; List <NItemInfo> costInfoList = panel.GetCostInfoList(); if (costInfoList == null) { return; } NItemInfo info = costInfoList[dataIndex]; ItemPackage itemPackage = FacadeSingleton.Instance.RetrieveData(ConstVal.Package_Item) as ItemPackage; nameLabel.text = itemPackage.GetItemDataByConfigID(info.configID).MinName; valueLabel.text = info.number.ToString(); }
public Result SellItem(NetConnection <NetSession> sender, NItemInfo itemInfo) { ItemDefine itemDefine; if (!DataManager.Instance.Items.TryGetValue(itemInfo.Id, out itemDefine)) { return(Result.Failed); } if (!sender.Session.Character.itemManager.HasItem(itemInfo.Id, itemInfo.Count)) { return(Result.Failed); } sender.Session.Character.itemManager.RemoveItem(itemInfo.Id, itemInfo.Count); ApplyCurrency(sender.Session.Character, itemDefine, itemInfo.Count); return(Result.Success); }
public int GetRousourceTotalCap() { int sum = 0; foreach (var pair in mItemInfoMap) { NItemInfo info = pair.Value; ITEM_RES config = GetItemDataByConfigID(info.configID); if (config == null) { Debug.Log(string.Format("item configID= {0} missing", info.configID)); continue; } sum += config.StorUnit * info.number; } return(sum); }
public bool IsAbleToUnlockOrUpgrade(int configID) { int requireVal; double curVal; ItemPackage itemPackage = FacadeSingleton.Instance.RetrieveData(ConstVal.Package_Item) as ItemPackage; UserPackage userPackage = FacadeSingleton.Instance.RetrieveData(ConstVal.Package_User) as UserPackage; BUILDING config = GetBuildingConfigDataByConfigID(configID); //level requireVal = config.BldgLvLim; curVal = userPackage.GetManorLevel(); if (curVal < requireVal) { return(false); } //gold cost requireVal = config.GoldCost; curVal = itemPackage.GetGoldNumber(); if ((double)requireVal > curVal) { return(false); } //item for (int i = 0; i < config.CostTableCount; i++) { var cost = config.GetCostTable(i); if (cost.CostId == 0) { continue; } requireVal = cost.CostQty; NItemInfo info = itemPackage.GetItemInfo(cost.CostId); // ITEM_RES itemConfig = itemPackage.GetItemDataByConfigID(cost.CostId); // if(itemConfig == null) // { // Debug.Log(string.Format("configID = {0} missing!!!", cost.CostId)); // continue; // } if (info == null || info.number < cost.CostQty) { return(false); } } return(true); }
void InitView() { NItemInfo info = itemPackage.GetSelectionItem(); ITEM_RES configData = itemPackage.GetItemDataByConfigID(info.configID); nameLabel.text = configData.MinName; numLabel.text = info.number.ToString(); descLabel.text = configData.Desc; iconSprite.spriteName = configData.IconName; if (configData.IfAvailable == 1) { ShowEffect(configData.Id); } else { tableView.DataCount = 0; tableView.TableChange(); } }
private void OnSearchBoxListBoxItemSelected(NEventArgs arg) { if (arg.Cancel) { return; } INSearchableListBox listBox = (INSearchableListBox)arg.TargetNode; NWidget selectedItem = ((NKeyValuePair <string, NWidget>)listBox.GetSelectedItem()).Value; if (selectedItem != null && TileSelected != null) { NItemInfo tileInfo = (NItemInfo)selectedItem.Tag; TileSelected(tileInfo.XmlElement); } // Mark the event as handled arg.Cancel = true; }
void InitView(NDictionary data = null) { configID = itemPackage.GetSelectionItemConfigID(); isBuy = data.Value <bool>("isbuy"); ITEM_RES config = itemPackage.GetItemDataByConfigID(configID); if (isBuy) { titleLabel.text = string.Format("购买 {0}", config.MinName); double price = itemPackage.GetItemPrice(configID); double curGold = itemPackage.GetGoldNumber(); double tax = itemPackage.GetTaxRate(); itemCap = Mathf.Min(itemPackage.GetBuyLimit(configID), (int)(curGold / (price * (1 + tax)))); btnLabel.text = "购买"; } else { NItemInfo info = itemPackage.GetItemInfo(configID); titleLabel.text = string.Format("出售 {0}", config.MinName); itemCap = info.number; if (itemCap <= 0) { ITEM_RES test = itemPackage.GetItemDataByConfigID(info.configID); print(string.Format("{0}'s number is zero", test.MinName)); } btnLabel.text = "出售"; } if (config.GoldConv >= 1000) { ratio = 1; } else { ratio = 1000 / config.GoldConv; } itemCap = AdjustCap(ratio, itemCap); value = 0; slider.value = 0f; slider.numberOfSteps = (int)Mathf.Ceil((float)itemCap / (float)ratio) + 1; UpdateValueView(); }
public override void DrawCell(int i, int index, int count = 0) { base.DrawCell(i, index, count); int dataCount = mIndex; List <NItemInfo> itemInfoList = itemPackage.GetItemFilterInfoList(); info = itemInfoList[dataCount]; var itemDataMap = ConfigDataStatic.GetConfigDataTable("ITEM_RES"); if (!itemDataMap.ContainsKey(info.configID)) { Debug.Log(string.Format("item configID={0} cant find config", info.configID)); return; } ITEM_RES itemConfigData = itemDataMap[info.configID] as ITEM_RES; nameLabel.text = itemConfigData.MinName; numLabel.text = GlobalFunction.NumberFormat(info.number); iconSprite.spriteName = itemConfigData.IconName; }
void RefreshItemInfo() { int selectionConfigID = itemPackage.GetSelectionItemConfigID(); if (selectionConfigID == 0) { taxLabel.text = ""; nameLabel.text = ""; cdTimeLabel.text = ""; return; } var dataList = ConfigDataStatic.GetConfigDataTable("ITEM_RES"); if (!dataList.ContainsKey(selectionConfigID)) { Debug.Log(string.Format("ITEM_RES config={0} missing", selectionConfigID)); return; } ITEM_RES itemConfig = dataList[selectionConfigID] as ITEM_RES; taxLabel.text = string.Format("当前中间人费用{0}%", itemPackage.GetTaxRate() * 100); nameLabel.text = string.Format("{0}近3日价格", itemConfig.MinName); priceLabel.text = string.Format("当前价格: {0}", itemPackage.GetItemPrice(selectionConfigID).ToString("0.00")); //set buy & sell button NItemInfo info = itemPackage.GetItemInfo(itemPackage.GetSelectionItemConfigID()); //PURCHASE_LIM limConfig = ConfigDataStatic.GetConfigDataTable("PURCHASE_LIM")[userPackage.GetPlayerLevel()] as PURCHASE_LIM; if (info == null || info.number <= 0) { sellBtn.isEnabled = false; } else { sellBtn.isEnabled = true; } RefreshBuyLimit(); RefreshGraph(); }
protected override void OnMouseUp(NMouseButtonEventArgs args) { base.OnMouseUp(args); if (args.Cancel || args.Button != ENMouseButtons.Left) { return; } if (args.TargetNode is NImageBox && args.TargetNode.Tag is NXmlElement) { OnExampleCategoryMouseUp(args); return; } // Get the clicked example tile NExampleTile tile = args.TargetNode as NExampleTile; if (tile == null) { tile = (NExampleTile)args.TargetNode.GetFirstAncestor(NExampleTile.NExampleTileSchema); } if (tile == null) { return; } NItemInfo itemInfo = (NItemInfo)tile.Tag; if (TileSelected != null) { TileSelected(itemInfo.XmlElement); } // Mark the event as handled args.Cancel = true; }
public void SetSelectionItem(NItemInfo info) { selectionItem = info; }
void InitView() { NBuildingInfo info = sanctuaryPackage.GetBuildingInfo(selectionBuilding.BuildingID); var buildingDataMap = ConfigDataStatic.GetConfigDataTable("BUILDING"); BUILDING buildingData = buildingDataMap[info.configID] as BUILDING; int level = sanctuaryPackage.GetBulidingLevelByConfigID(info.configID); long remainTime = 0; //check if is crafting isCrafting = false; isCollect = false; if (GlobalFunction.GetRemainTime(info.processFinishTime, out remainTime)) { isCrafting = true; } else if (info.number > 0) { isCollect = true; } toConfigID = buildingData.ProId; fromConfigID = buildingData.ConId; //item name var itemDataMap = ConfigDataStatic.GetConfigDataTable("ITEM_RES"); ITEM_RES itemData = itemDataMap[fromConfigID] as ITEM_RES; fromItemName.text = itemData.MinName; fromSprite.spriteName = itemData.IconName; ratio = buildingData.ConPro; itemData = itemDataMap[toConfigID] as ITEM_RES; toItemName.text = itemData.MinName; describeLabel.text = itemData.Desc; toSprite.spriteName = itemData.IconName; descSprite.spriteName = itemData.IconName; // set number NItemInfo itemInfo = itemPackage.GetItemInfo(fromConfigID); craftNum = 0; slider.value = 0f; if (itemInfo == null) { craftMax = 0; } else { int toItemMax = (int)Mathf.Floor((float)itemInfo.number / (float)ratio); craftMax = toItemMax * ratio; slider.numberOfSteps = (int)Mathf.Ceil((float)craftMax / (float)ratio) + 1; } //check if is self if (info.processUID == userPackage.UserID) { isSelf = true; } else { isSelf = false; } //text title.text = string.Format("{0} Lv.{1}", buildingData.BldgName, level); collectButton.gameObject.SetActive(false); cancelButton.gameObject.SetActive(false); //stop timer if (TimerCo != null) { timeLabel.text = "00:00"; StopCoroutine(TimerCo); } if (isCrafting) { //check if is self if (isSelf) { stateLabel.text = "你正在使用"; cancelButton.gameObject.SetActive(true); } else { stateLabel.text = string.Format("玩家Uid{0}正在使用", info.processUID); } //set time if (remainTime > 0) { TimerCo = StartCoroutine(Timer(remainTime)); } } else if (isCollect) { if (isSelf) { stateLabel.text = string.Format("可以领取{0}", info.number); collectButton.gameObject.SetActive(true); } timeLabel.text = "00:00"; } else { stateLabel.text = "该工厂处于空闲状态"; collectButton.gameObject.SetActive(false); cancelButton.gameObject.SetActive(false); } UpdateNumView(); }
public Item(NItemInfo item) : this(item.Id, item.Count) { }
void ShowCost(BUILDING configData) { int count = 0; //show gold & elec if (configData.GoldCost > 0) { int costNum = configData.GoldCost; double curNum = itemPackage.GetGoldNumber(); costCellList[count].title.text = "黄金消耗: "; costCellList[count].value.text = string.Format("{0} / {1}", GlobalFunction.NumberFormat(costNum), GlobalFunction.NumberFormat(curNum)); costCellList[count].go.SetActive(true); if ((double)costNum > curNum) { costCellList[count].title.color = Color.red; costCellList[count].value.color = Color.red; } else { costCellList[count].title.color = Color.white; costCellList[count].value.color = Color.white; } count++; } if (configData.ElecCost > 0) { int costNum = configData.ElecCost; double curNum = itemPackage.GetElecNumber(); costCellList[count].title.text = "电力消耗: "; costCellList[count].value.text = string.Format("{0} / {1}", GlobalFunction.NumberFormat(costNum), GlobalFunction.NumberFormat(curNum)); costCellList[count].go.SetActive(true); if ((double)costNum > curNum) { costCellList[count].title.color = Color.red; costCellList[count].value.color = Color.red; } else { costCellList[count].title.color = Color.white; costCellList[count].value.color = Color.white; } count++; } for (int i = 0; i < configData.CostTableCount; i++) { int itemConfigId = configData.GetCostTable(i).CostId; if (itemConfigId == 0) { continue; } int num = configData.GetCostTable(i).CostQty; ITEM_RES itemData = itemPackage.GetItemDataByConfigID(itemConfigId); NItemInfo itemInfo = itemPackage.GetItemInfo(itemConfigId); int curNum = itemInfo == null ? 0 : itemInfo.number; costCellList[count].title.text = itemData.MinName + ": "; costCellList[count].value.text = string.Format("{0} / {1}", num.ToString(), curNum); costCellList[count].go.SetActive(true); if (itemInfo == null || itemInfo.number < num) { costCellList[count].title.color = Color.red; costCellList[count].value.color = Color.red; } else { costCellList[count].title.color = Color.white; costCellList[count].value.color = Color.white; } count++; } for (; count < 5; count++) { costCellList[count].go.SetActive(false); } }
public Item(NItemInfo itemInfo) { ID = itemInfo.Id; Count = itemInfo.Count; define = DataManager.Instance.Items[ID]; }
public Item(NItemInfo item) { Id = item.Id; Count = item.Count; }
public override void DrawCell(int index, int count = 0) { base.DrawCell(index, count); var dataList = sanctuaryPackage.GetBuildingCostList(); NCostDef cost = dataList[index]; bool isEnough = true; if (cost.configID == 1) { nameLabel.text = string.Format("庄园等级限制:"); valueLabel.text = string.Format("{0}/{1}", cost.value, userPackage.GetManorLevel()); if (userPackage.GetManorLevel() < cost.value) { isEnough = false; } } else if (cost.configID == 2) { nameLabel.text = string.Format("黄金:"); valueLabel.text = string.Format("{0}/{1}", cost.value, GlobalFunction.NumberFormat(itemPackage.GetGoldNumber())); if (itemPackage.GetGoldNumber() < cost.value) { isEnough = false; } } else if (cost.configID == 3) { nameLabel.text = string.Format("电力:"); valueLabel.text = string.Format("{0}/{1}", cost.value, GlobalFunction.NumberFormat(itemPackage.GetElecNumber())); if (itemPackage.GetElecNumber() < cost.value) { isEnough = false; } } else { ITEM_RES itemData = itemPackage.GetItemDataByConfigID(cost.configID); if (itemData == null) { return; } nameLabel.text = string.Format("{0}:", itemData.MinName); NItemInfo itemInfo = itemPackage.GetItemInfo(cost.configID); if (itemInfo == null) { valueLabel.text = string.Format("{0}/{1}", cost.value, 0); isEnough = false; } else { valueLabel.text = string.Format("{0}/{1}", cost.value, GlobalFunction.NumberFormat(itemInfo.number)); if (itemInfo.number < cost.value) { isEnough = false; } } } if (isEnough) { nameLabel.color = Color.white; valueLabel.color = Color.white; } else { nameLabel.color = Color.red; valueLabel.color = Color.red; } }