Exemplo n.º 1
0
    void OnClickMsg(GameObject go)
    {
        if (go == goShortMsgFolder)
        {
            m_bShowAll = !m_bShowAll;
            TweenRotation.Begin(goShortMsgFolder, 0.2f, Quaternion.AngleAxis(m_bShowAll ? 0.0f : 90.0f, new Vector3(0.0f, 0.0f, 1.0f))).method = UITweener.Method.EaseOut;
            return;
        }

        MatchMsgBtn msgBtn = m_matchMsgBtns.Find((MatchMsgBtn matchBtn) => { return(matchBtn.btn == go); });

        if (msgBtn == null)
        {
            return;
        }
        if (!msgBtn.valid)
        {
            return;
        }
        if (go == goCustomMsg)
        {
            m_bShowCustomMsg = !m_bShowCustomMsg;
            return;
        }

        foreach (MatchMsgBtn btn in m_matchMsgBtns)
        {
            btn.Reset(msgBtn.msg.cd);
        }
        m_bShowCustomMsg = false;
        GameMsgSender.SendGameShortMsg(m_match.mainRole, msgBtn.msg.id, (uint)msgBtn.msg.recvType);
    }
Exemplo n.º 2
0
    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;
        }
    }