示例#1
0
        // Helper method used by HandleUpdate to take a clock update and act accordingly
        private void ApplyClockUpdate(List <byte> data)
        {
            // Get the time sent with the notification
            float time = BitConverter.ToSingle(data.ToArray(), 0);

            // Start or stop the clock as appropriate
            if (time == START_CLOCK)
            {
                clock.StartTiming();
            }
            else if (time == STOP_CLOCK)
            {
                clock.StopTiming();
                FinalizeLevel.CrossFinishLine(clock.GetTime());
            }
            else
            {
                clock.StopTiming();
                clock.SetTime(time);
                FinalizeLevel.CrossFinishLine(time);
            }
        }
        static void InitializeFinalization(GameObject level, UpdateManager updateManager)
        {
            StartLineSerializer[]    starts   = level.GetComponentsInChildren <StartLineSerializer> ();
            FinishLineSynchronizer[] finishes = level.GetComponentsInChildren <FinishLineSynchronizer> ();

            // Set up the start and finish line blocks to send updates
            foreach (StartLineSerializer start in starts)
            {
                start.enabled       = true;
                start.updateManager = updateManager;
            }

            foreach (FinishLineSynchronizer finish in finishes)
            {
                finish.enabled = true;
            }

            // set up the static state of the finaliser for a new game,
            // linking it to the update manager

            FinalizeLevel.Init(updateManager);
        }
 // public method to handle exit button behaviour
 public void ExitButtonHandler(bool disconnected)
 {
     FinalizeLevel.ExitGame(disconnected);
 }