protected override void HandleRequest(C2Request request) { string type = request.Type; if(type.Equals("SpawnBullet")) { Vector3 spawnPos = new Vector3((float)request.getData("x"), (float)request.getData("y"), (float)request.getData("z")); SpawnCollidable(bulletPrefab, spawnPos); } }
protected override void HandleRequest(C2Request request) { string type = request.Type; if(type.Equals(C2MessageType.Request_SpawnStone)) { Vector3 spawnPos = new Vector3((float)request.getData("x"), (float)request.getData("y"), (float)request.getData("z")); SpawnCollidable(stonePrefab, spawnPos); } }
protected override void HandleRequest(C2Request request) { string type = request.Type; if (Network.peerType == NetworkPeerType.Server){ if(type.Equals("SpawnCoin")) { Vector3 spawnPos = new Vector3((float)request.getData("x"), (float)request.getData("y"), (float)request.getData("z")); SpawnCollidable(coinPrefab, spawnPos); } } }
protected override void HandleRequest(C2Request request) { if (request.Type.Equals(C2MessageType.Request_ClientAction)){ C2Notification notification = new C2Notification(C2MessageType.Notification_Input); notification.putData("VInput", (float)request.getData("VInput")); notification.putData("HInput", (float)request.getData("HInput")); notification.putData("NetworkPlayer" , (NetworkPlayer)request.getData("NetworkPlayer")); this.SendNotification(notification); } }
//Obviously the GUI is for both client&servers (mixed!) protected override void HandleRequest(C2Request request) { string type = request.Type; if(type.Equals(C2MessageType.Request_ConnectToServer)) { string ConnectToIP = (string)request.getData("IP"); int ConnectPort = (int)request.getData("Port"); Network.Connect(ConnectToIP , ConnectPort); Application.LoadLevel(Application.loadedLevel); } else if(type.Equals(C2MessageType.Request_DisconnectFromServer)) { Network.Disconnect(200); Application.LoadLevel(Application.loadedLevel); } }
protected override void HandleRequest(C2Request request) { string type = request.Type; NetworkPlayer player = (NetworkPlayer)request.getData("NetworkPlayer"); switch (type){ case C2MessageType.Request_UpdateCoin: playerList[player].updatePlayerCoin(); break; case C2MessageType.Request_UpdateEnergy: playerList[player].updatePlayerEnergy(); break; case C2MessageType.Request_UpdateSpeed: playerList[player].updatePlayerSpeed(); break; case C2MessageType.Request_UpdateShield: playerList[player].updatePlayerShield(); break; case C2MessageType.Request_UpdateAlive: playerList[player].updatePlayerAlive(); break; case C2MessageType.Request_PlayerStatus: C2Notification notification = new C2Notification(C2MessageType.Notification_PlayerStatus); notification.putData("NetworkPlayer" , player); notification.putData("Player" , playerList[player]); this.SendNotification(notification); break; default: break; } }
protected override void HandleRequest(C2Request request) { string type = request.Type; if(type.Equals(C2MessageType.Request_SpawnAccelerator)) { Vector3 spawnPos = new Vector3((float)request.getData("x"), (float)request.getData("y"), (float)request.getData("z")); SpawnCollidable(acceleratorPrefab, spawnPos); } if(type.Equals(C2MessageType.Request_SpawnEnergyBlock)) { Vector3 spawnPos = new Vector3((float)request.getData("x"), (float)request.getData("y"), (float)request.getData("z")); SpawnCollidable(energyBlockPrefab, spawnPos); } if(type.Equals(C2MessageType.Request_SpawnShield)) { Vector3 spawnPos = new Vector3((float)request.getData("x"), (float)request.getData("y"), (float)request.getData("z")); SpawnCollidable(shieldPrefab, spawnPos); } }
protected override void HandleRequest(C2Request request) { if (Network.isClient && (owner == Network.player)) { string type = request.Type; if (currentPlayer.Alive == true && type.Equals(C2MessageType.Request_Movement)) { float liftForce = (float)request.getData("VForce"); Vector3 upVec = transform.position; upVec.Normalize(); if (currentPlayer.Energy > 0){ constantForce.force = upVec * liftForce * 700; currentPlayer.Energy -= liftForce; } else{ constantForce.force = Vector3.zero; currentPlayer.Energy = 0; } float rotation = (float)request.getData("Rotation"); transform.RotateAround(transform.position, rotation); } } else if (Network.isServer){ string type = request.Type; if ( type.Equals(C2MessageType.Request_Movement)) { NetworkPlayer nid = (NetworkPlayer)request.getData("NetworkPlayer"); if (nid == owner){ float liftForce = (float)request.getData("VForce"); Vector3 upVec = transform.position; currentPlayer = ((Players)GameObject.Find("Players").GetComponent(typeof(Players))).playerList[nid]; if (currentPlayer.Alive == false)return; upVec.Normalize(); if (currentPlayer.Energy > 0){ constantForce.force = upVec * liftForce * 700; currentPlayer.Energy -= liftForce; } else{ constantForce.force = Vector3.zero; currentPlayer.Energy = 0; } float rotation = (float)request.getData("Rotation"); transform.RotateAround(transform.position, rotation); } } } }
protected override void HandleRequest(C2Request request) { foreach(C2Port topPort in this.tops) { topPort.PassRequest(request); } string type = request.Type; switch(type){ case C2MessageType.Request_Input: SendMovement((float)request.getData("VInput") , (float)request.getData("HInput")); break; case C2MessageType.Request_PlayerStatus: networkView.RPC("RequestPlayerStatus" , RPCMode.Server , Network.player); break; default: break; } }