Exemplo n.º 1
0
    public void showHeadSelect(UnityEntity unit)
    {
        var headselect = UIPackage.CreateObject("GameUI", "HeadSelect").asCom;

        //GRoot.inst.AddChild(headselect);
        GRoot.inst.ShowPopup(headselect);
        headselect.xy = maininfo.xy;
        headselect.x += 50;
        headselect.y += 50;


        //注销组队功能
        //headselect.GetChild("team").asButton.onClick.Add(() =>
        //{

        //    if (GameScene.Singleton.m_MyMainUnit == null || unit == null)
        //    {
        //        GRoot.inst.HidePopup(headselect);
        //        return;
        //    }

        //    Protomsg.CS_OrganizeTeam msg1 = new Protomsg.CS_OrganizeTeam();
        //    msg1.Player1 = GameScene.Singleton.m_MyMainUnit.ControlID;
        //    msg1.Player2 = unit.ControlID;
        //    MyKcp.Instance.SendMsg(GameScene.Singleton.m_ServerName, "CS_OrganizeTeam", msg1);
        //    GRoot.inst.HidePopup(headselect);
        //});

        headselect.GetChild("info").asButton.onClick.Add(() =>
        {
            GRoot.inst.HidePopup(headselect);
            MyInfo myinfo = new MyInfo(unit);
        });
        headselect.GetChild("siliao").asButton.onClick.Add(() =>
        {
            ChatUI.SOpenChatBox("zonghe", unit.Name, unit.ControlID);
            GRoot.inst.HidePopup(headselect);
        });
    }
Exemplo n.º 2
0
    public bool SC_GetFriendsList(Protomsg.MsgBase d1)
    {
        Debug.Log("SC_GetFriendsList:");
        IMessage IMperson = new Protomsg.SC_GetFriendsList();

        Protomsg.SC_GetFriendsList p2 = (Protomsg.SC_GetFriendsList)IMperson.Descriptor.Parser.ParseFrom(d1.Datas);

        var list = FriendsCom.GetChild("list").asList;

        list.RemoveChildren();

        foreach (var p1 in p2.FriendsRequest)
        {
            var teamrequest = UIPackage.CreateObject("GameUI", "FriendRequest").asCom;
            list.AddChild(teamrequest);
            AudioManager.Am.Play2DSound(AudioManager.Sound_OpenLittleUI);
            //SrcUnitTypeID
            var clientitem = ExcelManager.Instance.GetUnitInfoManager().GetUnitInfoByID(p1.Typeid);
            if (clientitem != null)
            {
                teamrequest.GetChild("headicon").asLoader.url = clientitem.IconPath;
            }
            teamrequest.GetChild("name").asTextField.text  = p1.Name;
            teamrequest.GetChild("level").asTextField.text = p1.Level + "";

            teamrequest.GetChild("no_btn").asButton.onClick.Add(() =>
            {
                //回复拒绝好友请求
                Protomsg.CS_AddFriendResponse msg = new Protomsg.CS_AddFriendResponse();
                msg.Result     = 2;//1同意  2拒绝
                msg.FriendInfo = p1;
                MyKcp.Instance.SendMsg(GameScene.Singleton.m_ServerName, "CS_AddFriendResponse", msg);

                list.RemoveChild(teamrequest);
            });

            teamrequest.GetChild("yes_btn").asButton.onClick.Add(() =>
            {
                //回复同意组队请求
                Protomsg.CS_AddFriendResponse msg = new Protomsg.CS_AddFriendResponse();
                msg.Result     = 1;//1同意  2拒绝
                msg.FriendInfo = p1;
                MyKcp.Instance.SendMsg(GameScene.Singleton.m_ServerName, "CS_AddFriendResponse", msg);
                list.RemoveChild(teamrequest);
            });
        }

        //处理排序
        Protomsg.FriendInfoMsg[] allplayer = new Protomsg.FriendInfoMsg[p2.Friends.Count];
        int index = 0;

        foreach (var item in p2.Friends)
        {
            allplayer[index++] = item;
        }
        //排序
        System.Array.Sort(allplayer, (s1, s2) => {
            if (s1.State > s2.State)
            {
                return(1);
            }
            else if (s1.State == s2.State)
            {
                return(0);
            }
            return(-1);
        });

        foreach (var p1 in allplayer)
        {
            var teamrequest = UIPackage.CreateObject("GameUI", "FriendOne").asCom;
            list.AddChild(teamrequest);
            AudioManager.Am.Play2DSound(AudioManager.Sound_OpenLittleUI);
            //SrcUnitTypeID
            var clientitem = ExcelManager.Instance.GetUnitInfoManager().GetUnitInfoByID(p1.Typeid);
            if (clientitem != null)
            {
                teamrequest.GetChild("headicon").asLoader.url = clientitem.IconPath;
            }
            teamrequest.GetChild("name").asTextField.text  = p1.Name;
            teamrequest.GetChild("level").asTextField.text = p1.Level + "";
            if (p1.State == 1)
            {
                //在线
                teamrequest.GetChild("discript").asTextField.text   = "在线";
                teamrequest.GetChild("discript").asTextField.color  = new Color(1, 1, 1);
                teamrequest.GetChild("name").asTextField.color      = new Color(1, 1, 1);
                teamrequest.GetChild("level").asTextField.color     = new Color(1, 1, 1);
                teamrequest.GetChild("levelword").asTextField.color = new Color(1, 1, 1);

                teamrequest.onClick.Add(() => {
                    //onlinefriendclick
                    var headselect = UIPackage.CreateObject("GameUI", "onlinefriendclick").asCom;
                    GRoot.inst.ShowPopup(headselect);
                    headselect.GetChild("siliao").asButton.onClick.Add(() =>
                    {
                        ChatUI.SOpenChatBox("zonghe", p1.Name, p1.Uid);
                        GRoot.inst.HidePopup(headselect);
                    });
                    headselect.GetChild("info").asButton.onClick.Add(() =>
                    {
                        new HeroSimpleInfo(p1.Characterid);
                    });
                    //注销组队功能
                    //headselect.GetChild("zudui").asButton.onClick.Add(() =>
                    //{
                    //    Protomsg.CS_OrganizeTeam msg1 = new Protomsg.CS_OrganizeTeam();
                    //    msg1.Player1 = GameScene.Singleton.m_MyMainUnit.ControlID;
                    //    msg1.Player2 = p1.Uid;
                    //    MyKcp.Instance.SendMsg(GameScene.Singleton.m_ServerName, "CS_OrganizeTeam", msg1);
                    //    GRoot.inst.HidePopup(headselect);
                    //});
                });
            }
            else
            {
                //离线
                teamrequest.GetChild("discript").asTextField.text   = "离线";
                teamrequest.GetChild("discript").asTextField.color  = new Color(0.2f, 0.2f, 0.2f);
                teamrequest.GetChild("name").asTextField.color      = new Color(0.2f, 0.2f, 0.2f);
                teamrequest.GetChild("level").asTextField.color     = new Color(0.2f, 0.2f, 0.2f);
                teamrequest.GetChild("levelword").asTextField.color = new Color(0.2f, 0.2f, 0.2f);

                teamrequest.onClick.Add(() => {
                    new HeroSimpleInfo(p1.Characterid);
                });
            }
        }

        return(true);
    }