Exemplo n.º 1
0
    // Use this for initialization
    void Start()
    {
        InputField inputfield = addressObj.GetComponent <InputField> ();
//		Text inputAdress = addressObj.transform.Find ("Text").GetComponent<Text> ();
        var record = PlayerPrefs.GetString("address");

        if (!string.IsNullOrEmpty(record))
        {
            print("address record: " + record);
            inputfield.text = record;
        }
        var btn = connectBtn.GetComponent <Button> ();

        btn.onClick.AddListener(() => {
            if (!string.IsNullOrEmpty(inputfield.text))
            {
                PlayerPrefs.SetString("address", inputfield.text);
                this.gameObject.SetActive(false);
                Netmanager.conf    = NetworkConfig.GetInstance();
                Netmanager.conf.ip = inputfield.text;
                var tt             = this.transform.parent.Find("addresshold").GetComponent <Text> ();
                tt.text            = Netmanager.conf.ip;
                Netmanager.ToConnect();
                //==
                ingameObj.SetActive(true);
            }
        });
    }
Exemplo n.º 2
0
    //	public static NetworkConfig conf_UDP;
    //init
    public void init()
    {
        // Use this for initialization
        NetConnection.MSG_haldlerPool = new System.Collections.Generic.Dictionary <ushort, Type> ()
        {
            { (ushort)NetCode.CreateSelf, typeof(Rsp_CreateSelf) },
            { (ushort)NetCode.CreateOthers, typeof(Rsp_CreateOthers) },
            { (ushort)NetCode.UDP_UpdateStatus, typeof(Rsp_UpdateStatus) },           //UDP
            { (ushort)NetCode.BeatHeart, typeof(Rsp_HeartBeating) },
            { (ushort)NetCode.LeaveOffOthers, typeof(Rsp_LeaveOffOthers) },

            { (ushort)NetCode.Move, typeof(Rsp_StateUpdateMove) },
            { (ushort)NetCode.TabSwitch, typeof(Rsp_StatusUpdateTabSwitch) },
            { (ushort)NetCode.Sprint, typeof(Rsp_StatusUpdateSprint) },
            { (ushort)NetCode.Jump, typeof(Rsp_StatusUpdateJump) },
            { (ushort)NetCode.ExitGame, typeof(Rsp_StatusUpdateExitGame) },
        };
        NetConnection_UDP.MSG_haldlerPool = NetConnection.MSG_haldlerPool;

        DebugTool.setDebug(true);
        DebugTool.LogYellow("直接跳过登陆环节,此项目暂未添加登陆");
        LoginInfo.LoginState    = true;
        LoginInfo.loginInfo [0] = 1;
        LoginInfo.loginInfo [1] = 1;
        if (conf == null)
        {
            conf = NetworkConfig.GetInstance();
            //		conf.ip = "192.168.78.226";
            conf.ip = "127.0.0.1";
            //		conf.ip = "172.20.6.11";
            //		conf.ip = "192.168.1.106";
            //		conf.ip = "172.30.58.7";
        }
        conf.port               = 42020;
        conf.write_timeout      = 2000;
        conf.receiv_buffer_size = 1024;
        conf.connect_timeout    = 2000;
        //===============================
        //		if (conf_UDP == null) {
        //			conf_UDP = NetworkConfig.GetInstance ();
        //			//		conf.ip = "192.168.78.226";
        //			conf_UDP.ip = "127.0.0.1";
        //			//		conf.ip = "172.20.6.11";
        //			//		conf.ip = "192.168.1.106";
        //			//		conf.ip = "172.30.58.7";
        //		}
        //		conf_UDP.port = 2020;
        //		conf_UDP.write_timeout = 2000;
        //		conf_UDP.receiv_buffer_size = 1024;
        //		conf_UDP.connect_timeout = 2000;

        //Array.Copy(;
        DebugTool.LogRed("init Net :" + conf.ip);
    }