Exemple #1
0
    // Update is called once per frame
    void Update()
    {
        string query;

        if (!ready && !sent)
        {
            query = "S_READY:" + client.nickName;
            client.SendData(query);
            sent  = true;
            query = null;
        }

        string toExecute = client.ReceiveData();

        if (toExecute != null)
        {
            string[] isValidCommand = toExecute.Split(':');

            if (opcodesPtr.ContainsKey(isValidCommand[0]))
            {
                opcodesPtr[isValidCommand[0]](isValidCommand);
            }
            toExecute = null;
        }

        if (ready && Input.GetKeyDown(KeyCode.Escape))
        {
            menu.SetActive(true);
            Cursor.visible = true;
        }

        if (ready && !end)
        {
            StartMusic();
            if (Physics.Raycast(player_body_transform.position, Vector3.down, 0.6f)) // isGrounded
            {
                float   fVerticalForce   = Input.GetAxis("Vertical") * (bIsOnAccelerator ? m_fAcceleratorSpeed : speed);
                Vector3 vMouvementVector = transform.rotation * new Vector3(0.0f, 0.0f, fVerticalForce) * Time.deltaTime;

                player_body.AddForce(vMouvementVector);
                player_body.MoveRotation(camera.rotation);
            }
            if (showCountdown.activeSelf)
            {
                showCountdown.SetActive(false);
            }
        }

        time += Time.deltaTime;

        if (time >= interpolationPeriod)
        {
            time = time - interpolationPeriod;

            query  = "S_MOVEMENT:" + client.nickName + ':';
            query += transform.position.x.ToString() + ':' + transform.position.y.ToString() + ':' + transform.position.z.ToString();
            client.SendData(query);
            query = null;
        }
    }
Exemple #2
0
        private static void SendAll(ClientInfo client)
        {
            MessageModel _sendData = new MessageModel();

            _sendData.Type       = MessageType.UpdateAll;
            _sendData.Token      = client.Token;
            _sendData.RemotePort = client.RemotePort;

            UpdateAllMessage message = new UpdateAllMessage()
            {
                PlayerState  = MediaController.Current.CurrentPlayer.CurrentState.ToString(),
                TrackIndex   = MediaController.Current.CurrentPlayingIndex,
                SeekPosition = MediaController.Current.CurrentPlayer.Position,
                Volume       = MediaController.Current.CurrentPlayer.Volume
            };

            List <MusicInfo> playlist = new List <MusicInfo>();

            foreach (var item in MediaController.Current.SongList)
            {
                playlist.Add(new MusicInfo()
                {
                    Artist   = item.Artist,
                    Title    = item.Title,
                    Duration = item.Duration
                });
            }
            message.Playlist = playlist;

            string json = JsonHelper.ToJson(message);

            _sendData.Content       = CryptographicBuffer.ConvertStringToBinary(json, BinaryStringEncoding.Utf8);
            _sendData.ContentLength = _sendData.Content.Capacity;
            UDPClient.SendData(client.HostName, client.RemotePort.ToString(), MessageModel.FromMessage(_sendData));
        }
Exemple #3
0
 private static void SendData(MessageModel _sendData)
 {
     foreach (var client in UDPServer.Current.ClientList)
     {
         _sendData.Token      = client.Token;
         _sendData.RemotePort = client.RemotePort;
         UDPClient.SendData(client.HostName, client.RemotePort.ToString(), MessageModel.FromMessage(_sendData));
     }
 }
Exemple #4
0
    private void sendPosition(string[] chainList)
    {
        string query = "S_GETCURRENTPOSITION:";

        float x = transform.position.x;
        float y = transform.position.y;
        float z = transform.position.z;

        query += client.nickName + ':' + x + ':' + y + ':' + z;

        client.SendData(query);
    }
Exemple #5
0
        private void Update()
        {
            if (!connected && !sent)
            {
                string query = "S_LOGIN:";
                query += client.nickName + ':' + client.pass;
                client.SendData(query);
                sent = true;
            }

            string toExecute = client.ReceiveData();

            if (toExecute != null)
            {
                string[] isValidCommand = toExecute.Split(':');

                if (opcodesPtr.ContainsKey(isValidCommand[0]))
                {
                    opcodesPtr[isValidCommand[0]](isValidCommand);
                }
                toExecute = null;
            }

            if (connected)
            {
                if (Input.GetKeyDown(KeyCode.Escape))
                {
                    if (menuNumber == 2 || menuNumber == 7 || menuNumber == 8)
                    {
                        GoBackToMainMenu();
                        ClickSound();
                    }

                    else if (menuNumber == 3 || menuNumber == 4 || menuNumber == 5)
                    {
                        GoBackToOptionsMenu();
                        ClickSound();
                    }

                    else if (menuNumber == 6) //CONTROLS MENU
                    {
                        GoBackToGameplayMenu();
                        ClickSound();
                    }
                }

                if (Input.GetKeyDown(KeyCode.Return) || Input.GetKeyDown(KeyCode.KeypadEnter))
                {
                    SendInvite();
                    ClickSound();
                }
            }
        }
Exemple #6
0
 private bool UDPClient_dataSend_EventDataSend(byte[] data)
 {
     return(UDPClient.SendData(data));
 }