public void AddNewBlob(MatchMsg msg, bool bHome) { MsgBlob msgBlob = new MsgBlob(); GameObject newBtn = NGUITools.AddChild(gameObject, m_goBlob); TweenAlpha.Begin(newBtn, m_dispearTime, 0.0f); newBtn.SetActive(true); msgBlob.goBtn = newBtn; msgBlob.msg = msg; msgBlob.bHome = bHome; UILabel uiLabel = newBtn.GetComponentInChildren <UILabel>(); uiLabel.text = msg.pop_text; if (m_goBlobs.Count == 3) { MsgBlob lastMsgBlob = m_goBlobs[2]; m_goBlobs.Remove(lastMsgBlob); Destroy(lastMsgBlob.goBtn); } m_goBlobs.Insert(0, msgBlob); m_bNeedRefresh = true; }
public void ReadConfig() { if (isLoadFinish == false) { return; } isLoadFinish = false; lock (LockObject) { GameSystem.Instance.readConfigCnt += 1; } Debug.Log("Config reading " + name1); string text = ResourceLoadManager.Instance.GetConfigText(name1); if (text == null) { ErrorDisplay.Instance.HandleLog("LoadConfig failed: " + name1, "", LogType.Error); return; } try { XmlDocument doc = CommonFunction.LoadXmlConfig(GlobalConst.DIR_XML_MATCH_MSG, text); XmlNode root = doc.SelectSingleNode("Data"); foreach (XmlNode line in root.SelectNodes("Line")) { if (CommonFunction.IsCommented(line)) { continue; } MatchMsg matchMsg = new MatchMsg(); matchMsg.id = uint.Parse(line.SelectSingleNode("ID").InnerText); string strCondition = line.SelectSingleNode("Conditions").InnerText; string[] conds = strCondition.Split('&'); uint uCond = 0; foreach (string cond in conds) { uCond = 0; if (!uint.TryParse(cond, out uCond)) { continue; } matchMsg.conds.Add(uCond); } matchMsg.menu_type = uint.Parse(line.SelectSingleNode("MenuType").InnerText); matchMsg.cd = uint.Parse(line.SelectSingleNode("CD").InnerText); matchMsg.desc = line.SelectSingleNode("Desc").InnerText; matchMsg.audio_src = line.SelectSingleNode("AudioSrc").InnerText; matchMsg.recvType = (MatchMsgRecvType)int.Parse(line.SelectSingleNode("RecvType").InnerText); matchMsg.pop_text = line.SelectSingleNode("PopText").InnerText; matchMsgs.Add(matchMsg); } } catch (XmlException cep) { Debug.LogError("Parse matchmsgconfig failed: " + cep); } }
public MatchMsgBtn(GameObject inBtn, MatchMsg inMsg) { btn = inBtn; msg = inMsg; valid = true; timeCnt = 0; m_btnScale = btn.GetComponent <UIButtonScale>(); m_btnSound = btn.GetComponent <UIPlaySound>(); }
void Update() { if (uiGridCustomMsgs != null) { uiGridCustomMsgs.gameObject.SetActive(m_bShowCustomMsg); } if (goCustomMsg != null) { goCustomMsg.SetActive(m_bShowAll); } if (goMsg1.transform.parent != null) { goMsg1.transform.parent.gameObject.SetActive(m_bShowAll); } if (goMsg2.transform.parent != null) { goMsg2.transform.parent.gameObject.SetActive(m_bShowAll); } if (uiGridCustomMsgs != null && m_bShowCustomMsg) { uiGridCustomMsgs.gameObject.SetActive(m_bShowAll); } m_matchMsgBtns.ForEach((MatchMsgBtn btn) => { btn.Update(Time.deltaTime); }); UBasketball ball = m_match.mCurScene.mBall; if (ball == null) { return; } uint curMatchMsgCond = 0; if (ball.m_ballState != BallState.eUseBall) { curMatchMsgCond = 1; } else { if (ball.m_owner.m_team == m_match.mainRole.m_team) { if (ball.m_owner == m_match.mainRole) { curMatchMsgCond = 4; } else { curMatchMsgCond = 3; } } else { curMatchMsgCond = 2; } } if ((curMatchMsgCond != m_curMatchMsgCond && curMatchMsgCond != 0) || (m_match.mainRole != null && m_curMatchMsgRoleId != m_match.mainRole.m_id) ) { m_matchMsgBtns.Clear(); m_curMatchMsgRoleId = m_match.mainRole.m_id; List <MatchMsg> matchedmsgs = GameSystem.Instance.matchMsgConfig.matchMsgs.FindAll((MatchMsg msg) => { return(msg.conds.Contains(curMatchMsgCond)); }); if (m_match.mainRole != null) { uint id = m_match.mainRole.m_id; RoleBaseData2 rd = GameSystem.Instance.RoleBaseConfigData2.GetConfigData(id); if (rd == null) { Debug.LogError("Unable to find role base: " + id); } m_matchMsgBtns.Add(new MatchMsgBtn(goCustomMsg, null)); List <MatchMsg> filteredMsgs = new List <MatchMsg>(); foreach (uint msg_id in rd.match_msg_ids) { MatchMsg filteredMsg = matchedmsgs.Find((MatchMsg msg) => { return(msg.id == msg_id); }); if (filteredMsg == null) { continue; } filteredMsgs.Add(filteredMsg); } //update ui MatchMsg finalMsg = filteredMsgs.Find((MatchMsg msg) => { return(msg.menu_type == 1); }); if (finalMsg != null) { GameObject btnMsg1 = goMsg1.transform.parent.gameObject; MatchMsgBtn matchBtn = new MatchMsgBtn(btnMsg1, finalMsg); m_matchMsgBtns.Add(matchBtn); if (!m_bShowAll) { btnMsg1.SetActive(true); } UISprite icon = goMsg1.GetComponent <UISprite>(); icon.spriteName = finalMsg.desc; if (!m_bShowAll) { btnMsg1.SetActive(false); } } finalMsg = filteredMsgs.Find((MatchMsg msg) => { return(msg.menu_type == 2); }); if (finalMsg != null) { GameObject btnMsg2 = goMsg2.transform.parent.gameObject; MatchMsgBtn matchBtn = new MatchMsgBtn(btnMsg2, finalMsg); m_matchMsgBtns.Add(matchBtn); if (!m_bShowAll) { btnMsg2.SetActive(true); } UISprite icon = goMsg2.GetComponent <UISprite>(); icon.spriteName = finalMsg.desc; if (!m_bShowAll) { btnMsg2.SetActive(false); } } if (!m_bShowCustomMsg || !m_bShowAll) { uiGridCustomMsgs.gameObject.SetActive(true); } CommonFunction.ClearGridChild(uiGridCustomMsgs.transform); List <MatchMsg> finalMsgs = filteredMsgs.FindAll((MatchMsg msg) => { return(msg.menu_type == 3); }); foreach (MatchMsg msg in finalMsgs) { GameObject goChild = GameObject.Instantiate(m_btnCustomItem.gameObject) as GameObject; goChild.SetActive(true); uiGridCustomMsgs.AddChild(goChild.transform); MatchMsgBtn matchBtn = new MatchMsgBtn(goChild, msg); m_matchMsgBtns.Add(matchBtn); UILabel label = goChild.GetComponentInChildren <UILabel>(); label.text = msg.desc; UIEventListener.Get(goChild).onClick = OnClickMsg; goChild.transform.localScale = Vector3.one; } if (!m_bShowCustomMsg || !m_bShowAll) { uiGridCustomMsgs.gameObject.SetActive(false); } } m_curMatchMsgCond = curMatchMsgCond; } }