public void ArrowLeftClick() { currentIndex--; if (currentIndex < 0) { currentIndex = options.Count - 1; } if (options[currentIndex] != null) { content.text = options[currentIndex]; this.changed = true; } OnChange.Invoke(); OnChangeCall?.Invoke(); }
private IEnumerator DownloadFile(Tile tile, RequestType requestType) { string request = null; switch (requestType) { case RequestType.OsmFile: request = BuildOsmFileRequest(tile); break; case RequestType.GeoJSON: request = BuildGeoJSONRequest(tile); break; } UnityWebRequest www = UnityWebRequest.Get(request); yield return(www.SendWebRequest()); if (www.isNetworkError || www.isHttpError || www.isHttpError) { Debug.LogError(www.error); } else if (www.isHttpError) { Debug.LogError("Invalid response received"); } else { OnDowloaded.Invoke(tile, requestType, www.downloadHandler.text); } }
public void PrepareEnd(bool midway) { OnPrepareEnd.Invoke(); preparing = false; Battle.localPlayerBattleInfo.SetPlayerEnable(true); Battle.UpdateFriendlyMark(); Battle.freezing = false; }
public static void Trigger(NetEventType eventName, NetEventArgs args) { NetworkEvent e = null; if (instance.events.TryGetValue(eventName, out e)) { e.Invoke(args); } }
// Lobby Operation----------------------------------------------------------------- public override void OnJoinedLobby() { PhotonNetwork.player.NickName = Battle.playerBasicSave.playerName + "#" + DateTime.Now.GetHashCode().ToString().Substring(0, 4); PhotonNetwork.player.SetCustomProperties(new Hashtable() { { "battle", "0#0#0#0" }, { "team", "0" } }); onJoinedLobby.Invoke(); }
IEnumerator RunRecieve() { byte[] outbuf = new byte[PACKET_SIZE]; int nbytes = 0; NetworkStream stream = mClient.GetStream(); while (isWaitReceive) { yield return(new WaitForEndOfFrame()); if (!stream.DataAvailable) { continue; } try { nbytes = stream.Read(outbuf, 0, outbuf.Length); mFifoBuffer.Push(outbuf, nbytes); while (true) { byte[] buf = mFifoBuffer.readSize(mFifoBuffer.GetSize()); bool isError = false; ICD.stHeader msg = ICD.stHeader.Parse(buf, ref isError); if (isError) { mFifoBuffer.Clear(); } if (msg == null) { break; } else { mFifoBuffer.Pop(msg.head.len); } IPEndPoint ep = (IPEndPoint)mClient.Client.RemoteEndPoint; string ipAddress = ep.Address.ToString(); int port = ep.Port; string info = ipAddress + ":" + port.ToString(); if (mOnRecv != null) { mOnRecv.Invoke(msg, info); } } } catch (Exception ex) { Debug.Log(ex.ToString()); } } mFifoBuffer.Clear(); stream.Close(); }
public void Back() { if (applyBtn.interactable) { confirmWindow.SetActive(true); } else { OnClosePanel.Invoke(); } }
public override void OnJoinedRoom() { onJoinedRoom.Invoke(); this.UpdatePlayerNumber(); StartBattleCheck(); // test code if (this.single) { onPlayStart.Invoke(); async = PhotonNetwork.LoadLevelAsync("Battle002"); async.allowSceneActivation = true; Hashtable p = new Hashtable(); p.Add("team", "1"); PhotonNetwork.playerList[0].SetCustomProperties(p, null, false); } //if (PhotonNetwork.isMasterClient) //{ // PhotonNetwork.room.IsVisible = false; //} }
public void CheckInternet() { if (Application.internetReachability == NetworkReachability.NotReachable) { // if no network onNoNetwork.Invoke(); } else { // check game version StartCoroutine(CheckVersion()); } }
public void Back() { if (applyBtn.interactable) { confirmWindow.SetActive(true); } else { OnCloseSettingPanel.Invoke(); Cursor.lockState = CursorLockMode.Locked; Cursor.visible = false; } }
private void ListenerThread() { _receivingUdpClient.ExclusiveAddressUse = false; _receivingUdpClient.Connect(new IPEndPoint(IPAddress.None, ClientPort)); while (true) { try { IPEndPoint remoteIpEndPoint = new IPEndPoint(IPAddress.Any, ClientPort); // Blocks until a message returns on this socket from a remote host. Byte[] receiveBytes = _receivingUdpClient.Receive(ref remoteIpEndPoint); if (receiveBytes.Length == 0) { return; } NetCommand cmd = NetCommand.Parse(receiveBytes); IPAddress sender = remoteIpEndPoint.Address; lock (_incomingQueue) { _incomingQueue.Push(new NetPackage() { NetCommand = cmd, Sender = sender }); Debug.WriteLine($"Queue count: {_incomingQueue.Count}"); } Debug.WriteLine("Network data received!"); if (NetworkEvent != null) { Debug.WriteLine("Invoking event handlers: " + NetworkEvent.GetInvocationList().Length); } else { Debug.WriteLine($"No event handlers attached! Read from queue manually"); } NetworkEvent?.Invoke(cmd, sender); } catch (SocketException e) { Debug.WriteLine(e); throw; } } }
public override void SwitchPanel(bool isOpen) { if (isOpen) { base.SwitchPanel(isOpen); OnOpenSettingPanel.Invoke(); Cursor.lockState = CursorLockMode.None; Cursor.visible = true; } else { Back(); } }
public void GameEnd() { this.preparing = true; Battle.localPlayerBattleInfo.SetPlayerEnable(false); Battle.freezing = true; Cursor.lockState = CursorLockMode.None; Cursor.visible = true; OnGameOver.Invoke(); if (PhotonNetwork.isMasterClient) { PhotonNetwork.room.IsOpen = false; Battle.localPlayerBattleInfo.photonView.RPC("SyncGameOver", PhotonTargets.Others, this.lastKillCamp); } }
private void AcceptConnectionCallback(IAsyncResult result) { try { WinsockClient Client = new WinsockClient(this, Connection.EndAccept(result), BufferSize, CreatePacketCipher()); if (OnClientConnected != null) { OnClientConnected.Invoke(Client, null); } Client.BeginReceive(); Connection.BeginAccept(new AsyncCallback(AcceptConnectionCallback), null); } catch (Exception exception) { #if DEBUG Console.WriteLine(exception.ToString()); #endif } }
// 从网络获取版本设置,旧版本不进行网络连接 IEnumerator CheckVersion() { WWW w = new WWW(versionAddress.value); while (!w.isDone) { yield return(new WaitForEndOfFrame()); } var versionSettting = JsonConvert.DeserializeObject <VersionSetting>(w.text); if (versionSettting.version.Equals(version.value)) { StartConnect(); } else { onVersionOld.Invoke(); Debug.Log("游戏版本旧"); } }
public override void OnDisconnectedFromPhoton() { onDisconnFromPhoton.Invoke(); }
public override void OnJoinedLobby() { onJoinedLobby.Invoke(); OpenMenu(0); }
public void OpenPanel() { StartCoroutine(WaitProcess()); OnOpenPanel.Invoke(); }
public void OnTimerComplate() { OnTimeOut.Invoke(); }
// Primatry Connection Operation------------------------------------------------------- public override void OnConnectedToMaster() { onConnToMaster.Invoke(); }
public void JoinLobby() { onStartJoinLobby.Invoke(); PhotonNetwork.JoinLobby(); }
public void StartConnect() { onConnStart.Invoke(); PhotonNetwork.ConnectUsingSettings(version.value); }
// Photon Server Connection Operation-------------------------------------------------- // 连接成功 public override void OnConnectedToPhoton() { onConnToPhoton.Invoke(); }
public void ReceiveBytes(byte[] data) { onReceivedBytes.Invoke(data); }
// 连接失败 public override void OnFailedToConnectToPhoton(DisconnectCause cause) { onConnToPhotonFiled.Invoke(); }
public override void OnConnectionFail(DisconnectCause cause) { onConnToMasterFiled.Invoke(); }
public override void OnLeftLobby() { onLeftLobby.Invoke(); }