Example #1
0
 private void RequestInput(float VInput , float HInput)
 {
     C2Request request = new C2Request(C2MessageType.Request_Input);
     request.putData("VInput",VInput);
     request.putData("HInput",HInput);
     this.SendRequest(request);
 }
Example #2
0
 void RequestSpawnItem(Vector3 spawnPos , string item)
 {
     C2Request request= new C2Request("Spawn" + item);
     request.putData("x",spawnPos.x);
     request.putData("y",spawnPos.y);
     request.putData("z",spawnPos.z);
     this.SendRequest(request);
 }
    public void SendClientAction(float VInput, float HInput , NetworkPlayer player)
    {
        C2Request request = new C2Request(C2MessageType.Request_ClientAction);
        request.putData("VInput", VInput);
        request.putData("HInput", HInput);
        request.putData("NetworkPlayer" , player);

        this.HandleRequest(request);
    }
 private void RequestMovement(float VInput, float HInput)
 {
     float liftForce = VInput * Time.deltaTime * upForce;
     float rotation = HInput * Time.deltaTime;
     C2Request request = new C2Request(C2MessageType.Request_Movement);
     request.putData("VForce", liftForce);
     request.putData("Rotation", rotation);
     this.SendRequest(request);
 }
    void OnGUI()
    {
        if (Network.peerType == NetworkPeerType.Disconnected){
            //We are currently disconnected: Not a client or host
            GUILayout.Label("Connection status: Disconnected");
            connectToIP = GUILayout.TextField(connectToIP, GUILayout.MinWidth(100));
            connectPort = int.Parse(GUILayout.TextField(connectPort.ToString()));
            GUILayout.BeginVertical();
            if (GUILayout.Button ("Connect To Server"))
            {
                C2Request request = new C2Request(C2MessageType.Request_ConnectToServer);
                request.putData("IP" , connectToIP);
                request.putData("Port" , connectPort);
                this.SendRequest(request);

            }
            GUILayout.EndVertical();

        }else{
            //We've got a connection(s)!

            if (Network.peerType == NetworkPeerType.Connecting){

                GUILayout.Label("Connection status: Connecting");

            } else if (Network.peerType == NetworkPeerType.Client){

                GUILayout.Label("Connection status: Client!");
                GUILayout.Label("Ping to server: "+Network.GetAveragePing(  Network.connections[0] ) );
            }

            if (GUILayout.Button ("Disconnect"))
            {
                C2Request request = new C2Request(C2MessageType.Request_DisconnectFromServer);
                this.SendRequest(request);
            }

        }
        /*if (gameState == LunarLanderGameState.lost)
        {
            GUILayout.Label("You Lost!");
            if (GUILayout.Button("Try again"))
            {
                Application.LoadLevel(Application.loadedLevel);
            }
        }*/
        //We display the game GUI from the playerscript
        //It would be nicer to have a seperate script dedicated to the GUI though...
    }
Example #6
0
 private void RequestUpdatePlayer(NetworkPlayer player)
 {
     C2Request request;
     request = new C2Request(C2MessageType.Request_UpdateAlive);
     request.putData("NetworkPlayer" , player);
     this.SendRequest(request);
 }
Example #7
0
    private void RequestUpdatePlayer(NetworkPlayer player , string item)
    {
        C2Request request;

        switch (item){
        case "Coin":
            request = new C2Request(C2MessageType.Request_UpdateCoin);
            request.putData("NetworkPlayer" , player);
            this.SendRequest(request);
            break;
        case "EnergyBlock":
            request = new C2Request(C2MessageType.Request_UpdateEnergy);
            request.putData("NetworkPlayer" , player);
            this.SendRequest(request);
            break;
        case "Accelerator":
            request = new C2Request(C2MessageType.Request_UpdateSpeed);
            request.putData("NetworkPlayer" , player);
            this.SendRequest(request);
            break;
        case "Shield":
            request = new C2Request(C2MessageType.Request_UpdateShield);
            request.putData("NetworkPlayer" , player);
            this.SendRequest(request);
            break;
        default:
            break;
        }
    }
    public void RequestPlayerStatus(NetworkPlayer player)
    {
        //request for lasted data

        C2Request request = new C2Request(C2MessageType.Request_PlayerStatus);
        request.putData("NetworkPlayer" , player);
        this.HandleRequest(request);
    }