示例#1
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;
            }
        }
        void OnTriggerEnter2D(Collider2D other)
        {
            if (ArcadePhysics.SameWorld(this, other))
            {
                // only trigger if this component is on
                if (enabled)
                {
                    if (started == false && replayer != null)
                    {
                        replayer.StartReplaying();

                        started = true;
                    }
                }
            }
        }