public void Init(Loading loadingScript) { mLoadingCom = loadingScript; for (int i = 0; i < mPlayerOtherMeshs.Length; i++) { if (mPlayerOtherMeshs.Length > i && mPlayerOtherMeshs[i] != null) { mPlayerOtherAnimators[i] = mPlayerOtherMeshs[i].GetComponent <Animator>(); } } for (int i = 0; i < mPlayerMeshArray.Length; i++) { if (mPlayerMeshArray.Length > i && mPlayerMeshArray[i] != null) { mPlayerAnimators[i] = mPlayerMeshArray[i].GetComponent <Animator>(); } } SetActiveLinkNameParent(false); SetAcitveStartBt(false); //SetPlayerUITexture(0); SetPlayerUIMesh(0); SetActiveUICreateSever(true); SetActiveUISeverWeiHu(false); NetworkEvent.GetInstance().OnFailedToConnectToMasterServerEvent += OnFailedToConnectToMasterServerEvent; }
void Awake() { Debug.Log("SSGameRoot::Awake -> peerType " + Network.peerType + ", eGameMode " + SSGameCtrl.GetInstance().eGameMode); SSGameCtrl.GetInstance().mSSGameRoot = this; NetworkServerNet.GetInstance().mNetworkRootGame = mNetworkRootGame; switch (SSGameCtrl.GetInstance().eGameMode) { case NetworkRootMovie.GameMode.Null: case NetworkRootMovie.GameMode.NoLink: { mSSGameDataManage.mGameData.SpawnPlayer(0); mSSGameDataManage.mGameData.SpawnNpc(1); mSSGameDataManage.mGameData.SpawnNpc(2); mSSGameDataManage.mGameData.SpawnNpc(3); mUIController.SetActiveUIRoot(true); break; } case NetworkRootMovie.GameMode.Link: { mUIController.SetActiveUIRoot(false); mSSTimeUpCom = gameObject.AddComponent <SSTimeUpCtrl>(); mSSTimeUpCom.OnTimeUpOverEvent += OnTimeUpOverNotConnectEvent; mSSTimeUpCom.Init(35f); break; } } NetworkEvent.GetInstance().OnServerInitializedEvent += OnServerInitializedEvent; NetworkEvent.GetInstance().OnPlayerConnectedEvent += OnPlayerConnectedEvent; NetworkEvent.GetInstance().OnConnectedToServerEvent += OnConnectedToServerEvent; NetworkEvent.GetInstance().OnFailedToConnectToMasterServerEvent += OnFailedToConnectToMasterServerEvent; }
void OnConnectedToServer() { Debug.Log("OnConnectedToServer -> appLevel " + Application.loadedLevel); if (mNetworkRootGame != null) { //游戏场景. NetworkEvent.GetInstance().OnConnectedToServerTrigger(); } }
void OnFailedToConnectToMasterServer(NetworkConnectionError info) { Debug.Log("Could not connect to master server: " + info); switch (info) { case NetworkConnectionError.CreateSocketOrThreadFailure: { break; } default: { NetworkEvent.GetInstance().OnFailedToConnectToMasterServerTrigger(); break; } } }
void Start() { if (PlayerControllerForMoiew.GetInstance() != null) { PlayerControllerForMoiew.GetInstance().mLoadingCom = this; } if (NetworkServerNet.GetInstance() != null) { NetworkServerNet.GetInstance().mRequestMasterServer.SetIsNetScene(true); } if (IsLuPingTest) { gameObject.SetActive(false); } //m_MovieTex.loop = true; //m_MovieTex.Play(); m_HasBegin = false; GameMode = ReadGameInfo.GetInstance().ReadGameStarMode(); if (GameMode == ReadGameInfo.GameMode.Oper.ToString()) { m_FreeTexture.enabled = false; CoinNumSet = ReadGameInfo.GetInstance().ReadStarCoinNumSet(); InsertCoinNum = ReadGameInfo.GetInstance().ReadInsertCoinNum(); CoinNumSetTex.spriteName = CoinNumSet; m_InserNum = Convert.ToInt32(InsertCoinNum); UpdateInsertCoin(); UpdateTex(); } else { m_ToubiObj.SetActive(false); m_IsBeginOk = true; m_FreeTexture.enabled = true; } m_Loading.SetActive(false); InputEventCtrl.GetInstance().mListenPcInputEvent.ClickSetEnterBtEvent += ClickSetEnterBtEvent; InputEventCtrl.GetInstance().mListenPcInputEvent.ClickStartBtOneEvent += ClickStartBtOneEvent; NetworkEvent.GetInstance().OnRpcSendLoadLevelMsgEvent += OnRpcSendLoadLevelMsgEvent; }
void OnDisconnectedFromServer(NetworkDisconnection info) { Debug.Log("OnDisconnectedFromServer -> info is " + info + ", peerType " + Network.peerType); switch (info) { case NetworkDisconnection.Disconnected: { if (Network.peerType == NetworkPeerType.Client) { RemoveClientHost(NetworkDisconnection.Disconnected); if (NetworkRootMovie.GetInstance() != null) { //循环动画场景中,玩家是客户端时需要重置masterServer信息. NetworkEvent.GetInstance().OnFailedToConnectToMasterServerTrigger(); } } break; } } }
void OnPlayerConnected(NetworkPlayer playerNet) { Debug.Log("NetworkServerNet::OnPlayerConnected -> ip " + playerNet.ipAddress + ", appGameLevel " + Application.loadedLevel); if (NetworkRootMovie.GetInstance() != null) { //循环动画场景. if (NetworkRootMovie.GetInstance().mNetworkRpcMsgScript != null) { NetworkRootMovie.GetInstance().mNetworkRpcMsgScript.NetSetSpawnPlayerIndex(playerNet, Network.connections.Length); } LinkServerPlayerNum_Movie = Network.connections.Length; } if (mNetworkRootGame != null) { //游戏场景. LinkServerPlayerNum_Game = Network.connections.Length; NetworkEvent.GetInstance().OnPlayerConnectedTrigger(); } }
void OnServerInitialized() { Debug.Log("OnServerInitialized -> appLevel " + Application.loadedLevel); IsCreateServer = true; if (NetworkRootMovie.GetInstance() != null) { //循环动画场景. LinkServerPlayerNum_Movie = 0; //初始化. LinkServerPlayerNum_Game = 0; //重置. SetIndexSpawnPlayer(0); NetworkRootMovie.GetInstance().CreateNetworkRpc(); } if (mNetworkRootGame != null) { //游戏场景. SetIndexSpawnPlayer(0); NetworkEvent.GetInstance().OnServerInitializedTrigger(); } }
void RpcSendLoadLevelMsg(int levelVal) { NetworkEvent.GetInstance().OnRpcSendLoadLevelMsgTrigger(levelVal); }