コード例 #1
0
        public static void PlayagainstAwake(GameObject ghost, GameObject level)
        {
            // prepare the ghost level visually

            PrepareGhostLevel(ghost, level);


            // set up the components in the ghost level to track a recording

            EnableReplayingComponents(ghost);


            // enable the replayer object itself

            ReplayingController replayer = FindObjectOfType <ReplayingController>();

            replayer.enabled = true;
            replayer.level   = ghost.GetComponent <TiledMap>();

            // but don't start playing just yet! Wait till someone crosses
            // the start lines in the first level, actually!


            // make sure the start line in the main level
            // will start the recording in the ghost level

            foreach (ReplayingStarter starter in level.GetComponentsInChildren <ReplayingStarter>())
            {
                starter.enabled = true;

                // link this starter directly to the replayer in the ghost level
                starter.replayer = replayer;
            }


            // the finish lines in the ghost level should not exit the game,
            // or stop the clock! they should just end the replaying being replayed

            foreach (FinishLine finish in ghost.GetComponentsInChildren <FinishLine>())
            {
                // turn off clock-stopping

                finish.enabled = false;

                // turn on replaying ending but not level-leaving

                ReplayingEnder ender = finish.GetComponent <ReplayingEnder> ();
                ender.enabled  = true;
                ender.terminal = false;
            }

            // also, the level boundaries should not exit the game! they should be deactivated,
            // because they are active by default

            foreach (LevelBoundary exit in ghost.GetComponentsInChildren <LevelBoundary>())
            {
                exit.enabled = false;
            }
        }
コード例 #2
0
        void Start()
        {
            // reset static state between games
            ended = false;

            // link components together
            if (replayer == null)
            {
                replayer = FindObjectOfType <ReplayingController> ();
            }
        }
コード例 #3
0
        public static void ReplayingAwake(GameObject level)
        {
            // set up objects and players for replaying

            EnableReplayingComponents(level);


            // set the camera up to follow either player. just find an
            // enabled physics controller!

            foreach (ArcadePhysicsController apc in level.GetComponentsInChildren <ArcadePhysicsController> ())
            {
                if (apc.enabled)
                {
                    InitializeLevel.instance.cam.target = apc;
                    break;
                }
            }

            // also, there's no need for the controls or chat
            // in a replay

            InitializeLevel.instance.gui.OnScreenControls.SetActive(false);
            InitializeLevel.instance.gui.ChatButton.SetActive(false);

            // enable the replayer object itself

            ReplayingController replayer = FindObjectOfType <ReplayingController>();

            replayer.enabled = true;
            replayer.level   = level.GetComponent <TiledMap>();


            // start playing straight away! also start the clock

            replayer.StartReplaying();
            FindObjectOfType <ClockController> ().StartTiming();


            // the finish lines in the main level should end
            // the replaying, and also exit the game

            foreach (ReplayingEnder ender in level.GetComponentsInChildren <ReplayingEnder>())
            {
                ender.enabled = true;

                ender.terminal = true;
            }
        }