/// Apply frame n's information to these replayer objects
        /// so that they match the frame
        public void ApplyFrame(ClockController timer,
                               DynamicReplayer[] dynamics, StaticReplayer[] statics)
        {
            // spin up to the frame right before the current time

            float currentTime = timer.GetTime();

            while (frames[head].time <= currentTime)
            {
                head++;
                if (head >= frames.Count)
                {
                    // we've reached the end of the recording, and should
                    // return the last frame
                    head--;
                    break;
                }
            }

            // that makes frames[head] the first frame before (or at) the
            // current time

            // if this frame hasn't been rendered yet, we should play it

            if (head > prev)
            {
                frames[head].Apply(dynamics, statics);
                prev = head;
            }
        }
        /// Add the information from these recordable objects to
        /// a new frame
        public void AddFrame(ClockController timer,
                             DynamicRecorder[] dynamics, StaticRecorder[] statics)
        {
            // create and store a new frame

            Frame frame = new Frame(timer.GetTime(), dynamics, statics);

            frames.Add(frame);

            // optional: print the frame's json to the console

            // Debug.Log(JsonUtility.ToJson(frame));
        }
Пример #3
0
        void OnTriggerEnter2D(Collider2D other)
        {
            if (ArcadePhysics.SameWorld(this, other))
            {
                // only trigger if this component is on
                if (enabled)
                {
                    if (ended == false && recorder != null)
                    {
                        recorder.EndRecording(clock.GetTime());

                        ended = true;
                    }
                }
            }
        }
Пример #4
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);
            }
        }