/// <summary> /// 更新信息 /// </summary> public void updateInfo() { buildSidList = GuildBuildSampleManager.Instance.getAllGuildBuild(); if (!buildSidList.Contains(buildSid)) { this.gameObject.SetActive(false); Debug.LogError("No GuildBuild By Sid =" + buildSid); return; } this.gameObject.SetActive(true); if (isShowTitle) { objTitle.SetActive(true); } else { objTitle.SetActive(false); } buildSample = GuildBuildSampleManager.Instance.getGuildBuildSampleBySid(buildSid); buildLevel = GuildManagerment.Instance.getBuildLevel(buildSid.ToString()); labelName.text = buildSample.buildName; setBuildInfo(); /**显示状态图标*/ if (GuildManagerment.Instance.isUpGuildBuildState(buildSample.sid, buildLevel)) { stateIcon.gameObject.SetActive(true); } else { stateIcon.gameObject.SetActive(false); } updateEffect(); }
public override void copy(object destObj) { base.copy(destObj); GuildBuildSample dest = destObj as GuildBuildSample; if (this.costs != null) { dest.costs = new List <int> (); for (int i = 0; i < this.costs.Count; i++) { dest.costs.Add(this.costs [i]); } } if (this.hallLevel != null) { dest.hallLevel = new List <int> (); for (int i = 0; i < this.hallLevel.Count; i++) { dest.hallLevel.Add(this.hallLevel [i]); } } if (this.goods != null) { dest.goods = new List <GuildGood> (); for (int i = 0; i < this.goods.Count; i++) { dest.goods.Add(this.goods [i].Clone() as GuildGood); } } }
/// <summary> /// 建筑是否可以升级 /// </summary> /// <returns><c>true</c>, if up guild build was ised, <c>false</c> otherwise.</returns> /// <param name="id">Identifier.</param> /// <param name="level">Level.</param> public bool isUpGuildBuild(int id, int level) { GuildBuildSample sample = GuildBuildSampleManager.Instance.getGuildBuildSampleBySid(id); if (level >= sample.levelMax) { UiManager.Instance.createMessageLintWindow(LanguageConfigManager.Instance.getLanguage("Guild_47")); return(false); } if (guild.livenessing >= sample.costs [level] && getGuildBuild(HALL).level >= sample.hallLevel [level] && level < sample.levelMax) { return(true); } else { if (guild.livenessing < sample.costs [level]) { UiManager.Instance.createMessageLintWindow(LanguageConfigManager.Instance.getLanguage("Guild_45")); } else if (getGuildBuild(HALL).level < sample.hallLevel [level]) { UiManager.Instance.createMessageLintWindow(LanguageConfigManager.Instance.getLanguage("Guild_46")); } return(false); } }
//解析模板数据 public override void parseSample(int sid) { GuildBuildSample sample = new GuildBuildSample(); string dataStr = getSampleDataBySid(sid); sample.parse(sid, dataStr); samples.Add(sid, sample); }
public override void updateItem(GameObject item, int index) { GuildBuildView button = item.GetComponent <GuildBuildView> (); GuildBuildSample sample = GuildBuildSampleManager.Instance.getGuildBuildSampleBySid(buildSidList[index]); button.initBuild(sample.sid, true, () => { (fatherWindow as GuildBuildWindow).updateInfo(sample); MaskWindow.UnlockUI(); }); }
//获得限制等级 public int getOpenLevel(Goods good) { GuildBuildSample buildSample = GuildBuildSampleManager.Instance.getGuildBuildSampleBySid(StringKit.toInt(SHOP)); List <GuildGood> list = buildSample.goods; for (int i = 0; i < list.Count; i++) { if (getBuildLevel(SHOP) < list [i].level && list [i].sid == good.sid) { return(list [i].level); } } return(0); }
//判断物品是否开放 public bool isOpenGood(Goods good) { GuildBuildSample buildSample = GuildBuildSampleManager.Instance.getGuildBuildSampleBySid(StringKit.toInt(SHOP)); List <GuildGood> list = buildSample.goods; for (int i = 0; i < list.Count; i++) { if (list [i].sid == good.sid && getBuildLevel(SHOP) >= list [i].level) { return(true); } } return(false); }
public bool isUpGuildBuildState(int id, int level) { GuildBuildSample sample = GuildBuildSampleManager.Instance.getGuildBuildSampleBySid(id); if (level >= sample.levelMax) { return(false); } if (guild.livenessing >= sample.costs [level] && getGuildBuild(HALL).level >= sample.hallLevel [level] && level < sample.levelMax) { return(true); } else { return(false); } }
/// <summary> /// 由建筑Sid获得对应等级建筑图标 /// </summary> public string getBuildIcon(int sid) { GuildBuildSample buildSample = GuildBuildSampleManager.Instance.getGuildBuildSampleBySid(sid); int buildLv = getBuildLevel(sid.ToString()); string spriteName = ""; switch (buildSample.sid) { case 1: spriteName = "hall_"; break; case 2: spriteName = "college_"; break; case 3: spriteName = "shop_"; break; case 4: spriteName = "altar_"; break; case 5: spriteName = "area_"; break; default: spriteName = ""; break; } if (buildLv > 0) { return(spriteName + buildSample.getIconByLv(buildLv)); } else { return(spriteName + 1); } }
//获得建筑的需求描述 public string getBuildNeedsDesc(int sid) { GuildBuildSample buildSample = GuildBuildSampleManager.Instance.getGuildBuildSampleBySid(sid); if (getBuildLevel(sid.ToString()) < buildSample.levelMax) { if (sid == StringKit.toInt(HALL)) { return(LanguageConfigManager.Instance.getLanguage("Guild_51", buildSample.costs [getBuildLevel(sid.ToString())].ToString())); } else { return(LanguageConfigManager.Instance.getLanguage("Guild_50", buildSample.costs [getBuildLevel(sid.ToString())].ToString(), buildSample.hallLevel [getBuildLevel(sid.ToString())].ToString())); } } else { return(LanguageConfigManager.Instance.getLanguage("Guild_47")); } }
public override void initButton(int i) { if (nodeList [i] == null) { nodeList [i] = NGUITools.AddChild(gameObject, (fatherWindow as GuildBuildWindow).buildItem); } nodeList [i].name = StringKit.intToFixString(i + 1); GuildBuildView button = nodeList [i].GetComponent <GuildBuildView> (); button.transform.localScale = new Vector3(0.7f, 0.7f, 0.7f); button.fatherWindow = fatherWindow; GuildBuildSample sample = GuildBuildSampleManager.Instance.getGuildBuildSampleBySid(buildSidList[i]); button.initBuild(sample.sid, true, () => { (fatherWindow as GuildBuildWindow).updateInfo(sample); MaskWindow.UnlockUI(); }); // if (i == 0) { // (fatherWindow as GuildBuildWindow).init (sample); // } }
//初始化信息 public void initInfo(GuildBuildSample build) { this.build = build; updateInfo(); }
/// <summary> /// 更新建筑升级信息 /// </summary> public void updateInfo(GuildBuildSample _buildSample) { if (_buildSample == null || (this.buildSample == _buildSample && buildLevel == instance.getBuildLevel(buildSample.sid.ToString()))) { return; } descItem.clear(); this.buildSample = _buildSample; Guild guild = instance.getGuild(); buildLevel = instance.getBuildLevel(buildSample.sid.ToString()); bool isMaxLv = buildLevel >= buildSample.levelMax; if (buildLevel > 0) { descItem.buttonBuild.textLabel.text = Language("Guild_34"); } else { descItem.buttonBuild.textLabel.text = Language("Guild_35"); } //标题部分 descItem.spriteIcon.spriteName = instance.getBuildIcon(buildSample.sid); descItem.labelNameTitle.text = Language("s0303") + buildSample.buildName + ":"; descItem.labelOldLv.text = "Lv." + buildLevel; descItem.labelNewLv.text = isMaxLv ? "" : ("Lv." + (buildLevel + 1)); descItem.objUpArrow.SetActive(!isMaxLv); descItem.labelLiveness.text = guild.livenessing.ToString(); descItem.labelCostLiveness.text = isMaxLv ? "" : buildSample.costs [buildLevel].ToString(); //提升部分 //是公会大厅就显示成员提升信息 if (buildSample.sid == 1) { descItem.labelNeedHellLv.transform.parent.gameObject.SetActive(false); descItem.objHell.SetActive(true); descItem.labelOldMember.text = guild.membershipMax.ToString(); descItem.labelNewMember.text = isMaxLv ? "" : (guild.membershipMax + 2).ToString(); descItem.objMemberUpArrow.SetActive(!isMaxLv); } else { descItem.labelNeedHellLv.transform.parent.gameObject.SetActive(true); descItem.labelNeedHellLv.text = isMaxLv ? Language("s0070") : ("Lv." + buildSample.hallLevel [buildLevel]); descItem.objHell.SetActive(false); } //升级描述 if (isMaxLv) { descItem.labelDesc.transform.parent.gameObject.SetActive(true); descItem.labelDesc.text = Language("s0070"); descItem.buttonBuild.disableButton(true); } else { descItem.buttonBuild.disableButton(false); if (buildSample.sid != 3) { descItem.labelDesc.transform.parent.gameObject.SetActive(true); descItem.labelDesc.text = buildSample.getDesc(buildLevel).Replace("~", "\n"); } else { descItem.labelDesc.transform.parent.gameObject.SetActive(false); if (buildSample.goods != null) { List <GuildGood> goods = buildSample.goods; List <Goods> tmpGoods = new List <Goods> (); for (int i = 0; i < goods.Count; i++) { if (goods[i].level == buildLevel + 1) { tmpGoods.Add(new Goods(goods[i].sid)); } } GoodsView goodsView; if (tmpGoods.Count > 0) { for (int i = 0; i < tmpGoods.Count; i++) { goodsView = NGUITools.AddChild(descItem.objBuildShow, goodsItem).GetComponent <GoodsView> (); goodsView.fatherWindow = this; goodsView.init(tmpGoods[i].getGoodsType(), tmpGoods[i].getGoodsSid(), 0); } descItem.objBuildShow.GetComponent <UIGrid> ().repositionNow = true; descItem.objBuildShow.GetComponent <UIPanel>().clipOffset = new Vector2(0, 10.0f); descItem.objBuildShow.gameObject.transform.localPosition = new Vector3(0, -100f, 0); } } } } descItem.labelName.text = Language("guildBuildUp_" + buildSample.sid); }
public void init(GuildBuildSample _buildSample) { buildSample = _buildSample; }