void Connect()
    {
        if (isEnable)
        {
            if (InRoom.GetInRoomInstantiate().ServerConnected)
            {
                InRoom.GetInRoomInstantiate().SendID(BtnGameManager.yt.Rows[0]["PlayerID"].YuanColumnText, BtnGameManager.yt.Rows[0]["ProID"].YuanColumnText, BtnGameManager.yt.Rows[0]["PlayerName"].YuanColumnText, true, PlayerPrefs.GetString("Language", "CH"), SystemInfo.deviceUniqueIdentifier, PlayerUtil.mapInstanceID, playerPostion.x, playerPostion.y, playerPostion.z);    //,BtnGameManagerBack.teaminstensid);
                isConnecting        = false;
                lblConnectInfo.text = "";
                lblConnectInfo.gameObject.active = false;
                CancelInvoke("Connect");
            }
            //Debug.Log ("------------------:"+time%5);
            if ((time % 100) == 0 || time == 0)
            {
                ZealmConnector.closeConnection();
                //InRoom.GetInRoomInstantiate().peer.Disconnect();
                //while(InRoom.GetInRoomInstantiate ().peer.PeerState!=ExitGames.Client.Photon.PeerStateValue.Disconnected)
                //{
                //	yield return new WaitForSeconds(0.1f);
                //}
                try
                {
                    PhotonHandler.ShowLog("GameReonline");
                    InRoom.NewInRoomInstantiate().SetAddress(PlayerPrefs.GetString("InAppServerIP"));
                    InRoom.GetInRoomInstantiate().ServerApplication  = PlayerPrefs.GetString("InAppServer");
                    InRoom.GetInRoomInstantiate().btnGameManagerBack = this.btnGameManagerBack;
                    InRoom.GetInRoomInstantiate().SM = this.sendManager;
                    InRoom.GetInRoomInstantiate().Connect();
                    reTime++;
                }
                catch (System.Exception ex)
                {
                    Debug.LogError(ex.ToString());
                }
            }
            if (reTime >= 5)
            {
                if (isStart)
                {
                    //uiCon.SendMessage("UIDisconnect", SendMessageOptions.DontRequireReceiver);
                    lblConnectInfo.text = StaticLoc.Loc.Get("info356");
                }
                else
                {
                    lblConnectInfo.text = StaticLoc.Loc.Get("info357");
                }
                CancelInvoke("Connect");

                isStart = false;
                //PanelStatic.StaticWarnings.warningAllEnter.Show (StaticLoc.Loc.Get("info358"),StaticLoc.Loc.Get("info649"));
                PanelStatic.StaticBtnGameManager.OffLine();
            }
            time++;
        }
    }
Esempio n. 2
0
    IEnumerator Connect()
    {
        if (isFastBtn)
        {
//			Debug.Log ("8888888888");
            mainMenuManage.btnCreatPlayerBack.invokMethodName  = "Back";
            mainMenuManage.btnCreatPlayerEnter.invokMethodName = "PlayerFastLogon";

            btnManage.AnimCamera.CrossFade("CameraToNewPlayer");
            btnManage.cameraStatus = BtnManager.CameraStatus.NewPlayer;
            mainMenuManage.isLogin = false;
            PlayerPrefs.SetString("InFastServer", this.applicationName);
            mainMenuManage.listMenu[4].transform.localScale = new Vector3(1, 1, 1);
            yuan.YuanClass.SwitchListOnlyOne(mainMenuManage.listMenu, 4, true, true);
//			Debug.Log ("99999999999");
            //mainMenuManage.YuanSetActive(mainMenuManage.btnSelectServerCreate, false);
        }
        else
        {
            outTime = 0;
            InvokeRepeating("ReOnline", 1, 1);
            if (!InRoom.GetInRoomInstantiate().ServerConnected)
            {
                PhotonHandler.ShowLog("ReOnlin");
                InRoom.NewInRoomInstantiate().SetAddress(this.applicationIp + ":" + this.applicationHost);
                InRoom.GetInRoomInstantiate().ServerApplication = this.applicationName;
                InRoom.GetInRoomInstantiate().Connect();
            }
            while (!InRoom.GetInRoomInstantiate().ServerConnected)
            {
                yield return(new WaitForSeconds(0.1f));
            }

            YuanUnityPhoton.YuanDispose();
            yuan.YuanClass.SwitchListOnlyOne(mainMenuManage.listMenu, 9, true, true);
            mainMenuManage.listMenu[9].SetActive(true);
            InRoom.GetInRoomInstantiate().GetPlayers(YuanUnityPhoton.GetYuanUnityPhotonInstantiate().userID, this.applicationName, "DarkSword2", "PlayerInfo");
            PlayerPrefs.SetString("InAppServer", this.applicationName);
            PhotonHandler.ShowLog("InAppServerIP Set:" + this.applicationIp);
            PlayerPrefs.SetString("InAppServerIP", InRoom.GetInRoomInstantiate().GetSvrAddress());
        }
    }
Esempio n. 3
0
    IEnumerator Connect()
    {
        if (txtServerIP.text != "")
        {
            //YuanUnityPhoton.GetYuanUnityPhotonInstantiate().peer.Disconnect();
            //while (YuanUnityPhoton.GetYuanUnityPhotonInstantiate().peer.PeerState != ExitGames.Client.Photon.PeerStateValue.Disconnected)
            //{
            //    yield return new WaitForSeconds(1);
            //}
            //YuanUnityPhoton.GetYuanUnityPhotonInstantiate().ServerAddress = txtServerIP.text + ":5059";
            //YuanUnityPhoton.GetYuanUnityPhotonInstantiate().Connect();
            //YuanUnityPhoton.GetYuanUnityPhotonInstantiate().peer.Disconnect();
            //YuanUnityPhoton.GetYuanUnityPhotonInstantiate().peer = new ExitGames.Client.Photon.PhotonPeer(YuanUnityPhoton.GetYuanUnityPhotonInstantiate());
            //YuanUnityPhoton.GetYuanUnityPhotonInstantiate().peer.Connect(txtServerIP.text+":5059", "YuanPhotonServerRoom");
            //InRoom.GetInRoomInstantiate().peer.Disconnect();
            //InRoom.GetInRoomInstantiate().peer = new ExitGames.Client.Photon.PhotonPeer(InRoom.GetInRoomInstantiate());

            YuanUnityPhoton.GetYuanUnityPhotonInstantiate().peer.Disconnect();
            YuanUnityPhoton.NewYuanUnityPhotonInstantiate().ServerAddress = txtServerIP.text + ":5059";
            YuanUnityPhoton.GetYuanUnityPhotonInstantiate().MMManage      = this.mmManage;
            YuanUnityPhoton.GetYuanUnityPhotonInstantiate().tableRead     = this.tableRead;
            YuanUnityPhoton.GetYuanUnityPhotonInstantiate().Connect();
            InRoom.GetInRoomInstantiate().peer.Disconnect();
            InRoom.NewInRoomInstantiate();
            //InRoom.GetInRoomInstantiate().Connect();

            ServerSettings.DefaultServerAddress = txtServerIP.text + ":5055";
            PhotonNetwork.Disconnect();
            while (PhotonNetwork.connectionState != ConnectionState.Disconnected)
            {
                yield return(new WaitForSeconds(0.5f));
            }
            PhotonNetwork.Connect(txtServerIP.text, 5055, "Master", "1.0");
            PlayerPrefs.SetString("TestServer", txtServerIP.text);
            PlayerPrefs.SetString("TestServerName", "YuanPhotonServerRoom");
        }
    }
Esempio n. 4
0
    /// <summary>
    /// InRoom服务器重连方法
    /// </summary>
    /// <returns>
    /// The in room.
    /// </returns>
    /// <param name='mNum'>
    /// 超时时间.
    /// </param>
    public IEnumerator ConnectInRoom(int mNum)
    {
        if (ZealmConnector.connection == null)
        //if(!InRoom.GetInRoomInstantiate ().ServerConnected)
        {
            InRoom.NewInRoomInstantiate().SetAddress(PlayerPrefs.GetString("InAppServerIP"));
            Debug.Log("ConnectInRoom:" + PlayerPrefs.GetString("InAppServerIP"));
            InRoom.GetInRoomInstantiate().ServerApplication  = PlayerPrefs.GetString("InAppServer");
            InRoom.GetInRoomInstantiate().btnGameManagerBack = BtnGameManagerBack.my;
            InRoom.GetInRoomInstantiate().SM = SendManager.my;
            InRoom.GetInRoomInstantiate().Connect();
            int tempNum = 0;
            while (true)
            {
                yield return(new WaitForSeconds(1));

                tempNum++;
                if (tempNum >= mNum || InRoom.GetInRoomInstantiate().ServerConnected)
                {
                    break;
                }
            }
        }
    }
Esempio n. 5
0
    IEnumerator Connect()
    {
        //  serverAddress = serverAddress2;
        tableRead.strInfo = StaticLoc.Loc.Get("meg0101");
        Ping ping    = new Ping(serverAddress.Split(':')[0]);
        Ping ping2   = new Ping(serverAddress2.Split(':')[0]);
        int  timeOut = 0;

        int p1 = 0;
        int p2 = 0;

        while (true)
        {
            if (ping.isDone || ping2.isDone)
            {
                break;
            }
            if (timeOut > 30)
            {
                break;
            }

            timeOut++;
            Debug.Log(string.Format("---------------------Ping:{0},{1};Ping2:{2},{3}", ping.isDone, ping.time, ping2.isDone, ping2.time));
            yield return(new WaitForSeconds(0.1f));
        }
        p1 = ping.time;
        p2 = ping2.time;
        Debug.Log(string.Format("---------------------PingEnd:{0},{1};Ping2:{2},{3}", ping.isDone, p1, ping2.isDone, p2));
        if (p1 == -1 && p2 == -1)
        {
            tableRead.strInfo = StaticLoc.Loc.Get("meg0096");
            //ShowConnectFail(StaticLoc.Loc.Get("meg0096")+StaticLoc.Loc.Get("meg0103"));

            tableRead.ReadTimeOut(StaticLoc.Loc.Get("meg0096") + StaticLoc.Loc.Get("meg0103"));
        }
        else if (p2 != -1 && p1 != -1)
        {
            if (p1 > p2)
            {
                serverAddress = serverAddress2;
            }
        }
        else if (p2 != -1)
        {
            serverAddress = serverAddress2;
        }

        ping.DestroyPing();
        ping2.DestroyPing();

        Debug.Log("===============ConnectIP:" + serverAddress);
        tableRead.strInfo = StaticLoc.Loc.Get("meg0095");
        //NGUIDebug.Log ("--------------------------RadyConnect");
        yuan.YuanClass.SwitchList(listBtnServer, false, true);
//		if(YuanUnityPhoton.GetYuanUnityPhotonInstantiate().ServerConnected)
//		{
//
//          //YuanUnityPhoton.GetYuanUnityPhotonInstantiate().peer.Disconnect();
//			ZealmConnector.closeConnection();
//			while(YuanUnityPhoton.GetYuanUnityPhotonInstantiate().ServerConnected)
//			{
//				yield return new WaitForSeconds(0.1f);
//			}
//		}
//
//			if(InRoom.GetInRoomInstantiate ().ServerConnected)
//			{
//		        //InRoom.GetInRoomInstantiate().peer.Disconnect();
//			ZealmConnector.closeConnection();
//				while(InRoom.GetInRoomInstantiate ().ServerConnected)
//				{
//					yield return new WaitForSeconds(0.1f);
//				}
//			}

        ZealmConnector.closeConnection();
        //try
        //{
        //NGUIDebug.Log ("-------------------------------IP:"+serverAddress);
        YuanUnityPhoton.NewYuanUnityPhotonInstantiate().ServerAddress = serverAddress;
//	        YuanUnityPhoton.NewYuanUnityPhotonInstantiate().ServerAddress = "117.131.207.219" + ":5059";
//        YuanUnityPhoton.NewYuanUnityPhotonInstantiate().ServerAddress = "192.168.1.100" + ":5059";
        YuanUnityPhoton.GetYuanUnityPhotonInstantiate().ServerApplication = "YuanPhotonServerRoom";
        YuanUnityPhoton.GetYuanUnityPhotonInstantiate().MMManage          = this.mmManage;
        YuanUnityPhoton.GetYuanUnityPhotonInstantiate().tableRead         = this.tableRead;
        //NGUIDebug.Log ("--------------------------StratConnect");

        YuanUnityPhoton.GetYuanUnityPhotonInstantiate().Connect();
        PhotonHandler.ShowLog("SetConnectionIP:" + serverAddress);
        PlayerPrefs.SetString("ConnectionIP", serverAddress);
        while (!YuanUnityPhoton.GetYuanUnityPhotonInstantiate().ServerConnected)
        {
            yield return(new WaitForSeconds(0.1f));
        }
        //NGUIDebug.Log ("--------------------------Connected");
        if (StartGame)
        {
            StartGame = false;
            YuanUnityPhoton.GetYuanUnityPhotonInstantiate().SetPlayerBehavior(yuan.YuanPhoton.ConsumptionType.GameSchedule, ((int)GameScheduleType.OpenGame).ToString(), SystemInfo.deviceUniqueIdentifier);
        }
//			Debug.Log("Con2222222");
        //}
        //catch(System.Exception ex)
        //{
        //Debug.LogError (ex.ToString ());
        //}

/**************************************************
 *      //	if(InRoom.GetInRoomInstantiate ().peer.PeerState==ExitGames.Client.Photon.PeerStateValue.Connected)
 *      //	{
 *  //      InRoom.GetInRoomInstantiate().peer.Disconnect();
 *      //		while(InRoom.GetInRoomInstantiate ().peer.PeerState!=ExitGames.Client.Photon.PeerStateValue.Disconnected)
 *      //		{
 *      //			yield return new WaitForSeconds(0.1f);
 *      //		}
 *      //	}
 *******************************************************/
        try
        {
            InRoom.NewInRoomInstantiate();
        }
        catch (System.Exception ex)
        {
            Debug.LogError(ex.ToString());
        }
        PhotonNetwork.Disconnect();
    }