public void SetView(TotemData data, int lv = 1) { if (data == null) { Color c = item_img.color; c.a = 0; item_img.color = c; play_cr.SetAlpha(0); name_txt.text = string.Format("<color=#FFFF00>{0}级</color>", lv); level_txt.text = ""; return; } this.data = data; cr.SetAlpha(1); play_cr.SetAlpha(0); Color co = item_img.color; co.a = 1; item_img.color = co; item_img.sprite = ResourceMgr.Instance.LoadSprite(data.ItemData.icon); EventListener.Get(item_img.gameObject).OnClick = e => { UIFace.GetSingleton().Open(UIID.DivinationTip, data, SHOWBUTTON.EtakeOff); }; int rare = data.ItemData.rare; string color = ColorMgr.Colors[rare - 1]; name_txt.text = string.Format("<color=#{0}>Lv.{1}\n {2}</color>", color, data.Level, data.TotemConfig.Name); }
public override void SetParameters(object[] arg) { if (arg.Length > 0) { data = (TotemData)arg[0]; } }
public void Open(TotemData td) { if (td == null) { return; } playExp = 0; plusLevel = 0; composeItem = td; playItem_img.sprite = ResourceMgr.Instance.LoadSprite(td.ItemData.icon); ExpValue(); name_txt.text = td.ItemData.name; SetAttrActive(false); st = tip_obj.GetComponent <ScaleTween>(); st.AddOnFinished(delegate() { tip_obj.SetActive(false); }); EventListener.Get(tip_btn.gameObject).OnClick = e => { tip_obj.SetActive(true); st.ResetToBeginning(); st.PlayForward(); }; EventListener.Get(close_btn.gameObject).OnClick = e => { UIFace.GetSingleton().Close(UIID.CompostDivination); }; SetPlayView(); InitItem(); }
public void RemoveTotem(TotemData data) { if (TotemDic.ContainsKey(data.md5)) { TotemDic.Remove(data.md5); } ZEventSystem.Dispatch(EventConst.TOTEMDATACHANGE); }
public void AddTotem(TotemData data) { if (TotemDic.ContainsKey(data.md5)) { return; } TotemDic.Add(data.md5, data); ZEventSystem.Dispatch(EventConst.TOTEMDATACHANGE); }
public override void SetParameters(object[] arg) { if (arg.Length > 0) { td = (TotemData)arg[0]; } if (arg.Length > 1) { e = (SHOWBUTTON)arg[1]; } }
public void OnLoadTotemData(ServerMsgObj msg) { string server = msg.Msg; TotemMsgCollect tc = JsonUtility.FromJson <TotemMsgCollect>(server); TotemData[] data = new TotemData[tc.totems.Length]; for (int i = 0; i < data.Length; i++) { data[i] = new TotemData(tc.totems[i]); TotemMgr.GetSingleton().AddTotem(data[i]); } }
public TotemData[] GetHeroTotem(string[] totemArray) { TotemData[] ret = new TotemData[totemArray.Length]; for (int i = 0; i < totemArray.Length; ++i) { if (TotemDic.ContainsKey(totemArray[i])) { ret[i] = TotemDic[totemArray[i]]; } } return(ret); }
/// <summary> /// 脱下气运 /// </summary> /// <param name="totem"></param> public void TakeOffTotem(TotemData totem) { HeroData hero = HeroMgr.GetSingleton().GetHeroData(totem.HeroID); if (hero == null) { return; } hero.Totems[totem.Groove] = ""; totem.HeroID = 0; totem.Groove = 0; hero.ClearTotemAttr(); }
/// <summary> /// 穿带气运 /// </summary> /// <param name="totem"></param> public int TakeHeroTotem(HeroData hero, TotemData totem) { int length = hero.Totems.Length; for (int i = 0; i < length; i++) { if (hero.Totems[i] == "") { hero.Totems[i] = totem.md5; hero.ClearTotemAttr(); return(i); } } CanvasView.Instance.AddNotice("没有可用的气运槽"); return(int.MaxValue); }
public List <Pro> TotemAttr() { if (totemAttr == null) { totemAttr = new List <Pro>(); TotemData[] totems = GetTotem(); for (int i = 0, length = totems.Length; i < length; ++i) { TotemData ed = totems[i]; if (ed == null) { continue; } totemAttr.AddRange(ed.Attribute); } } return(totemAttr); }
public void TakeTotem(TotemData td, HeroData hd) { if (!TotemDic.ContainsKey(td.md5)) { return; } int res = HeroMgr.GetSingleton().TakeHeroTotem(hd, td); if (res == int.MaxValue) { return; } //服务器处理 这里模拟 td.HeroID = hd.HeroId; td.Groove = res; hd.ClearTotemAttr(); }
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 Instantiate(string id) { GameObject go = Instantiate(item, itemparent_trf, false); DivinationItemView div = go.GetComponent <DivinationItemView>(); TotemData td = TotemMgr.GetSingleton().GetTotemByID(id); if (td == null) { td = new TotemData(40007) { md5 = id }; TotemMgr.GetSingleton().AddTotem(td); } div.SetView(td); EventListener.Get(go).OnClick = e => { ZEventSystem.Register(EventConst.ONOPENCOMPOSE, this, "OnOpenCompose"); UIFace.GetSingleton().Open(UIID.DivinationTip, td, SHOWBUTTON.Ecompose); if (!select_trf.gameObject.activeInHierarchy) { select_trf.gameObject.SetActive(true); } select_trf.SetParent(go.transform); select_trf.transform.localPosition = Vector3.zero; }; EventListener.Get(go).BegineDragEvent = e => { Item_sr.OnBeginDrag(e); }; EventListener.Get(go).DragEvent = e => { Item_sr.OnDrag(e); }; EventListener.Get(go).EndDragEvent = e => { Item_sr.OnEndDrag(e); }; Role.Instance.DivinationLucky += JsonMgr.GetSingleton().GetTotemTreeByID(progress + 1).spend; lucky_img.fillAmount = Role.Instance.DivinationLucky / maxLucky; }
private void InitItem() { TotemData[] totems = TotemMgr.GetSingleton().Totems; for (int i = 0; i < totems.Length; ++i) { TotemData totem = totems[i]; if (totem.md5 == composeItem.md5 || totem.HeroID != 0) { continue; } GameObject t = Instantiate(item, divination_sr.content); DivinationItemView div = t.GetComponent <DivinationItemView>(); div.SetView(totem); allItem.Add(div); EventListener.Get(t).OnClick = e => { if (!playItem.Contains(div)) { if (playItem.Count >= 6) { CanvasView.Instance.AddNotice("已到最大数量"); return; } playItem.Add(div); div.SetAlpha(1); for (int j = 1; j < div.data.Level; j++) { playExp += div.data.LevelUpExp(j); } playExp += totem.Exp; playExp += totem.TotemConfig.Exp; } else { playItem.Remove(div); div.SetAlpha(0); for (int j = 1; j < div.data.Level; j++) { playExp -= div.data.LevelUpExp(j); } playExp -= totem.Exp; playExp -= totem.TotemConfig.Exp; } SetPlayView(); ExpValue(); }; EventListener.Get(t).BegineDragEvent = e => { divination_sr.OnBeginDrag(e); }; EventListener.Get(t).DragEvent = e => { divination_sr.OnDrag(e); }; EventListener.Get(t).EndDragEvent = e => { divination_sr.OnEndDrag(e); }; } EventListener.Get(auto_btn.gameObject).OnClick = e => { int count = playItem.Count; int index = allItem.Count; index--; while (playItem.Count < 6 && index >= 0) { if (!playItem.Contains(allItem[index])) { playItem.Add(allItem[index]); allItem[index].SetAlpha(1); } index--; } playExp = 0; for (int i = 0; i < playItem.Count; i++) { for (int j = 1; j < playItem[i].data.Level; j++) { playExp += playItem[i].data.LevelUpExp(j);; } playExp += playItem[i].data.Exp; playExp += playItem[i].data.TotemConfig.Exp; } SetPlayView(); ExpValue(); }; Vector2 size = divination_sr.content.sizeDelta; size.y = Mathf.CeilToInt(totems.Length / 3f) * 182 + 24; divination_sr.content.sizeDelta = size; EventListener.Get(sure_btn.gameObject).OnClick = e => { if (composeItem == null) { return; } Compose(); SetPlayView(); ExpValue(); Close(); Open(composeItem); }; }
public void TakeTotem(TotemData data) { TotemMgr.GetSingleton().TakeTotem(data, heroData); ShowDivination(); }
private void ShowDivination() { showGo = Divination_trf; showGo.SetParent(Right_trf); Divination_obj.SetActive(true); takeoff_btn.gameObject.SetActive(true); take_btn.gameObject.SetActive(true); Dress_btn.gameObject.SetActive(false); Intensify_btn.gameObject.SetActive(false); Equip_obj.SetActive(false); HeroDivinationView hdv = Divination_obj.GetComponent <HeroDivinationView>(); hdv.SetHeroTotemView(heroData); EventListener.Get(gotoDiv_btn.gameObject).OnClick = e => { UIFace.GetSingleton().Open(UIID.Divination); }; int count = divparent_trf.childCount; TotemData[] mData = TotemMgr.GetSingleton().GetUnDressTotem(); while (count > mData.Length) { DestroyImmediate(divparent_trf.GetChild(0).gameObject); count = divparent_trf.childCount; } for (int i = 0; i < mData.Length; ++i) { TotemData data = mData[i]; if (data.HeroID != 0) { continue; } GameObject totem; if (i < count) { totem = divparent_trf.GetChild(i).gameObject; } else { totem = Instantiate(totemGo, divparent_trf); } DivinationItemView div = totem.GetComponent <DivinationItemView>(); div.SetView(data); EventListener.Get(totem).OnClick = e => { ZEventSystem.Register(EventConst.TAKETOTEM, this, "TakeTotem"); UIFace.GetSingleton().Open(UIID.DivinationTip, data, SHOWBUTTON.Etake); }; EventListener.Get(totem).BegineDragEvent = e => { divination_sr.OnBeginDrag(e); }; EventListener.Get(totem).DragEvent = e => { divination_sr.OnDrag(e); }; EventListener.Get(totem).EndDragEvent = e => { divination_sr.OnEndDrag(e); }; } Vector2 size = divination_sr.content.sizeDelta; size.y = Mathf.CeilToInt(mData.Length / 3f) * 159 + 26; divination_sr.content.sizeDelta = size; EventListener.Get(take_btn.gameObject).OnClick = e => { if (mData.Length <= 0) { return; } int index = mData.Length - 1; TotemData[] totems = heroData.GetTotem(); if (totems.Length == 0) { CanvasView.Instance.AddNotice("没有可用的气运槽"); return; } for (int i = 0, length = totems.Length; i < length; ++i) { TotemMgr.GetSingleton().TakeTotem(mData[i], heroData); } ShowSide(false); }; EventListener.Get(takeoff_btn.gameObject).OnClick = e => { TotemData[] totems = heroData.GetTotem(); for (int i = 0, length = totems.Length; i < length; ++i) { if (totems[i] == null) { continue; } TotemMgr.GetSingleton().TakeOffTotem(totems[i]); } ShowSide(false); }; }