Exemplo n.º 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();
 }
    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);
        }
    }
Exemplo n.º 3
0
    public void PrepareEnd(bool midway)
    {
        OnPrepareEnd.Invoke();
        preparing = false;

        Battle.localPlayerBattleInfo.SetPlayerEnable(true);
        Battle.UpdateFriendlyMark();
        Battle.freezing = false;
    }
Exemplo n.º 4
0
    public static void Trigger(NetEventType eventName, NetEventArgs args)
    {
        NetworkEvent e = null;

        if (instance.events.TryGetValue(eventName, out e))
        {
            e.Invoke(args);
        }
    }
Exemplo n.º 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();
    }
Exemplo n.º 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();
    }
Exemplo n.º 7
0
 public void Back()
 {
     if (applyBtn.interactable)
     {
         confirmWindow.SetActive(true);
     }
     else
     {
         OnClosePanel.Invoke();
     }
 }
Exemplo n.º 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;
        //}
    }
Exemplo n.º 9
0
 public void CheckInternet()
 {
     if (Application.internetReachability == NetworkReachability.NotReachable)
     {
         // if no network
         onNoNetwork.Invoke();
     }
     else
     {
         // check game version
         StartCoroutine(CheckVersion());
     }
 }
Exemplo n.º 10
0
    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;
                }
            }
        }
Exemplo n.º 12
0
    public override void SwitchPanel(bool isOpen)
    {
        if (isOpen)
        {
            base.SwitchPanel(isOpen);
            OnOpenSettingPanel.Invoke();

            Cursor.lockState = CursorLockMode.None;
            Cursor.visible   = true;
        }
        else
        {
            Back();
        }
    }
Exemplo n.º 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);
        }
    }
Exemplo n.º 14
0
        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
            }
        }
Exemplo n.º 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("游戏版本旧");
        }
    }
Exemplo n.º 16
0
 public override void OnDisconnectedFromPhoton()
 {
     onDisconnFromPhoton.Invoke();
 }
Exemplo n.º 17
0
 public override void OnJoinedLobby()
 {
     onJoinedLobby.Invoke();
     OpenMenu(0);
 }
Exemplo n.º 18
0
 public void OpenPanel()
 {
     StartCoroutine(WaitProcess());
     OnOpenPanel.Invoke();
 }
Exemplo n.º 19
0
 public void OnTimerComplate()
 {
     OnTimeOut.Invoke();
 }
Exemplo n.º 20
0
 // Primatry Connection Operation-------------------------------------------------------
 public override void OnConnectedToMaster()
 {
     onConnToMaster.Invoke();
 }
Exemplo n.º 21
0
 public void JoinLobby()
 {
     onStartJoinLobby.Invoke();
     PhotonNetwork.JoinLobby();
 }
Exemplo n.º 22
0
 public void StartConnect()
 {
     onConnStart.Invoke();
     PhotonNetwork.ConnectUsingSettings(version.value);
 }
Exemplo n.º 23
0
 // Photon Server Connection Operation--------------------------------------------------
 // 连接成功
 public override void OnConnectedToPhoton()
 {
     onConnToPhoton.Invoke();
 }
Exemplo n.º 24
0
 public void ReceiveBytes(byte[] data)
 {
     onReceivedBytes.Invoke(data);
 }
Exemplo n.º 25
0
 // 连接失败
 public override void OnFailedToConnectToPhoton(DisconnectCause cause)
 {
     onConnToPhotonFiled.Invoke();
 }
Exemplo n.º 26
0
 public override void OnConnectionFail(DisconnectCause cause)
 {
     onConnToMasterFiled.Invoke();
 }
Exemplo n.º 27
0
 public override void OnLeftLobby()
 {
     onLeftLobby.Invoke();
 }