private void ShowType(EHEROSHOWTYPE type) { if (showGo != null) { showGo.SetParent(Hide_trf); } if (LOfficer_obj.activeInHierarchy) { LOfficer_obj.SetActive(false); Left_obj.SetActive(true); } if (Divination_obj.activeInHierarchy) { Divination_obj.SetActive(false); takeoff_btn.gameObject.SetActive(false); take_btn.gameObject.SetActive(false); Equip_obj.SetActive(true); Dress_btn.gameObject.SetActive(true); Intensify_btn.gameObject.SetActive(true); } ShowLeft(); switch (type) { case EHEROSHOWTYPE.Card: ShowCard(); break; case EHEROSHOWTYPE.Officer: ShowOfficer(); break; case EHEROSHOWTYPE.Divination: ShowDivination(); break; case EHEROSHOWTYPE.Skill: ShowSkill(); break; case EHEROSHOWTYPE.Relation: ShowRelation(); break; case EHEROSHOWTYPE.Detail: ShowDetail(); break; } showType = type; }
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); }