static void InitializeObstaclesClient(GameObject level, UpdateManager updateManager) { // on the client 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); } }
static void InitializeObstaclesHost(GameObject level, UpdateManager updateManager) { // on the host 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; } }