Exemple #1
0
    // Use this for initialization
    void Start()
    {
        client = new MyKcp();
        client.NoDelay(1, 10, 2, 1);    //fast
        client.WndSize(64, 64);
        client.Timeout(10 * 1000);
        client.SetMtu(512);
        client.SetMinRto(10);
        client.SetConv(121106);
        //client.Connect("119.29.153.92", 2222);
        client.Connect("127.0.0.1", 10086);
        client.Start();

        StartCoroutine(Co());
    }
    public void Connect(string host, int port)
    {
        if (null != client)
        {
            client.Stop();
        }

        client = new MyKcp();
        client.NoDelay(1, 10, 2, 1);//fast
        client.WndSize(4096, 4096);
        client.Timeout(40 * 1000);
        client.SetMtu(512);
        client.SetMinRto(10);
        client.SetConv(121106);

        client.Connect(host, port);

        client.Start();
    }
Exemple #3
0
    // Use this for initialization
    void Start()
    {
        Screen.fullScreen    = false;
        m_LastQuickLoginTime = 0;
        SaveDataManager.SetFileName(winMachineid);
        //MyKcp.Instance.Destroy();
        //读取存档
        SaveDataManager.Read();

        //UIPackage.AddPackage("FairyGui/GameUI");
        //GComponent view = UIPackage.CreateObject("GameUI","MyInfo").asCom;
        //以下几种方式都可以将view显示出来:
        //1,直接加到GRoot显示出来
        //GRoot.inst.AddChild(view);
        //view.Center();
        Debug.Log("width:" + Screen.width + " height:" + Screen.height);
        UIPackage.AddPackage("FairyGui/GameUI");



        //MyKcp.Instance.Create("119.23.8.72", 1118);
        //MyKcp.Instance.Create("119.23.8.72", 1118);
        mRoot = GetComponent <UIPanel>().ui;
        ToolManager();


        //打开gm窗口
        mLineUp = UIPackage.CreateObject("GameUI", "LineUp").asCom;
        GRoot.inst.AddChild(mLineUp);
        mLineUp.visible = false;
        mLineUp.xy      = Tool.GetPosition(0.5f, 0.5f);
        mLineUp.GetChild("close").asButton.onClick.Add(() =>
        {
            Tool.NoticeWindonw("你确定要退出排队吗?", () =>
            {
                Protomsg.CS_CancelLineUp msg1 = new Protomsg.CS_CancelLineUp();
                MyKcp.Instance.SendMsg("Login", "CS_CancelLineUp", msg1);
                mLineUp.visible = false;
            });
        });
        mLineUp.GetChild("fresh").asButton.onClick.Add(() =>
        {
            Tool.NoticeWindonw("你确定要查看排在你前面的玩家人数吗?", () =>
            {
                Protomsg.CS_GetLineUpFrontCount msg1 = new Protomsg.CS_GetLineUpFrontCount();
                MyKcp.Instance.SendMsg("Login", "CS_GetLineUpFrontCount", msg1);
            });
        });


        //mRoot.GetChild("center")..AddChild(view);
        mRoot.GetChild("login").asButton.onClick.Add(() => {
            //两秒内不能重复登录
            if (Tool.GetTime() - m_LastQuickLoginTime <= 2 || SelectServer == null)
            {
                return;
            }
            m_LastQuickLoginTime = Tool.GetTime();

            //MyKcp.Instance.Destroy();
            //MyKcp.Instance.Create(SelectServer.ip, SelectServer.port);
            MyKcp.Create(SelectServer.Ip, SelectServer.Port);

            Protomsg.CS_MsgQuickLogin msg1 = new Protomsg.CS_MsgQuickLogin();
            //msg1.Machineid = "100001"; //PA
            //msg1.Machineid = "10000";   //剑圣 (技能特效完结)
            //msg1.Machineid = "10002";   //小黑 (技能特效完结)
            //msg1.Machineid = "10003";   //虚空 (技能特效完结)
            //msg1.Machineid = "10004";   //混沌骑士 (技能特效完结)
            //msg1.Machineid = "10005";   //熊战士   (技能特效完结)
            //msg1.Machineid = "10006";   //血魔    (技能特效完结)
            //msg1.Machineid = "10007";   //小娜迦 (技能特效完结)
            //msg1.Machineid = "10008";   //小小 (技能特效完结)
            //msg1.Machineid = "10009";   //风行 (技能特效完结)
            //msg1.Machineid = "10010";   //帕克 (技能特效完结)
            //msg1.Machineid = "10011";   //影魔 (技能特效完结)
            //msg1.Machineid = "10012";   //幽鬼 (技能特效完结)
            //msg1.Machineid = "10013";   //火枪 (技能特效完结)
            //msg1.Machineid = "10014";   //斧王 (技能特效完结)
            //msg1.Machineid = "10015";   //月骑 (技能特效完结)
            //msg1.Machineid = "10016";   //毒龙 (技能特效完结)
            //msg1.Machineid = "10017";   //蓝猫 (技能特效完结)
            //msg1.Machineid = "10018";   //瘟疫法师
            //msg1.Machineid = "10019";   //天怒法师
            Environment.GetCommandLineArgs();
            msg1.Machineid = SystemInfo.deviceUniqueIdentifier + winMachineid;
            msg1.Platform  = "test";
            MyKcp.Instance.SendMsg("Login", "CS_MsgQuickLogin", msg1);
            UnityEngine.Debug.Log("login onClick");
        });


        InitServerList();

        MsgManager.Instance.AddListener("SC_Logined", new HandleMsg(this.Logined));

        MsgManager.Instance.AddListener("SC_SelectCharacterResult", new HandleMsg(this.SelectCharacterResult));

        MsgManager.Instance.AddListener("SC_NeedLineUp", new HandleMsg(this.SC_NeedLineUp));
        MsgManager.Instance.AddListener("SC_GetLineUpFrontCount", new HandleMsg(this.SC_GetLineUpFrontCount));
    }