private void SetRandomView() { randomequip_img.sprite = ResourceMgr.Instance.LoadSprite(equip.ItemData.icon); randomlvfloor_cr.SetAlpha(equip.StrengthenLv); randomlv_txt.text = equip.StrengthenLv > 0 ? " +" + equip.StrengthenLv: ""; randomborder_img.sprite = ResourceMgr.Instance.LoadSprite(ColorMgr.Border[equip.ItemData.rare - 1]); equipname_txt.text = equip.ItemData.name; StringBuilder append = new StringBuilder(); for (int i = 0, length = equip.wishs.Length; i < length; ++i) { append.Append(AttrUtil.GetAttribute(equip.wishs[i].wish.attr)); append.Append(": +"); append.Append(AttrUtil.ShowText(equip.wishs[i].wish.attr, equip.wishs[i].wish.num, equip.wishs[i].wish.per)); append.Append("\n"); locks[i].isOn = equip.wishs[i].isLock; } oldattr_txt.text = append.ToString(); StringBuilder temp = new StringBuilder(); for (int i = 0, length = equip.tempWishs.Length; i < length; ++i) { temp.Append(AttrUtil.GetAttribute(equip.tempWishs[i].attr)); temp.Append(": +"); temp.Append(AttrUtil.ShowText(equip.tempWishs[i].attr, equip.tempWishs[i].num, equip.tempWishs[i].per)); temp.Append("\n"); } newattr_txt.text = temp.ToString(); randomspend_txt.text = JsonMgr.GetSingleton().GetGlobalIntArrayByID(expend).value.ToString(); }
public void SetView(HeroData heroData, Officer o) { officerID = o.ID; hd = heroData; text = o.Post; take_cr.SetAlpha(TestColor(false) == heroData.HeroId ? 1 : 0); down_obj.SetActive(false); StringBuilder sb = new StringBuilder(); for (int i = 0; i < o.attrerty.Length; i++) { Pro p = o.attrerty[i]; sb.Append(AttrUtil.GetAttribute(p.attr)); sb.Append(string.Format("<color=#00FF00> +{0}</color>", p.num)); if ((i + 1) % 2 != 0) { sb.Append(" "); } else { sb.Append("\n"); } } leftpro_txt.text = sb.ToString(); }
public Dictionary <Attr, float> HeroAttr() { if (heroAttr == null) { float Def = AttrUtil.CalDef(JsonData.power, Level, StarGrow.stardef[Star - 1]); float MdefRate = AttrUtil.CalMdef(JsonData.strategy, Level, StarGrow.starmdef[Star - 1]); heroAttr = new Dictionary <Attr, float> { { Attr.LeadPower, JsonData.leadpower }, //统率 { Attr.Power, JsonData.power }, //武力 { Attr.Strategy, JsonData.strategy }, //智力 { Attr.VigourSuck, JsonData.vigoursuck }, // 士气吸取(激励) { Attr.DefBreak, JsonData.defbreak }, //物理穿透 { Attr.MdefBreak, JsonData.mdefbreak }, //策略穿透 { Attr.VigourRec, JsonData.vigourrec }, //士气恢复 { Attr.CritInc, JsonData.critinc + AttrUtil.BASE_CRITINC }, //暴击伤害 { Attr.HpRec, JsonData.hprec }, //生命恢复 { Attr.HealRate, JsonData.healrate }, //治疗承受 { Attr.HpSuck, JsonData.hpsuck }, //吸血 { Attr.Asp, JsonData.asp }, //攻击速度 { Attr.HarmRate, JsonData.harmrate }, //伤害承受 { Attr.DodgeRate, JsonData.dodge }, { Attr.HitRate, JsonData.hit }, { Attr.BlockRate, JsonData.block }, { Attr.RoutRate, JsonData.rout }, { Attr.CritRate, JsonData.crit }, { Attr.FirmRate, JsonData.firm }, }; } return(heroAttr); }
public void Open(EquipData equip) { this.data = equip; int rare = equip.ItemData.rare; border_img.sprite = ResourceMgr.Instance.LoadSprite(ColorMgr.Border[rare - 1]); string color = ColorMgr.Colors[rare - 1]; name_txt.text = string.Format("<color=#{0}>{1}</color>", color, equip.JsonData.Name); state_txt.text = ""; levle_txt.text = equip.StrengthenLv > 0 ? "+" + equip.StrengthenLv: ""; lvfloor_cr.SetAlpha(equip.StrengthenLv); des_txt.text = equip.ItemData.usedes; equip_img.sprite = ResourceMgr.Instance.LoadSprite(equip.ItemData.icon); EventListener.Get(strengthen_btn.gameObject).OnClick = e => { UIFace.GetSingleton().Close(UIID.StrengthenTip); UIFace.GetSingleton().Open(UIID.Strengthen, equip); }; StringBuilder sb = new StringBuilder(); Pro[] p = equip.Attribute; for (int i = 0, length = p.Length; i < length; ++i) { sb.Append(AttrUtil.GetAttribute(p[i].attr)); sb.Append(": +"); sb.Append(AttrUtil.ShowText(p[i].attr, p[i].num, p[i].per)); sb.Append("\n"); } baseattr_txt.text = attr_txt.text = sb.ToString(); //appendattr_obj.SetActive(equip.wishs.Length > 0); sb.Length = 0; for (int i = 0, length = equip.wishs.Length; i < length; ++i) { sb.Append(AttrUtil.GetAttribute(equip.wishs[i].wish.attr)); sb.Append(": +"); sb.Append(AttrUtil.ShowText(equip.wishs[i].wish.attr, equip.wishs[i].wish.num, equip.wishs[i].wish.per)); sb.Append("\n"); } appendattr_txt.text = equip.wishs.Length > 0 ? sb.ToString(): "<color=#FFFF00>提升装备品质\n开放更多属性</color>"; p = equip.Innate; constattr_obj.SetActive(p.Length != 0); sb.Length = 0; for (int i = 0, length = p.Length; i < length; ++i) { sb.Append(AttrUtil.GetAttribute(p[i].attr)); sb.Append(": +"); sb.Append(AttrUtil.ShowText(p[i].attr, p[i].num, p[i].per)); sb.Append("\n"); } constattr_txt.text = sb.ToString(); sb = null; }
private void openItemTip(int itemId, Vector2 pos, int align, Vector2 offset) { JsonData.ItemConfig itemJson = JsonMgr.GetSingleton().GetItemConfigByID(itemId); if (itemJson == null) { EDebug.LogErrorFormat("openItemTip, invalid item id {0}", itemId); return; } itemTipsView.SetInfo(itemId, 0); string itemColor = ColorMgr.Colors[itemJson.rare - 1]; this.ItemName_txt.text = itemJson.name.AddColorLabel(itemColor); this.ItemNum_txt.text = string.Format(JsonMgr.GetSingleton().GetGlobalStringArrayByID(2005).desc, ItemMgr.Instance.GetItemNum(itemId).ToString()); this.ItemPrice_txt.text = itemJson.price.ToString(); if (itemJson.type == FuncType.EQUIP) { _sb.Length = 0; JsonData.Equip equipJson = JsonMgr.GetSingleton().GetEquipByID(itemId); if (equipJson != null) { for (int idx = 0; idx < equipJson.Attribute.Length; ++idx) { Pro p = equipJson.Attribute[idx]; _sb.AppendLine(string.Format(" {0} +{1}", AttrUtil.GetAttribute(p.attr), AttrUtil.ShowText(p.attr, p.num, p.per))); } for (int idx = 0; idx < equipJson.Innate.Length; ++idx) { Pro p = equipJson.Innate[idx]; _sb.AppendLine(string.Format(" {0} +{1}", AttrUtil.GetAttribute(p.attr), AttrUtil.ShowText(p.attr, p.num, p.per))); } _sb.Remove(_sb.Length - 1, 1); this.ItemIntroduce_txt.alignment = TextAnchor.MiddleLeft; this.ItemIntroduce_txt.text = _sb.ToString(); } else { EDebug.LogErrorFormat("openItemTip invalid equip id {0}", itemId); } } else { this.ItemIntroduce_txt.alignment = TextAnchor.UpperLeft; this.ItemIntroduce_txt.text = itemJson.propertydes; } this.itemtips_rect.anchoredPosition = calAlignment(pos, this.itemtips_rect.sizeDelta, align, offset); this.itemtips_rect.gameObject.SetActive(true); }
private void SetAttrView() { int upexp = composeItem.LevelUpExp() - composeItem.Exp; plusLevel = composeItem.Level; float temp = playExp; while (temp >= upexp) { plusLevel++; temp -= upexp; upexp = composeItem.LevelUpExp(plusLevel); } Pro[] proa = composeItem.Attribute; StringBuilder sb = new StringBuilder(); StringBuilder sbnext = new StringBuilder(); sb.Append(composeItem.Level + "级"); sbnext.Append(plusLevel + "级"); for (int i = 0; i < proa.Length; ++i) { sb.Append("\n"); sbnext.Append("\n"); sb.Append(AttrUtil.GetAttribute(proa[i].attr)); sbnext.Append(AttrUtil.GetAttribute(proa[i].attr)); sb.Append(" +"); sbnext.Append(" +"); if (proa[i].num != 0) { sb.Append(AttrUtil.ShowText(proa[i].attr, proa[i].num)); sbnext.Append(AttrUtil.ShowText(proa[i].attr, proa[i].num)); } else if (proa[i].per != 0) { sb.Append(AttrUtil.ShowText(proa[i].attr, 0, proa[i].per)); sbnext.Append(AttrUtil.ShowText(proa[i].attr, 0, proa[i].per)); } sb.Append("\n"); sbnext.Append("\n"); } attr_txt.text = sb.ToString(); nextattr_txt.text = sbnext.ToString(); SetAttrActive(playExp != 0); }
private void SetStrengthenView() { StringBuilder sb = new StringBuilder(); StringBuilder nextSB = new StringBuilder(); Pro[] p = equip.Attribute; for (int i = 0, length = p.Length; i < length; ++i) { sb.Append(AttrUtil.GetAttribute(p[i].attr)); nextSB.Append(AttrUtil.GetAttribute(p[i].attr)); sb.Append(": +"); nextSB.Append(": +"); sb.Append(AttrUtil.ShowText(p[i].attr, equip.JsonData.Attribute[i].num + p[i].num, equip.JsonData.Attribute[i].per + p[i].per)); nextSB.Append(AttrUtil.ShowText(p[i].attr, equip.JsonData.Attribute[i].num * 2 + p[i].num, equip.JsonData.Attribute[i].per * 2 + p[i].per)); sb.Append("\n"); nextSB.Append("\n"); } attr_txt.supportRichText = true; string title = equip.ItemData.name + (equip.StrengthenLv == 0 ? "" : " +" + equip.StrengthenLv) + "\n"; title = title.AddColorLabel(ColorMgr.Colors[equip.ItemData.rare - 1]); attr_txt.text = title + sb; title = equip.ItemData.name + " +" + (equip.StrengthenLv + 1) + "\n"; title = title.AddColorLabel(ColorMgr.Colors[equip.ItemData.rare - 1]); thenattr_txt.text = title + nextSB; sb = null; nextSB = null; equip_img.sprite = thenequip_img.sprite = ResourceMgr.Instance.LoadSprite(equip.ItemData.icon); thenborder_img.sprite = border_img.sprite = ResourceMgr.Instance.LoadSprite(ColorMgr.Border[equip.ItemData.rare - 1]); lvfloor_cr.SetAlpha(equip.StrengthenLv); lv_txt.text = equip.StrengthenLv == 0 ? "" : "+" + equip.StrengthenLv; thenlvfloor_cr.SetAlpha(1); thenlv_txt.text = "+" + (equip.StrengthenLv + 1); EventListener.Get(strengthen_btn.gameObject).OnClick = e => { if (EquipMgr.GetSingleton().UpEquip(equip)) { StrengthenOK_img.GetComponent <UISprite>().Play(); } SetStrengthenView(); }; EventListener.Get(strengthenonekey_btn.gameObject).OnClick = e => { }; spend_txt.text = JsonMgr.GetSingleton().GetStrengthenSpendByID(equip.StrengthenLv).spend.ToString(); }
public void AttrTxet(ScrollRect rect, Attr attr, float num) { EventListener.Get(gameObject).BegineDragEvent = e => { rect.OnBeginDrag(e); }; EventListener.Get(gameObject).DragEvent = e => { rect.OnDrag(e); }; EventListener.Get(gameObject).EndDragEvent = e => { rect.OnEndDrag(e); }; texts[0].text = string.Format("<color=#FFFF00>{0}</color>", AttrUtil.GetAttribute(attr)); texts[1].text = string.Format("<color=#4AE000>{0}</color>", AttrUtil.ShowText(attr, num)); }
public void AddBuff(FightUnit caster, int tplId, int buffLevel) { JObject buffJson = JsonMgr.GetSingleton().GetBuff(tplId); if (buffJson == null) { EDebug.LogErrorFormat("BuffMgr.AddBuff, failed to get buff json, id:{0}", tplId); return; } int type = buffJson["type"].ToObject <int>(); int layers = buffJson["layers"].ToObject <int>(); int resid = buffJson["resid"].ToObject <int>(); bool onfoot = buffJson["onfoot"].ToObject <int>() != 0; int calType = buffJson["caltype"].ToObject <int>(); JArray buffParam = buffJson["buffparam"].ToObject <JArray>(); int buffPriority = buffJson["priority"].ToObject <int>(); Vector3 effectParam = AttrUtil.CalExpression(calType, buffParam, caster, this._unit, buffLevel); Buff buff = new Buff(this, caster, buffLevel, ++_uid, tplId, effectParam); if (checkPriority(buffPriority)) { int curLayer = getCurLayer(tplId); if (curLayer >= layers) { removeFirstBuff(tplId); } if (0 == getCurLayer(tplId) && resid > 0) { //通知显示层显示特效 ZEventSystem.Dispatch(EventConst.OnFightUnitAddBuff, this._unit, resid, onfoot, true); } if (type == (int)BuffType.Time) { TakeEffect(buff); } _allBuff.Add(buff); } }
public void Open(TotemData data, SHOWBUTTON btnCtrl) { take_btn.gameObject.SetActive(btnCtrl == SHOWBUTTON.Etake); takeoff_btn.gameObject.SetActive(btnCtrl == SHOWBUTTON.EtakeOff); EventListener.Get(take_btn.gameObject).OnClick = e => { ZEventSystem.Dispatch(EventConst.TAKETOTEM, data); UIFace.GetSingleton().Close(UIID.DivinationTip); }; EventListener.Get(compose_btn.gameObject).OnClick = e => { UIFace.GetSingleton().Open(UIID.CompostDivination, data); ZEventSystem.Dispatch(EventConst.ONOPENCOMPOSE); UIFace.GetSingleton().Close(UIID.DivinationTip); }; EventListener.Get(takeoff_btn.gameObject).OnClick = e => { TotemMgr.GetSingleton().TakeOffTotem(data); ZEventSystem.Dispatch(EventConst.REFRESHRIGHT, false); UIFace.GetSingleton().Close(UIID.DivinationTip); }; item_img.sprite = ResourceMgr.Instance.LoadSprite(data.ItemData.icon); int rare = data.ItemData.rare; string color = ColorMgr.Colors[rare - 1]; name_txt.text = string.Format("<color=#{0}>{1}</color>", color, data.TotemConfig.Name); level_txt.text = string.Format("<color=#{0}>Lv.{1}</color>", color, data.Level); slider_img.fillAmount = data.Exp / (float)data.LevelUpExp(); prog_txt.text = data.Exp + "/" + data.LevelUpExp(); Pro[] p = data.Attribute; StringBuilder sb = new StringBuilder(); for (int i = 0; i < p.Length; ++i) { sb.Append(AttrUtil.GetAttribute(p[i].attr)); sb.Append(" +"); sb.Append(AttrUtil.ShowText(p[i].attr, p[i].num, p[i].per)); sb.Append("\n"); } attr_txt.text = sb.ToString(); }
private void _analyzeEffect(int effectId, ref HashSet <int> sound, ref HashSet <int> gos) { JObject jEffect = JsonMgr.GetSingleton().GetSkillEffect(effectId); if (jEffect == null) { EDebug.LogErrorFormat("PreloadMgr._analyzeEffect failed, no such effect:{0}", effectId); return; } int hitEffect = jEffect["hiteffect"].ToObject <int>(); if (hitEffect != 0) { gos.Add(hitEffect); } int effect = jEffect["effect"].ToObject <int>(); int paramType = jEffect["paramtype"].ToObject <int>(); if (1 == paramType) { return; } Vector3 EffectParams = AttrUtil.CalExpression(paramType, jEffect["effectparam"].ToObject <JArray>()); switch (effect) { case (int)EffectType.BULLET: _analyzeBullet((int)EffectParams.y, ref sound, ref gos); break; case (int)EffectType.BUFF: _analyzeBuffRes((int)EffectParams.y, ref sound, ref gos); break; case (int)EffectType.Summon: _analyzeFighterRes((int)EffectParams.x, true, ref sound, ref gos); break; } }
private void _analyzeBuffRes(int buffId, ref HashSet <int> sound, ref HashSet <int> gos) { JObject jBuff = JsonMgr.GetSingleton().GetBuff(buffId); if (jBuff == null) { EDebug.LogErrorFormat("PreloadMgr._analyzeBuff failed, no such buff:{0}", buffId); return; } int resId = jBuff["resid"].ToObject <int>(); if (resId != 0) { gos.Add(resId); } int effect = jBuff["effect"].ToObject <int>(); int calType = jBuff["caltype"].ToObject <int>(); if (1 == calType) { return; } Vector3 buffParams = AttrUtil.CalExpression(calType, jBuff["buffparam"].ToObject <JArray>()); switch (effect) { case (int)BuffEffect.UsePromotSkill: case (int)BuffEffect.UseSkill: _analyzeSkillRes((int)buffParams.y, ref sound, ref gos); break; case (int)BuffEffect.AddBuff: _analyzeBuffRes((int)buffParams.y, ref sound, ref gos); break; } }
private Dictionary <Attr, float> ComputerAttr() { plusDic.Clear(); mulDic.Clear(); //只为调整显示顺序 Dictionary <Attr, float> ret = new Dictionary <Attr, float> { { Attr.Power, 0 }, { Attr.Strategy, 0 }, { Attr.LeadPower, 0 }, { Attr.MaxHp, 0 }, { Attr.Asp, 0 }, { Attr.Atk, 0 }, { Attr.DefBreak, 0 }, { Attr.Matk, 0 }, { Attr.MdefBreak, 0 }, { Attr.Def, 0 }, { Attr.DefRate, 0 }, { Attr.MDef, 0 }, { Attr.MdefRate, 0 }, { Attr.DodgeRate, 0 }, { Attr.HitRate, 0 }, { Attr.BlockRate, 0 }, { Attr.RoutRate, 0 }, { Attr.CritRate, 0 }, { Attr.CritInc, 0 }, { Attr.FirmRate, 0 }, { Attr.HealRate, 0 }, { Attr.HpRec, 0 }, { Attr.VigourRec, 0 }, { Attr.HpSuck, 0 }, { Attr.VigourSuck, 0 } }; List <Pro> ep = EquipAttr(); Dictionary <Attr, float> oa = OfficerAttr(); Dictionary <Attr, float> ha = HeroAttr(); Dictionary <Attr, float> ra = RareAttr(false); int power = 0; int strategy = 0; int leadPower = 0; //计算武力 if (ha.ContainsKey(Attr.Power)) { power += (int)ha[Attr.Power]; } if (ra.ContainsKey(Attr.Power)) { power += (int)ra[Attr.Power]; } if (oa.ContainsKey(Attr.Power)) { power += (int)oa[Attr.Power]; } //计算策略 if (ha.ContainsKey(Attr.Strategy)) { strategy += (int)ha[Attr.Strategy]; } if (ra.ContainsKey(Attr.Strategy)) { strategy += (int)ra[Attr.Strategy]; } if (oa.ContainsKey(Attr.Strategy)) { strategy += (int)oa[Attr.Strategy]; } //计算统率 if (ha.ContainsKey(Attr.LeadPower)) { leadPower += (int)ha[Attr.LeadPower]; } if (ra.ContainsKey(Attr.Strategy)) { leadPower += (int)ra[Attr.LeadPower]; } if (oa.ContainsKey(Attr.LeadPower)) { leadPower += (int)oa[Attr.LeadPower]; } for (int i = 0; i < ep.Count; ++i) { if (ep[i].attr == Attr.Power) { power += (int)ep[i].num; power = Mathf.RoundToInt(power * (1f + ep[i].per)); } else if (ep[i].attr == Attr.Strategy) { strategy += (int)ep[i].num; strategy = Mathf.RoundToInt(strategy * (1f + ep[i].per)); } else if (ep[i].attr == Attr.LeadPower) { leadPower += (int)ep[i].num; leadPower = Mathf.RoundToInt(leadPower * (1f + ep[i].per)); } else { if (plusDic.ContainsKey(ep[i].attr)) { plusDic[ep[i].attr] += ep[i].num; } else { plusDic.Add(ep[i].attr, ep[i].num); } if (mulDic.ContainsKey(ep[i].attr)) { mulDic[ep[i].attr] += ep[i].per; } else { mulDic.Add(ep[i].attr, ep[i].per); } } } List <Pro> tp = TotemAttr(); for (int i = 0; i < tp.Count; ++i) { if (plusDic.ContainsKey(tp[i].attr)) { plusDic[tp[i].attr] += tp[i].num; } else { plusDic.Add(tp[i].attr, tp[i].num); } if (mulDic.ContainsKey(tp[i].attr)) { mulDic[tp[i].attr] += tp[i].per; } else { mulDic.Add(tp[i].attr, tp[i].per); } } float Def = AttrUtil.CalDef((int)power, Level, StarGrow.stardef[Star - 1]); float MdefRate = AttrUtil.CalMdef((int)strategy, Level, StarGrow.starmdef[Star - 1]); int maxHp = AttrUtil.CalMaxHp((int)leadPower, Level, StarGrow.starhp[Star - 1]); //最大生命值 float atk = AttrUtil.CalAtk((int)power, Level, StarGrow.staratk[Star - 1]); //物理攻击力 float matk = AttrUtil.CalMatk((int)strategy, Level, StarGrow.starmatk[Star - 1]); //策略攻击力 float mdefRatr = AttrUtil.CalMdefRate(MdefRate, Level); float defRate = AttrUtil.CalDefRate(Def, Level); //物理抗性 float dodgeRate = AttrUtil.CalDodgeRate((int)leadPower, Level), //闪避率 blockRate = AttrUtil.CalBlockRate((int)leadPower, Level), //格挡率 firmRate = AttrUtil.CalFirmRate((int)leadPower, Level), //韧性率 hitRate = AttrUtil.CalHitRate((int)leadPower, Level), //命中率 routRate = AttrUtil.CalRoutRate((int)leadPower, Level), //破击率 critRate = AttrUtil.CalCritRate((int)leadPower, Level); //暴击率 foreach (var item in ha) { if (ret.ContainsKey(item.Key)) { ret[item.Key] += item.Value; } else { ret.Add(item.Key, item.Value); } } foreach (var item in ra) { if (ret.ContainsKey(item.Key)) { ret[item.Key] += item.Value; } else { ret.Add(item.Key, item.Value); } } foreach (var item in oa) { if (ret.ContainsKey(item.Key)) { ret[item.Key] += item.Value; } else { ret.Add(item.Key, item.Value); } } foreach (var item in plusDic) { if (ret.ContainsKey(item.Key)) { ret[item.Key] += item.Value; } else { ret.Add(item.Key, item.Value); } } foreach (var item in mulDic) { if (ret.ContainsKey(item.Key)) { ret[item.Key] = ret[item.Key] * (1 + item.Value); } } //增加最大生命值 if (ret.ContainsKey(Attr.MaxHp)) { ret[Attr.MaxHp] += maxHp; } //物理攻击计算 if (ret.ContainsKey(Attr.Atk)) { ret[Attr.Atk] += atk; } //策略攻击 if (ret.ContainsKey(Attr.Matk)) { ret[Attr.Matk] += matk; } //物理抗性 if (ret.ContainsKey(Attr.DefRate)) { ret[Attr.DefRate] += defRate; } //策略抗性 if (ret.ContainsKey(Attr.MdefRate)) { ret[Attr.MdefRate] += mdefRatr; } //闪避率 if (ret.ContainsKey(Attr.DodgeRate)) { ret[Attr.DodgeRate] += dodgeRate; } //格挡率 if (ret.ContainsKey(Attr.BlockRate)) { ret[Attr.BlockRate] += blockRate; } //韧性率 if (ret.ContainsKey(Attr.FirmRate)) { ret[Attr.FirmRate] += firmRate; } //命中率 if (ret.ContainsKey(Attr.HitRate)) { ret[Attr.HitRate] += hitRate; } //破击率 if (ret.ContainsKey(Attr.RoutRate)) { ret[Attr.RoutRate] += routRate; } //暴击率 if (ret.ContainsKey(Attr.CritRate)) { ret[Attr.CritRate] += critRate; } if (ret.ContainsKey(Attr.AspRate)) { ret[Attr.Asp] *= (1 + ret[Attr.AspRate]); } return(ret); }
private void ShowOfficer() { showGo = Officer_trf; showGo.SetParent(Right_trf); LOfficer_obj.SetActive(true); Left_obj.SetActive(false); HeroRare ou = JsonMgr.GetSingleton().GetHeroRareByID(heroData.Rare); HeroRare up = JsonMgr.GetSingleton().GetHeroRareByID(Mathf.Min(heroData.Rare + 1)); if (ou == null) { return; } if (up == null) { return; } currentleft_img.sprite = currentright_img.sprite = ResourceMgr.Instance.LoadSprite(ou.Officer); upleft_img.sprite = upright_img.sprite = ResourceMgr.Instance.LoadSprite(up.Officer); current_txt.text = ou.Name.AddColorLabel(ou.Color); up_txt.text = up.Name.AddColorLabel(up.Color); HeroHeadView hhvL = LeftHead_trf.GetComponent <HeroHeadView>(); HeroHeadView hhvR = RightHea_trf.GetComponent <HeroHeadView>(); hhvL.Init(); hhvR.Init(); hhvL.SetHeroInfo(heroData.JsonData.headid, heroData.Rare, heroData.Star, heroData.Level, true); hhvR.SetHeroInfo(heroData.JsonData.headid, heroData.Rare + 1, heroData.Star, heroData.Level, true); needhonor_txt.color = Role.Instance.Honor < up.NeedNum ? Color.red : Color.white; needhonor_txt.text = up.NeedNum.ToString("N0"); EventListener.Get(up_btn.gameObject).OnClick = e => { if (heroData.Rare >= JsonMgr.GetSingleton().GetGlobalIntArrayByID(1023).value) { CanvasView.Instance.AddNotice("高处不胜寒呐~~"); return; } if (Role.Instance.Honor < up.NeedNum) { CanvasView.Instance.AddNotice("荣誉不足!!"); return; } HeroMgr.GetSingleton().UnfixOfficer(heroData); heroData.Rare++; ShowOfficer(); ShowSide(false); }; Dictionary <Attr, float> ret = heroData.RareAttr(false); StringBuilder sb = new StringBuilder(); foreach (var item in ret) { if (item.Value != 0) { sb.Append(AttrUtil.GetAttribute(item.Key)); sb.Append(" "); sb.Append(AttrUtil.ShowText(item.Key, item.Value)); sb.Append("\n"); } } leftpro_txt.text = sb.ToString(); Dictionary <Attr, float> next = heroData.RareAttr(true); sb.Length = 0; foreach (var item in next) { if (item.Value != 0) { sb.Append(AttrUtil.GetAttribute(item.Key)); sb.Append(" "); sb.Append(AttrUtil.ShowText(item.Key, item.Value)); sb.Append(" "); float befor = 0; if (ret.ContainsKey(item.Key)) { befor = ret[item.Key]; } sb.Append(string.Format(@"<color=#00FF00> (+{0})</color>", AttrUtil.ShowText(item.Key, item.Value - befor))); sb.Append("\n"); } } rightpro_txt.text = sb.ToString(); int[] officers = HeroMgr.GetSingleton().GetUnLockOfficer(heroData.Rare); int childCount = OfficerList_obj.transform.childCount; List <Officer> os = SortPost(officers); for (int i = 0; i < os.Count; ++i) { Officer o = os[i]; if (o == null) { continue; } GameObject itemgo; if (i < childCount) { itemgo = OfficerList_obj.transform.GetChild(i).gameObject; } else { itemgo = Instantiate(officerGo, OfficerList_obj.transform, false); } OfficerItem oi = itemgo.GetComponent <OfficerItem>(); oi.SetView(heroData, o); EventListener.Get(oi.take_btn.gameObject).OnClick = e => { int takeID = HeroMgr.GetSingleton().IsTake(o.ID); if (takeID == heroData.HeroId) { return; } if (takeID != 0) { string name = HeroMgr.GetSingleton().GetHeroData(takeID).JsonData.name; TipCtrl ctrl = (TipCtrl)UIFace.GetSingleton().Open(UIID.Tip, 1, name); ctrl.SetHandler(delegate() { UIFace.GetSingleton().Close(UIID.Tip); }, delegate() { UIFace.GetSingleton().Close(UIID.Tip); HeroMgr.GetSingleton().TakeOfficer(heroData, o.ID); ShowOfficer(); }); } else { HeroMgr.GetSingleton().TakeOfficer(heroData, o.ID); ShowOfficer(); } }; EventListener.Get(itemgo).OnClick = e => { oi.OnClickItem(); float minu = (oi.highlightY - oi.normalY); float height = oi.down ? minu : -minu; officerrt.sizeDelta = new Vector2(officerrt.sizeDelta.x, officerrt.sizeDelta.y + height); }; if (oi.down) { oi.OnClickItem(); } EventListener.Get(itemgo).BegineDragEvent = e => { OfficerSV_sr.OnBeginDrag(e); }; EventListener.Get(itemgo).DragEvent = e => { OfficerSV_sr.OnDrag(e); }; EventListener.Get(itemgo).EndDragEvent = e => { OfficerSV_sr.OnEndDrag(e); }; } float maxHeight = (officers.Length + 0.5f) * (10.6f + 101); officerrt.sizeDelta = new Vector2(officerrt.sizeDelta.x, maxHeight); }
private void SetAdvancedView() { int[] targets = equip.JsonData.Advanced; int target = PlayerPrefs.GetInt("advancedtarget"); //处理紫升橙 if (targets.Length > 1) { bool has = false; for (int i = 0; i < targets.Length; ++i) { if (targets[i] == target) { has = true; } } if (target != 0 && has) { advancedequip_img.raycastTarget = true; target_img.raycastTarget = false; EventListener.Get(advancedequip_img.gameObject).OnClick = e => { attr_obj.SetActive(false); null_obj.SetActive(true); for (int i = 0, length = parent_trf.childCount; i < length; ++i) { DestroyImmediate(parent_trf.GetChild(0).gameObject); } target = 0; PlayerPrefs.SetInt("advancedtarget", 0); UIFace.GetSingleton().Open(UIID.EuqipTipCtrl, targets); }; } else { advancedequip_img.gameObject.SetActive(false); advancedborder_img.gameObject.SetActive(false); target_img.gameObject.SetActive(true); attr_obj.SetActive(false); null_obj.SetActive(true); target_img.raycastTarget = true; advancedequip_img.raycastTarget = false; EventListener.Get(target_img.gameObject).OnClick = e => { PlayerPrefs.SetInt("advancedtarget", 0); UIFace.GetSingleton().Open(UIID.EuqipTipCtrl, targets); }; return; } } else if (targets.Length == 0) { advancedequip_img.gameObject.SetActive(false); advancedborder_img.gameObject.SetActive(false); target_img.gameObject.SetActive(true); attr_obj.SetActive(false); null_obj.SetActive(true); target_img.raycastTarget = true; advancedequip_img.raycastTarget = false; EventListener.Get(target_img.gameObject).OnClick = e => { CanvasView.Instance.AddNotice("当前装备已进阶至最大等级"); }; return; } else { advancedequip_img.raycastTarget = false; target = targets[0]; } advancedequip_img.gameObject.SetActive(true); advancedborder_img.gameObject.SetActive(true); target_img.gameObject.SetActive(false); attr_obj.SetActive(true); null_obj.SetActive(false); AdvancedSpend aspend = JsonMgr.GetSingleton().GetAdvancedSpendByID(target); SetSpendView(aspend); EventListener.Get(advanced_btn.gameObject).OnClick = e => { if (equip.JsonData.Advanced.Length == 0) { CanvasView.Instance.AddNotice("当前装备已进阶至最大等级"); return; } else if (equip.StrengthenLv < equip.JsonData.AdvancedCondition) { CanvasView.Instance.AddNotice(string.Format("进阶失败!需要强化等级达到{0},才能继续进阶。", equip.JsonData.AdvancedCondition)); return; } else if (target == 0) { return; } for (int i = 0, length = parent_trf.childCount; i < length; ++i) { DestroyImmediate(parent_trf.GetChild(0).gameObject); } equip.EquipId = target; SetAdvancedView(); HeroData hero = HeroMgr.GetSingleton().GetHeroData(equip.HeroId); if (hero == null) { return; } hero.ClearEquipAttr(); ZEventSystem.Dispatch(EventConst.REFRESHRIGHT); }; StringBuilder sb = new StringBuilder(); Pro[] p = equip.Attribute; for (int i = 0, length = p.Length; i < length; ++i) { sb.Append(AttrUtil.GetAttribute(p[i].attr)); sb.Append(": +"); sb.Append(AttrUtil.ShowText(p[i].attr, equip.JsonData.Attribute[i].num + p[i].num, equip.JsonData.Attribute[i].per + p[i].per)); sb.Append("\n"); } name_txt.supportRichText = true; string color = ColorMgr.Colors[equip.ItemData.rare - 1]; name_txt.text = string.Format("<color=#{0}>{1}{2}</color>", color, equip.JsonData.Name, equip.StrengthenLv > 0 ? " +" + equip.StrengthenLv : ""); baseattr_txt.text = string.Format("<color=#{0}>{1}</color>", color, sb); Equip q = JsonMgr.GetSingleton().GetEquipByID(target); StringBuilder append = new StringBuilder(); p = q.Attribute; for (int i = 0, length = p.Length; i < length; ++i) { append.Append(AttrUtil.GetAttribute(p[i].attr)); append.Append(": +"); append.Append(AttrUtil.ShowText(p[i].attr, p[i].num + p[i].num * equip.StrengthenLv, p[i].per + p[i].per * equip.StrengthenLv)); append.Append("\n"); } ItemConfig ic = JsonMgr.GetSingleton().GetItemConfigByID(target); color = ColorMgr.Colors[ic.rare - 1]; advanced_txt.supportRichText = true; advanced_txt.text = string.Format("<color=#{0}>{1}{2}</color>", color, q.Name, equip.StrengthenLv > 0 ? " +" + equip.StrengthenLv : ""); advancedattr_txt.text = string.Format("<color=#{0}>{1}</color>", color, append); sb = null; append = null; }
public void TakeEffect(Buff buff, bool inverse = false) { JObject cbuff = JsonMgr.GetSingleton().GetBuff(buff.BuffId); int buffeffect = cbuff["effect"].ToObject <int>(); int calType = cbuff["caltype"].ToObject <int>(); string buffparam = cbuff["buffparam"].ToString(); float effectParamKey = buff.EffectParam.x; float effectParamValue = (inverse ? -1 : 1) * buff.EffectParam.y; switch (buffeffect) { case (int)BuffEffect.AddHPMax: this._unit.MaxHP += (int)(effectParamValue * this._unit.BaseMaxHp); break; case (int)BuffEffect.AddVigour: { this._unit.AddVigour((int)effectParamValue); if (effectParamValue > 0) { ZEventSystem.Dispatch(EventConst.OnFightUnitPop, this._unit, new Vector2Int((int)EffectState.HealVigour, (int)effectParamValue)); } } break; case (int)BuffEffect.AddAtk: this.Atk += effectParamValue; break; case (int)BuffEffect.AddMatk: this.Matk += effectParamValue; break; case (int)BuffEffect.AddDefRate: this.DefRate += effectParamValue; break; case (int)BuffEffect.AddMdefRate: this.MdefRate += effectParamValue; break; case (int)BuffEffect.AddDefBreak: this.DefBreak += effectParamValue; break; case (int)BuffEffect.AddMdefBreak: this.MdefBreak += effectParamValue; break; case (int)BuffEffect.AddDeSowRate: this.DeSowRate += effectParamValue; break; case (int)BuffEffect.AddDeFaintRate: this.DeFaintRate += effectParamValue; break; case (int)BuffEffect.AddDeSpoofRate: this.DeSpoofRate += effectParamValue; break; case (int)BuffEffect.AddHealRate: this.HealRate += effectParamValue; break; case (int)BuffEffect.AddHarmRate: this.HarmRate += effectParamValue; break; case (int)BuffEffect.AddAsp: this.AspRate += effectParamValue; break; case (int)BuffEffect.AddDodgeRate: this.DodgeRate += effectParamValue; break; case (int)BuffEffect.AddHitRate: this.HitRate += effectParamValue; break; case (int)BuffEffect.AddBlockRate: this.BlockRate += effectParamValue; break; case (int)BuffEffect.AddRoutRate: this.RoutRate += effectParamValue; break; case (int)BuffEffect.AddCritRate: this.CritRate += effectParamValue; break; case (int)BuffEffect.AddFirmRate: this.FirmRate += effectParamValue; break; case (int)BuffEffect.AddCritInc: this.CritInc += effectParamValue; break; case (int)BuffEffect.LastHeal: { if (buff.EffectParam.x == 0) { this._unit.HarmHp(new Vector2Int(0, (int)buff.EffectParam.y), buff.Caster, buff.SklId); } else { this._unit.HarmHp(AttrUtil.CalHarm(false, buff.EffectParam.x == 1, buff.EffectParam.y, buff.Caster, this._unit), buff.Caster, buff.SklId); } } break; case (int)BuffEffect.LastHarm: { if (buff.EffectParam.x == 0) { this._unit.HarmHp(new Vector2Int(0, -(int)buff.EffectParam.y), buff.Caster, buff.SklId); } else { this._unit.HarmHp(AttrUtil.CalHarm(false, buff.EffectParam.x == 1, -(int)buff.EffectParam.y, buff.Caster, this._unit), buff.Caster, buff.SklId); } } break; case (int)BuffEffect.Sow: { this._unit.CState = (inverse ? ControlState.None : ControlState.Sow); } break; case (int)BuffEffect.Faint: { this._unit.CState = (inverse ? ControlState.None : ControlState.Faint); } break; case (int)BuffEffect.Spoof: { this._unit.CState = (inverse ? ControlState.None : ControlState.Spoof); if (!inverse) { this._unit.PathFinderObj.StartFind(); } } break; case (int)BuffEffect.Sneer: { this._unit.CState = (inverse ? ControlState.None : ControlState.Sneer); this._unit.SneerTarget = !inverse ? buff.Caster : null; } break; case (int)BuffEffect.Scared: { if (inverse) { this._unit.RemoveSpecialState(SpecialState.Scared); } else { this._unit.AddSpecialState(SpecialState.Scared); } } break; case (int)BuffEffect.Betray: { this._unit.CState = (inverse ? ControlState.None : ControlState.Betray); } break; case (int)BuffEffect.Slient: { if (inverse) { this._unit.RemoveSpecialState(SpecialState.Slient); } else { this._unit.AddSpecialState(SpecialState.Slient); } this._unit.Interrupt(); } break; case (int)BuffEffect.AddBuff: { this.AddBuff(buff.Caster, (int)effectParamValue, buff.BuffLevel); } break; case (int)BuffEffect.UsePromotSkill: { if (Random.Range(0, 1.0f) < effectParamKey) { Skill cskill = JsonMgr.GetSingleton().GetSkillByID((int)effectParamValue); if (cskill != null) { this._unit.UseSKill(cskill, buff.BuffLevel); } } } break; case (int)BuffEffect.Invincible: this._unit.Invincible = !inverse; break; case (int)BuffEffect.DeInvincible: this._unit.DeInvincible = !inverse; break; case (int)BuffEffect.HpSuck: this.HpSuck += effectParamValue; break; case (int)BuffEffect.UseSkill: { Skill cskill = JsonMgr.GetSingleton().GetSkillByID((int)effectParamValue); if (cskill != null) { this._unit.UseSKill(cskill, buff.BuffLevel); } } break; default: break; } }
private void SkillChose(int skillId) { Skill skill = JsonMgr.GetSingleton().GetSkillByID(skillId); skillname_txt.text = skill.name; int skillLv = heroData.SkillLevel[skill.ID]; skilllv_txt.text = skillLv.ToString(); //经验花费等级+5的4次幂 * 0.01 int expcost = Mathf.RoundToInt(Mathf.Pow(skillLv + 5, 4) * 0.01f); expcost_txt.text = expcost.ToString(); int moneyconst = skillLv * 500; moneycost_txt.text = moneyconst.ToString(); //2被动 3自动 4主动 string type = "被动"; if (skill.type == 3) { type = "自动"; } else if (skill.type == 4) { type = "主动"; } condition_txt.text = type; string desc = skill.desc; var o = new List <string>(); int start = 0; for (int i = 0; i < desc.Length; ++i) { if (desc[i].Equals('{')) { start = i; } else if (desc[i].Equals('}') && start != 0) { o.Add(desc.Substring(start + 1, i - start - 1)); start = 0; } } var n = new string[o.Count]; for (int i = 0; i < o.Count; i++) { string[] sp = o[i].Split(':'); int tostring = int.Parse(sp[0]); sp = sp[1].Split('|'); float att = AttrUtil.SkillPanelShow(float.Parse(sp[0]), skillLv, float.Parse(sp[1])); string s = string.Format("{0:###.#}", att * (tostring == 1 ? 100 : 1)); n[i] = s + (tostring == 1 ? "%" : ""); } for (int i = 0; i < n.Length; i++) { desc = desc.Replace(o[i], n[i]); } desc = desc.Replace("{", "").Replace("}", ""); tell_txt.supportRichText = true; tell_txt.text = desc; if (heroData.SkillLevel[skill.ID] >= HeroMgr.MaxHeroLevel) { lvup_btn.interactable = false; return; } lvup_btn.interactable = true; EventListener.Get(lvup_btn.gameObject).OnClick = e => { if (!lvup_btn.interactable) { CanvasView.Instance.AddNotice("技能满级"); return; } //检测技能升级条件 long cash = Role.Instance.Cash; long expPool = Role.Instance.ExpPool; if (expcost > expPool) { CanvasView.Instance.AddNotice("经验不足,技能升级失败!"); return; } if (moneyconst > cash) { CanvasView.Instance.AddNotice("金币不足,技能升级失败!"); return; } //通知服务器技能升级 heroData.SkillLevel[skill.ID]++; SkillChose(skillId); }; }