void InitPlayerInfo() { PlayerState state = userPackage.GetPlayerState(); bloodProgess.value = (float)state.blood / (float)(20 + 2 * state.health); bloodLabel.text = string.Format("{0}/{1}", state.blood, 20 + 2 * state.health); hungerProgress.value = (float)state.hunger / (float)(20 + 2 * state.health); hungerLabel.text = string.Format("{0}/{1}", state.hunger, 20 + 2 * state.health); thirstProgress.value = (float)state.thirst / (float)(20 + 2 * state.health); thirstLabel.text = string.Format("{0}/{1}", state.thirst, 20 + 2 * state.health); interestLabel.text = string.Format("分配比例:{0:f}%", (float)userPackage.GetPlayerInterest() * 100); resLabel.text = GlobalFunction.NumberFormat(itemPackage.GetResourceTotolNumber()); moneyLabel.text = GlobalFunction.NumberFormat(itemPackage.GetGoldNumber()); elecLabel.text = string.Format("{0}/h", GlobalFunction.NumberFormat(sanctuaryPackage.GetTotalProEfficiency())); attackLabel.text = state.attack.ToString(); defenseLable.text = state.defense.ToString(); agileLabel.text = state.agile.ToString(); speedLabel.text = state.speed.ToString(); intellectLabel.text = state.intellect.ToString(); healthLabel.text = state.health.ToString(); moodLabel.text = state.mood.ToString(); loadLabel.text = "0"; float progress; userPackage.GetPlayerLevel(out progress); expProgress.value = progress; levelLabel.text = string.Format("Lv.{0}", userPackage.GetPlayerLevel()); expLabel.text = string.Format("个人实力:{0}", userPackage.GetPersonContribution()); nameLabel.text = userPackage.GetUserInfo(userPackage.UserID).name; }
void RefreshResinfo() { resNumLabel.text = GlobalFunction.NumberFormat(itemPackage.GetResourceTotolNumber()); goldNumLabel.text = GlobalFunction.NumberFormat(itemPackage.GetGoldNumber()); //elecNumLabel.text = GlobalFunction.NumberFormat(itemPackage.GetElecNumber()); elecNumLabel.text = string.Format("{0}/h", GlobalFunction.NumberFormat(sanctuaryPackage.GetTotalProEfficiency())); }
void RefreshUserState(NDictionary data = null) { PlayerState playerState = userPackage.GetPlayerState(); if (playerState == null) { return; } coinLabel.text = GlobalFunction.NumberFormat(itemPackage.GetGoldNumber()); resLabel.text = GlobalFunction.NumberFormat(itemPackage.GetResourceTotolNumber()); elecLabel.text = string.Format("{0}/h", GlobalFunction.NumberFormat(sanctuaryPackage.GetTotalProEfficiency())); taskLabel.text = userPackage.GetUserInfo(userPackage.UserID).name; healthProgressBar.value = (float)playerState.blood / (float)(20 + 2 * playerState.health); hungerProgressBar.value = (float)playerState.hunger / (float)(20 + 2 * playerState.health); thirstProgressBar.value = (float)playerState.thirst / (float)(20 + 2 * playerState.health); RefreshPlayerLevel(); }
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(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(); }
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 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; } }