コード例 #1
0
 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();
 }
コード例 #2
0
    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);
        }
    }
コード例 #3
0
    public void PrepareEnd(bool midway)
    {
        OnPrepareEnd.Invoke();
        preparing = false;

        Battle.localPlayerBattleInfo.SetPlayerEnable(true);
        Battle.UpdateFriendlyMark();
        Battle.freezing = false;
    }
コード例 #4
0
    public static void Trigger(NetEventType eventName, NetEventArgs args)
    {
        NetworkEvent e = null;

        if (instance.events.TryGetValue(eventName, out e))
        {
            e.Invoke(args);
        }
    }
コード例 #5
0
    // 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();
    }
コード例 #6
0
    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();
    }
コード例 #7
0
 public void Back()
 {
     if (applyBtn.interactable)
     {
         confirmWindow.SetActive(true);
     }
     else
     {
         OnClosePanel.Invoke();
     }
 }
コード例 #8
0
    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;
        //}
    }
コード例 #9
0
 public void CheckInternet()
 {
     if (Application.internetReachability == NetworkReachability.NotReachable)
     {
         // if no network
         onNoNetwork.Invoke();
     }
     else
     {
         // check game version
         StartCoroutine(CheckVersion());
     }
 }
コード例 #10
0
    public void Back()
    {
        if (applyBtn.interactable)
        {
            confirmWindow.SetActive(true);
        }
        else
        {
            OnCloseSettingPanel.Invoke();

            Cursor.lockState = CursorLockMode.Locked;
            Cursor.visible   = false;
        }
    }
コード例 #11
0
        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;
                }
            }
        }
コード例 #12
0
    public override void SwitchPanel(bool isOpen)
    {
        if (isOpen)
        {
            base.SwitchPanel(isOpen);
            OnOpenSettingPanel.Invoke();

            Cursor.lockState = CursorLockMode.None;
            Cursor.visible   = true;
        }
        else
        {
            Back();
        }
    }
コード例 #13
0
    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);
        }
    }
コード例 #14
0
ファイル: ServerSocket.cs プロジェクト: uvbs/conquerserver
        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
            }
        }
コード例 #15
0
    // 从网络获取版本设置,旧版本不进行网络连接
    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("游戏版本旧");
        }
    }
コード例 #16
0
 public override void OnDisconnectedFromPhoton()
 {
     onDisconnFromPhoton.Invoke();
 }
コード例 #17
0
 public override void OnJoinedLobby()
 {
     onJoinedLobby.Invoke();
     OpenMenu(0);
 }
コード例 #18
0
 public void OpenPanel()
 {
     StartCoroutine(WaitProcess());
     OnOpenPanel.Invoke();
 }
コード例 #19
0
 public void OnTimerComplate()
 {
     OnTimeOut.Invoke();
 }
コード例 #20
0
 // Primatry Connection Operation-------------------------------------------------------
 public override void OnConnectedToMaster()
 {
     onConnToMaster.Invoke();
 }
コード例 #21
0
 public void JoinLobby()
 {
     onStartJoinLobby.Invoke();
     PhotonNetwork.JoinLobby();
 }
コード例 #22
0
 public void StartConnect()
 {
     onConnStart.Invoke();
     PhotonNetwork.ConnectUsingSettings(version.value);
 }
コード例 #23
0
 // Photon Server Connection Operation--------------------------------------------------
 // 连接成功
 public override void OnConnectedToPhoton()
 {
     onConnToPhoton.Invoke();
 }
コード例 #24
0
 public void ReceiveBytes(byte[] data)
 {
     onReceivedBytes.Invoke(data);
 }
コード例 #25
0
 // 连接失败
 public override void OnFailedToConnectToPhoton(DisconnectCause cause)
 {
     onConnToPhotonFiled.Invoke();
 }
コード例 #26
0
 public override void OnConnectionFail(DisconnectCause cause)
 {
     onConnToMasterFiled.Invoke();
 }
コード例 #27
0
 public override void OnLeftLobby()
 {
     onLeftLobby.Invoke();
 }