Beispiel #1
0
    public static void SendData(int dest, int cmd, Dictionary <string, string> param)
    {
        string msgindex = "Msg_";

        msgindex += dest + "_";
        msgindex += cmd;

        //System.Reflection.Assembly.Load("程序集名称").CreateInstance("命名空间.类名", false);
        //反射创建
        Msg_2_2 msg = new Msg_2_2();
    }
Beispiel #2
0
    void OnGUI()
    {
        if (GUI.Button(new Rect(10, 10, 100, 50), "连接测试"))
        {
            //Debug.Log("开始连接");

            string ip   = "120.25.155.188";
            int    port = 6000;

            XLogicWorld.SP.NetManager.ConnectServer(ip, port);
        }

        if (GUI.Button(new Rect(150, 10, 100, 50), "登陆"))
        {
            //登录请求
            Debug.Log("登录请求");

            Msg_2_2 msg = new Msg_2_2();
            msg.aid    = "kk"; //先写死角色名
            msg.zoneId = 1;    //先写死1

            MessageStruct message = MessageStruct.SerializeData(2, 2, msg);

            XLogicWorld.SP.NetManager.SendDataToServer(message);
        }

        if (GUI.Button(new Rect(350, 10, 100, 50), "4_1命令"))
        {
            //登录请求

            //UILogin.AddNew();

            Msg_4_1 msg = new Msg_4_1();
            msg.type     = 1;//先写死角色名
            msg.chatData = "卡死大家分开了 所带来房价";

            MessageStruct message = MessageStruct.SerializeData(4, 1, msg);

            XLogicWorld.SP.NetManager.SendDataToServer(message);
        }

        if (GUI.Button(new Rect(500, 10, 100, 50), "100_1命令"))
        {
            Msg_100_1 msg = new Msg_100_1();
            msg.type     = 1;//先写死角色名
            msg.chatData = "卡死大家分开了 所带来房价";

            MessageStruct message = MessageStruct.SerializeData(100, 1, msg);

            XLogicWorld.SP.NetManager.SendDataToServer(message);
        }
    }
Beispiel #3
0
    void OnGUI()
    {
        if (GUI.Button(new Rect(10, 10, 100, 50), "连接测试"))
        {
            Debug.Log("开始连接");

            string ip   = "192.168.0.43";
            int    port = 6000;

            NetWorkManage s_NetWorkManage = NetWorkManage.getInstance();
            s_NetWorkManage.setHostPort(ip, port);
            if (!s_NetWorkManage.Connect())
            {
                Debug.Log("服务器连接失败,请检查网络!");
                return;
            }
        }

        if (GUI.Button(new Rect(150, 10, 100, 50), "登陆"))
        {
            //登录请求
            Debug.Log("登录请求");

            Msg_2_2 msg = new Msg_2_2();
            msg.aid    = "Test02"; //先写死角色名
            msg.zoneId = 1;        //先写死1

            SendDataStruct data = new SendDataStruct();
            data.cmd      = 2;
            data.dest     = 2;
            data.instance = msg;

            //NetWorkManage.SendData(2, 2, msg);
            NetWorkManage.SendData(data);
        }

        if (GUI.Button(new Rect(350, 10, 100, 50), "login"))
        {
            //登录请求
            Debug.Log("login界面");
            GameObject obj = UILayerManage.getInstance().CreateRoot("UILogin", "UILogin");
        }

        if (GUI.Button(new Rect(500, 10, 100, 50), "抽象工厂模式"))
        {
            IProtocolFactory factory = new ProtocolFactory();

            factory.createProtocolType1().DeserializeData(null);
            factory.createProtocolType2().DeserializeData(null);
        }
    }
Beispiel #4
0
 public void preFireBnt(GameObject obj)
 {
     if ("netBnt" == obj.name)
     {
         Msg_2_2 msg = new Msg_2_2();
         msg.aid    = "Test02"; //先写死角色名
         msg.zoneId = 1;        //先写死1
         NetWorkManage.SendData <Msg_2_2>(2, 2, msg);
     }
     else
     {
         UILayerManage.getInstance().RemoveLayer(gameObject);
     }
 }
Beispiel #5
0
 public void preFireBnt(GameObject obj)
 {
     if (LOGINBTN0 == obj.name)
     {
         Msg_2_2 msg = new Msg_2_2();
         msg.aid    = "Test02"; //先写死角色名
         msg.zoneId = 1;        //先写死1
         //NetWorkManage.SendData<Msg_2_2>(2, 2, msg);
     }
     else if (LOGINBTN1 == obj.name)
     {
         UILayerManage.getInstance().CreateAndAdd("UIHeroUP", "UIHeroUP", false);
     }
     else if (LOGINBTN2 == obj.name)
     {
         Debug.Log("我我我");
     }
 }