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);
            }
        }
        // helper method

        static void EnableReplayingComponents(GameObject level)
        {
            // enable dynamic replayers, and the lerping physics
            // controllers on these objects

            foreach (DynamicReplayer rep in level.GetComponentsInChildren <DynamicReplayer>())
            {
                // enable replaying

                rep.enabled = true;

                // enable remote control with lerping

                LerpingPhysicsController lpc = rep.GetComponent <LerpingPhysicsController>();
                lpc.enabled = true;
            }


            // enable static replayers, too

            foreach (StaticReplayer rep in level.GetComponentsInChildren <StaticReplayer>())
            {
                // enable replaying

                rep.enabled = true;
            }
        }
        void Start()
        {
            // link components

            LerpingPhysicsController[] remotes =
                GetComponents <LerpingPhysicsController> ();
            foreach (LerpingPhysicsController remote in remotes)
            {
                if (remote.enabled)
                {
                    this.remote = remote;
                    break;
                }
            }
        }
Beispiel #4
0
        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);
            }
        }
        void Start()
        {
            // link components

            lerper = GetComponent <LerpingPhysicsController> ();

            // find the first enabled player controller

            ArcadePhysicsController[] controllers = GetComponents <ArcadePhysicsController> ();
            foreach (ArcadePhysicsController controller in controllers)
            {
                if (controller.enabled)
                {
                    // found an enabled controller! let's track this one
                    block = controller;
                    break;
                }
            }
        }