void ShowTooltip(GameObject go) { UIButton btn = go.GetComponent <UIButton>(); if (btn != null) { if (btn.data != null) { string text = ""; if (btn.data is string) { text = (string)btn.data; } else if (btn.data is HyperNpc) { HyperNpc npc = (HyperNpc)btn.data; text = npc.Name; } else if (btn.data is HyperAttack) { HyperAttack attack = (HyperAttack)btn.data; text = attack.Name; } if (text != "") { CEventSystem.Instance.PushEvent(GAME_EVENT_ID.GE_SUPERTOOLTIP, text); lastWinName = go.name; } } } }
// 解析NPC对话超链接 [3/13/2012 Ivan] void ParseNpcTalkLink(ref HyperLink link, ref string src) { //npc超链接 eg:{#npc[sid,x,y,,id]描述文字} sid标示场景id ,x和y标示坐标,id标示npc的id Regex rDic = new Regex(@"{#npc\[\d+,\d+,\d+,\d+\]\w*}"); MatchCollection mc = rDic.Matches(src); for (int i = 0; i < mc.Count; i++) { // Add the match string to the string array. string fullText = mc[i].Value; int firstKeyIndex = fullText.IndexOf('[') + 1; int lastKeyIndex = fullText.IndexOf(']'); string[] poss = fullText.Substring(firstKeyIndex, lastKeyIndex - firstKeyIndex).Split(','); if (poss.Length != 4) { LogManager.LogError("超链接格式填写错误:" + fullText); continue; } int descLength = fullText.IndexOf('}') - lastKeyIndex - 1; string desc = fullText.Substring(lastKeyIndex + 1, descLength); // 将特定标示转换为显示文字 src = src.Replace(fullText, hyperLinkColor + desc + Color.white); HyperNpc npc = new HyperNpc(); npc.SceneId = int.Parse(poss[0]); npc.PosTarget = new UnityEngine.Vector3(float.Parse(poss[1]), 0, float.Parse(poss[2])); npc.NpcId = int.Parse(poss[3]); npc.textCheck.Text = desc; link.allItems.Add(npc); } }
private void ItemClick(GameObject go) { UIButton btn = go.GetComponent <UIButton>(); if (btn != null) { if (btn.data is HyperNpc) { HyperNpc npc = (HyperNpc)btn.data; npc.Click(); } else if (btn.data is HyperAttack) { HyperAttack attack = (HyperAttack)btn.data; attack.Click(); } } }
void UpdateNpc() { if (ShowNpc) { foreach (MAP_POS_DEFINE item in WorldManager.Instance.ExpNPClistObj) { bool alreadyExist; UIButton newWin = AddNewWin(item, npcIconName, out alreadyExist); if (newWin == null || alreadyExist) { continue; } HyperNpc hyper = new HyperNpc(); hyper.Name = item.name; hyper.NpcId = item.nServerID; hyper.SceneId = WorldManager.Instance.GetActiveSceneID(); hyper.PosTarget = new Vector3(item.pos.x, 0, item.pos.y); newWin.data = hyper; } } }