public int HandlePacket(GameClient client, GSPacketIn packet) { if (client.Player.PlayerCharacter.Grade < 20) { client.Out.SendMessage(eMessageType.Normal, "Hack level sao bạn!"); return(0); } if (client.Player.PlayerCharacter.HasBagPassword && client.Player.PlayerCharacter.IsLocked) { client.Out.SendMessage(eMessageType.Normal, LanguageMgr.GetTranslation("Bag.Locked", new object[0])); return(1); } int totemId = client.Player.PlayerCharacter.totemId; int consumeExp = TotemMgr.FindTotemInfo(totemId).ConsumeExp; int consumeHonor = TotemMgr.FindTotemInfo(totemId).ConsumeHonor; if (client.Player.PlayerCharacter.Money >= consumeExp && client.Player.PlayerCharacter.myHonor >= consumeHonor) { if (totemId == 0) { client.Player.AddTotem(10001); } else { client.Player.AddTotem(1); } client.Player.AddExpVip(consumeExp); client.Player.RemoveMoney(consumeExp); client.Player.RemovemyHonor(consumeHonor); client.Player.Out.SendPlayerRefreshTotem(client.Player.PlayerCharacter); client.Player.MainBag.UpdatePlayerProperties(); client.Player.OnUserToemGemstoneEvent(); } return(0); }
public void AddBaseTotemProperty(PlayerInfo p, ref int attack, ref int defence, ref int agility, ref int lucky, ref int hp) { attack += TotemMgr.getProp(p.totemId, "att"); defence += TotemMgr.getProp(p.totemId, "def"); agility += TotemMgr.getProp(p.totemId, "agi"); lucky += TotemMgr.getProp(p.totemId, "luc"); hp += TotemMgr.getProp(p.totemId, "blo"); }
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 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 Compose() { particle.Play(); for (int i = 0; i < playItem.Count; ++i) { TotemMgr.GetSingleton().RemoveTotem(playItem[i].data); childparticle[i].Play(); } playItem.Clear(); int upexp = composeItem.LevelUpExp() - composeItem.Exp; while (playExp >= upexp) { composeItem.Level++; composeItem.Exp = 0; playExp -= upexp; upexp = composeItem.LevelUpExp() - composeItem.Exp; } composeItem.Exp += Mathf.FloorToInt(playExp); playExp = 0; ZEventSystem.Dispatch(EventConst.TOTEMDATACHANGE); }
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 TotemData[] GetTotem() { return(TotemMgr.GetSingleton().GetHeroTotem(Totems)); }
public static TotemMgr GetSingleton() { return(_totem ?? (_totem = new TotemMgr())); }
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); }; }