void InitializeObjectsSender(GameObject level, UpdateManager updateManager) { // enable all the local players and their serializers on the sending side foreach (LocalPlayerController localPlayer in level.GetComponentsInChildren <LocalPlayerController>()) { localPlayer.enabled = true; PlayerSerializer localSerializer = localPlayer.GetComponent <PlayerSerializer> (); localSerializer.enabled = true; localSerializer.updateManager = updateManager; } // on the sender side, keys, key blocks and pressure playes should // all respond to collisions, not remote updates! foreach (KeyController key in level.GetComponentsInChildren <KeyController>()) { key.enabled = true; } foreach (PressurePlateController plate in level.GetComponentsInChildren <PressurePlateController>()) { plate.enabled = true; } foreach (KeyBlockController block in level.GetComponentsInChildren <KeyBlockController>()) { block.enabled = true; } // all of these obstacles need to be set up to notify the // update manager when something changes! foreach (BoolObstacleSerializer obstacle in level.GetComponentsInChildren <BoolObstacleSerializer>()) { obstacle.enabled = true; obstacle.updateManager = updateManager; } // as for push blocks, we'll need to enable their // normal controllers to, so that they can be pushed around // and we'll also set them up to foreach (PushBlockController pbc in level.GetComponentsInChildren <PushBlockController>()) { pbc.enabled = true; PushBlockSerializer pbs = pbc.GetComponent <PushBlockSerializer> (); pbs.enabled = true; pbs.updateManager = updateManager; } }
void InitializeObjectsReceiver(GameObject level, UpdateManager updateManager) { // enable all the local players and their serializers on the sending side foreach (LocalPlayerController remotePlayer in level.GetComponentsInChildren <LocalPlayerController>()) { remotePlayer.GetComponent <LerpingPhysicsController>().enabled = true; // enable the serialisers! and link them to update manager PlayerSerializer remoteSerializer = remotePlayer.GetComponent <PlayerSerializer> (); remoteSerializer.enabled = true; updateManager.Subscribe(remoteSerializer, UpdateManager.Channel.PLAYER); } // on the receiver side, there's no need to control keys and stuff via // collisions! they should just respond to network updates through their // serializer foreach (BoolObstacleSerializer obstacle in level.GetComponentsInChildren <BoolObstacleSerializer>()) { obstacle.enabled = true; updateManager.Subscribe(obstacle, UpdateManager.Channel.OBSTACLE); } // push blocks are also meant to subscribe to notifications from the // network, and should be remote controllable foreach (PushBlockController pbc in level.GetComponentsInChildren <PushBlockController>()) { LerpingPhysicsController rpc = pbc.GetComponent <LerpingPhysicsController> (); rpc.enabled = true; PushBlockSerializer pbs = pbc.GetComponent <PushBlockSerializer> (); pbs.enabled = true; updateManager.Subscribe(pbs, UpdateManager.Channel.PUSHBLOCK); } }