Example #1
0
    private void SaveObjectState(bool initialState)
    {
        NetDataWriter writer = new NetDataWriter(true);

        foreach (var player in MatchSystem.instance.Scene.AllPlayers)
        {
            player.WriteData(writer, initialState);
        }

        foreach (var netObj in MatchSystem.instance.Scene.NetworkObjects)
        {
            writer.Put(netObj.Key); //Network ID
            netObj.Value.WriteData(writer, initialState);
        }
        NetDataReader reader = new NetDataReader();

        reader.SetSource(writer);

        ReplayState state = new ReplayState
        {
            initialState = initialState,
            timestamp    = Time.ElapsedTime,
            reader       = reader
        };

        States.Add(state);
    }
 public void PostSimulate()
 {
     if (Game.instance == null)
     {
         return;
     }
     if (Game.instance.state != GameState.PlayingLevel)
     {
         state = ReplayState.None;
         SubtitleManager.instance.ClearRecording();
     }
     if (state == ReplayState.None)
     {
         return;
     }
     if (state == ReplayState.Record)
     {
         CaptureFrame();
         return;
     }
     PlaybackFrame(currentFrame);
     if (state == ReplayState.PlayForward)
     {
         currentFrame++;
     }
     else if (state == ReplayState.PlayBackward)
     {
         currentFrame--;
     }
     currentFrame = Mathf.Clamp(currentFrame, 0, lastFrame);
 }
Example #3
0
        public void GetRacersAndStartRecording(Statistics[] allRacers)
        {
            //Get the racer's vehicle controllers and start recording the replay

            racers.RemoveRange(allRacers.Length, racers.Count - allRacers.Length);

            for (int i = 0; i < racers.Count; i++)
            {
                racers[i].racer = allRacers[i].transform;

                if (racers[i].racer.GetComponent <Car_Controller>())
                {
                    racers[i].carController = racers[i].racer.GetComponent <Car_Controller>();
                }

                if (racers[i].racer.GetComponent <Motorbike_Controller>())
                {
                    racers[i].motorbikeController = racers[i].racer.GetComponent <Motorbike_Controller>();

                    if (racers[i].motorbikeController.chassis)
                    {
                        racers[i].motorbikeChassis = racers[i].motorbikeController.chassis.transform;
                    }
                }
            }

            replayState = ReplayState.Recording;
        }
Example #4
0
 // Token: 0x06000D44 RID: 3396 RVA: 0x0003A540 File Offset: 0x00038740
 public SingleCopyReplayConfiguration(IADDatabaseAvailabilityGroup dag, IADDatabase database, IADServer server, LockType lockType)
 {
     try
     {
         if (database == null)
         {
             throw new NullDatabaseException();
         }
         if (server == null)
         {
             throw new ErrorNullServerFromDb(database.Name);
         }
         this.m_database             = database;
         this.m_type                 = ReplayConfigType.SingleCopySource;
         this.m_server               = server;
         this.m_sourceNodeFqdn       = server.Fqdn;
         this.m_replayState          = ReplayState.GetReplayState(this.m_sourceNodeFqdn, this.m_sourceNodeFqdn, lockType, this.Identity, this.Database.Name);
         this.m_activationPreference = 1;
         base.PopulatePropertiesFromDag(dag);
     }
     finally
     {
         this.BuildDebugString();
     }
 }
Example #5
0
 IEnumerator Reverse()
 {
     while (state == ReplayState.Reverse)
     {
         int previousIndex = timeIndex;
         timeIndex--;
         int currentIndex = timeIndex;
         if (currentIndex < 0)
         {
             state     = ReplayState.Pause;
             timeIndex = 0;
         }
         else
         {
             ReplayData prev, cur;
             prev.time     = replay.TimeLookup(previousIndex);
             prev.messages = replay.MessagesLookup(previousIndex);
             cur.time      = replay.TimeLookup(currentIndex);
             cur.messages  = replay.MessagesLookup(currentIndex);
             ReplayEventData ed = new ReplayEventData(prev, cur);
             yield return(StartCoroutine(ReplayTransition(ed, false)));
         }
     }
     print("Finished Playing");
 }
Example #6
0
        void SetReplayState(ReplayState newState)
        {
            if (this.bestReplayState == newState)
            {
                return;
            }

            switch (newState)
            {
            case ReplayState.Stopped:
                dialogComponent.ReplayButton.gameObject.SetActive(true);
                dialogComponent.ReplayButtonText.text = StringConstants.ButtonReplayPlay;
                DestroyReplayAnimator();
                break;

            case ReplayState.Downloading:
                dialogComponent.ReplayButton.gameObject.SetActive(true);
                dialogComponent.ReplayButtonText.text = StringConstants.ButtonReplayWait;
                break;

            case ReplayState.Playing:
                dialogComponent.ReplayButton.gameObject.SetActive(true);
                dialogComponent.ReplayButtonText.text = StringConstants.ButtonReplayStop;
                SpawnReplayAnimator();
                break;

            default:
                dialogComponent.ReplayButton.gameObject.SetActive(false);
                dialogComponent.ReplayButtonText.text = "";
                break;
            }

            this.bestReplayState = newState;
        }
        private int CalculateMemoryBufferSize()
        {
            int requiredBytes = 0;

            // Create a temp storage container
            ReplayState state = new ReplayState();

            // Get all active components
            foreach (ReplayBehaviour replay in Component.FindObjectsOfType <ReplayBehaviour>())
            {
                // Calculate the required size
                replay.OnReplaySerialize(state);
            }

            // Multiply by record fps
            ReplayManager manager = Component.FindObjectOfType <ReplayManager>();

            // Default to 24 fps
            requiredBytes = (manager != null) ? state.Size * manager.recordFPS : state.Size * 24;

            // Take into account the number of seconds in the memory buffer
            requiredBytes = (int)(requiredBytes * Replay.recordSeconds);

            return(requiredBytes);
        }
        // Methods
        public IEnumerator Start()
        {
            while (true)
            {
                // Wait until we are recording
                if (IsRecording == false)
                {
                    yield return(null);
                }

                // Record event type 1
                yield return(new WaitForSeconds(1f));

                RecordEvent((ushort)MyEventType.Event1);

                // Record event type 2
                yield return(new WaitForSeconds(1f));

                RecordEvent((ushort)MyEventType.Event2);

                // Record event type 3 with extra data
                ReplayState eventData = ReplayState.pool.GetReusable();
                eventData.Write("Hello World");

                yield return(new WaitForSeconds(1f));

                RecordEvent((ushort)MyEventType.Event3, eventData);
            }
        }
Example #9
0
        private void addAction(bool hitting, bool hardhit = false)
        {
            if (wasHit == hitting)
            {
                return;
            }

            wasHit = hitting;

            var state = new ReplayState <TauAction>
            {
                PressedActions = new List <TauAction>()
            };

            if (hitting)
            {
                if (hardhit)
                {
                    state.PressedActions.Add(TauAction.HardButton);
                }
                else
                {
                    state.PressedActions.Add(wasLeft ? TauAction.LeftButton : TauAction.RightButton);
                    wasLeft = !wasLeft;
                }
            }

            state.Apply(tauInputManager.CurrentState, tauInputManager);
        }
        public void DrawGUI(ReplayState state)
        {
            switch (state)
            {
            case ReplayState.MainMenu:
                MenuRect = GUILayout.Window(GUIUtility.GetControlID(FocusType.Passive), MenuRect, MenuWindow, "ReplayEditor Menu");
                break;

            case ReplayState.LoadMenu:
                LoadRect = GUILayout.Window(GUIUtility.GetControlID(FocusType.Passive), LoadRect, LoadWindow, "Load Replay");
                break;

            case ReplayState.SaveMenu:
                SaveRect = GUILayout.Window(GUIUtility.GetControlID(FocusType.Passive), SaveRect, SaveWindow, "Save Replay");
                break;

            case ReplayState.SettingsMenu:
                SettingsRect = GUILayout.Window(GUIUtility.GetControlID(FocusType.Passive), SettingsRect, SettingsWindow, "Settings");
                break;
            }
            if (GUI.Button(new Rect(CurrentRect.xMax, CurrentRect.y, 30, 30), "X"))
            {
                ReplayManager.CurrentState = ReplayState.Playback;
            }
        }
Example #11
0
    private IEnumerator ReplayCoroutine(Vector3 goalPos)
    {
        Debug.Log("Replay cor is started");
        MatchSystem.instance.blockIncomingData = true;
        Replaying = true;
        //specCam.transform.position = goalPos + new Vector3(goalPos.z / 1.2f, 5, 0);
        MatchSystem.instance.ReadOwnerAsNormal = true;
        ReplayState initialState = States[0];

        RemoveAllInitialStates();
        float currentTime = initialState.timestamp;

        LoadObjectState(initialState);
        CameraMaster.instance.StopReplay();
        CameraMaster.instance.StartReplay();
        MatchSystem.instance.Pause();
        while (States.Count > 0)
        {
            while (currentTime < States[0].timestamp)
            {
                currentTime += Time.ActualDeltaTime;
                yield return(null);
            }
            LoadObjectState(States[0]);
            States.RemoveAt(0);
        }
        Replaying = false;
        _Replay   = null;
        MatchSystem.instance.ReadOwnerAsNormal = false;
        MatchSystem.instance.blockIncomingData = false;
        CameraMaster.instance.StopReplay();
        MatchSystem.instance.UnPause();
    }
Example #12
0
        /// <summary>
        /// Requests that the <see cref="CurrentState"/> changes to the specified <see
        /// cref="ReplayState"/>.</summary>
        /// <param name="state">
        /// The requested new value for the <see cref="CurrentState"/> property.</param>
        /// <remarks><para>
        /// <b>RequestState</b> does nothing if the specified <paramref name="state"/> already
        /// equals <see cref="CurrentState"/> or <see cref="RequestedState"/>.
        /// </para><para>
        /// <b>RequestState</b> also does nothing if <see cref="CurrentState"/> equals <see
        /// cref="ReplayState.Skip"/> or <see cref="ReplayState.Stop"/>. Skipping ahead prevents all
        /// input, and clients must call <see cref="Start"/> to start replays.
        /// </para><para>
        /// Otherwise, <b>RequestState</b> sets the <see cref="RequestedState"/> to the specified
        /// <paramref name="state"/>, and also sets the <see cref="SessionExecutor.AbortSignal"/> to
        /// speed up <see cref="Command"/> replay until the background thread gets around to check
        /// the new <see cref="RequestedState"/>.</para></remarks>

        public void RequestState(ReplayState state)
        {
            // quit if state already current or requested
            if (state == CurrentState || state == RequestedState)
            {
                return;
            }

            // quit if currently skipping or stopped
            if (CurrentState == ReplayState.Skip || CurrentState == ReplayState.Stop)
            {
                return;
            }

            // pause current replay if requested
            if (CurrentState == ReplayState.Play && state == ReplayState.Pause)
            {
                _playSignal.Reset();
            }
            else
            {
                _playSignal.Set();
            }

            // let background thread enter requested state
            RequestedState = state;
            SessionExecutor.AbortSignal.Set();
        }
Example #13
0
        public void OnReplayDeserialize(ReplayState state)
        {
            int size = state.Read32();

            for (int i = 0; i < size; i++)
            {
                // Read the target identity
                ReplayIdentity identity  = state.ReadIdentity();
                int            localSize = state.Read32();

                // Read all states
                for (int j = 0; j < localSize; j++)
                {
                    // Create empty data container
                    ReplayInitialData data = new ReplayInitialData();

                    // Deserialize data
                    data.OnReplayDeserialize(state);

                    // Register state
                    if (initialStates.ContainsKey(identity) == false)
                    {
                        initialStates.Add(identity, new List <ReplayInitialData>());
                    }

                    initialStates[identity].Add(data);
                }
            }
        }
Example #14
0
    GameStateBase getState(GameState state)
    {
        GameStateBase gameState;

        if (states.TryGetValue(state, out gameState))
        {
            return(gameState);
        }

        switch (state)
        {
        case GameState.Enter: gameState = new GameEnterState(this); break;

        case GameState.Ready: gameState = new GameReadyState(this); break;

        case GameState.Gaming: gameState = new GamingState(this); break;

        case GameState.Goal: gameState = new GoalState(this); break;

        case GameState.Replay: gameState = new ReplayState(this); break;

        case GameState.Over: gameState = new GameOverState(this); break;
        }
        states.Add(state, gameState);
        return(gameState);
    }
        // Methods
        public override void PrepareForPlayback(Animator component, ReplayState additionalData)
        {
            // Write the component state
            additionalData.Write(component.enabled);

            // Disable the animator - it could interfere with playback
            component.enabled = false;
        }
        public override void PrepareForGameplay(Animator component, ReplayState additionalData)
        {
            // Read the component state
            bool initialState = additionalData.ReadBool();

            // Reset the animator state
            component.enabled = initialState;
        }
        // Methods
        public override void PrepareForPlayback(Rigidbody component, ReplayState additionalData)
        {
            // Store the initial value
            additionalData.Write(component.isKinematic);

            // Make the body kinematic to avoid movement by the physics engine
            component.isKinematic = true;
        }
Example #18
0
        // Methods
        public override void PrepareForPlayback(Behaviour component, ReplayState additionalData)
        {
            // Store the initial value
            additionalData.Write(component.enabled);

            // Make the body kinematic to avoid movement by the physics engine
            component.enabled = false;
        }
Example #19
0
        public override void PrepareForGameplay(Behaviour component, ReplayState additionalData)
        {
            // Read the default value
            bool initialState = additionalData.ReadBool();

            // Reset the kinematic state
            component.enabled = initialState;
        }
 private void BeginRecording()
 {
     state = ReplayState.Record;
     recordingStartTime = Time.time;
     lastFrame          = 0;
     currentFrame       = 0;
     capture.Clear();
 }
Example #21
0
 /// <summary>
 /// Registers the specified replay state with this snapshot.
 /// The specified identity is used during playback to ensure that the replay objects receives the correct state to deserialize.
 /// </summary>
 /// <param name="identity">The identity of the object that was serialized</param>
 /// <param name="state">The state data for the object</param>
 public void RecordSnapshot(ReplayIdentity identity, ReplayState state)
 {
     // Register the state
     if (states.ContainsKey(identity) == false)
     {
         states.Add(identity, state);
     }
 }
        public override void PrepareForGameplay(Rigidbody component, ReplayState additionalData)
        {
            // Read the default value
            bool initialState = additionalData.ReadBool();

            // Reset the kinematic state
            component.isKinematic = initialState;
        }
        private void ResumeUsingState(ReplayConfiguration replayConfiguration)
        {
            ReplayState replayState = replayConfiguration.ReplayState;

            replayState.SuspendLockRemote.TryLeaveSuspend();
            replayState.SuspendMessage = null;
            this.m_fSuccess            = true;
        }
Example #24
0
 void Start()
 {
     if (state == null)
     {
         state         = new ReplayState();
         state.initPos = transform.position;
     }
 }
Example #25
0
    private void Awake()
    {
        Ins                     = this;
        Log                     = new Log();
        ActiveState             = new List <PersistState>();
        GameOverlay             = new GameOverlayDialogState();
        FightState              = new FightState();
        ReplayState             = new ReplayState();
        NickNameDialogState     = new NickNameDialogState();
        BattleStatusDialogState = new BattleStatusDialogState();
        PlayerDialogState       = new PlayerDialogState();
        ChatDialogState         = new ChatDialogState();
        PsdEditDialogState      = new PsdEditDialogState();
        RoomChatDialogState     = new RoomChatDialogState();
        LoadingEx               = new LoadingEXDialogState();
        ItemInfoDialogState     = new ItemInfoDialogState();
        GunShootDialogStatus    = new GunShootDialogStatus();
        //面板管理器.
        DialogStateManager = new MainDialogStateManager();
        //顺序排队弹出框.
        PopupStateManager = new MainPopupStateManager();
        //各类游戏数据.
        GameStateMgr    = new GameStateMgr();
        UpdateHelper    = new UpdateHelper();
        AppInfo         = new AppInfo();
        CombatData      = new CombatData();
        GameNotice      = new GameNotice();
        MeteorManager   = new MeteorManager();
        ScriptMng       = new ScriptMng();
        SFXLoader       = new SFXLoader();
        ActionInterrupt = new ActionInterrupt();

        BuffMng         = new BuffMng();
        EventBus        = new EventBus();
        NetWorkBattle   = new NetWorkBattle();
        SceneMng        = new SceneMng();
        FrameSync       = new FrameSync();
        MeteorBehaviour = new MeteorBehaviour();
        DropMng         = new DropMng();
        //原版相关资源的加载器.
        MenuResLoader    = new MenuResLoader();
        SkcLoader        = new SkcLoader();
        BncLoader        = new BncLoader();
        FMCLoader        = new FMCLoader();
        GMBLoader        = new GMBLoader();
        GMCLoader        = new GMCLoader();
        DesLoader        = new DesLoader();
        FMCPoseLoader    = new FMCPoseLoader();
        DataMgr          = new DataMgr();
        SfxMeshGenerator = new SfxMeshGenerator();
        RoomMng          = new RoomMng();
        SoundManager     = new SoundManager();
        ResMng           = new ResMng();
        DlcMng           = new DlcMng();

        DontDestroyOnLoad(gameObject);
        Log.WriteError(string.Format("GameStart AppVersion:{0}", Main.Ins.AppInfo.AppVersion()));
    }
Example #26
0
        private Thread BeginSuspendUsingState(ReplayConfiguration replayConfiguration)
        {
            ReplayState replayState = replayConfiguration.ReplayState;
            Thread      thread      = new Thread(new ParameterizedThreadStart(this.SuspendStateThreadProc));

            thread.IsBackground = true;
            thread.Start(replayState);
            return(thread);
        }
Example #27
0
        public void Suspend()
        {
            if ((_state == ReplayState.Done) || (!_replayer.IsAlive))
            {
                throw new InvalidOperationException();
            }

            _state = ReplayState.Suspend;
        }
Example #28
0
 // Methods
 /// <summary>
 /// Called by the replay system when the variable should be serialized.
 /// </summary>
 /// <param name="state">The <see cref="ReplayState"/> to serialize the data into</param>
 public void OnReplaySerialize(ReplayState state)
 {
     try
     {
         // Write the current field value
         state.TryWriteObject(Value);
     }
     catch { }
 }
Example #29
0
        /*
         *  回复切磋邀请
         */
        public IEnumerator ContestReplayInvite(int replayinviteId, ReplayState state)
        {
            var packet = new KBEngine.PacketHolder();
            var load   = CGContestReplayInvite.CreateBuilder();

            load.ReplyInviteId = replayinviteId;
            load.ReplyState    = state;
            yield return(StartCoroutine(KBEngine.Bundle.sendSimple(this, load, packet)));
        }
    public void Update()
    {
        if (replayState != ReplayState.Playing)
        {
            for (int padIndex = 0; padIndex < 8; padIndex++)
            {
                CheckKey(ref allControllers[padIndex].moveUp);
                CheckKey(ref allControllers[padIndex].moveDown);
                CheckKey(ref allControllers[padIndex].moveLeft);
                CheckKey(ref allControllers[padIndex].moveRight);
                CheckKey(ref allControllers[padIndex].jump);
                CheckKey(ref allControllers[padIndex].attack);
                CheckKey(ref allControllers[padIndex].escape);

                allControllers[padIndex].xMovement = 0.0f;
                if (allControllers[padIndex].moveRight.isDown)
                {
                    allControllers[padIndex].xMovement = 1.0f;
                }
                if (allControllers[padIndex].moveLeft.isDown)
                {
                    allControllers[padIndex].xMovement = -1.0f;
                }
            }
        }

        if (replayState == ReplayState.Recording)
        {
            if (Time.frameCount >= controllerHistory.Length)
            {
                Debug.LogWarning("Max recording limit reached");
                replayState = ReplayState.None;
                SaveReplay();
            }
            else
            {
                controllerHistory[Time.frameCount].contollerOne   = allControllers[(int)ControllerType.KeyboardWASD];
                controllerHistory[Time.frameCount].contollerTwo   = allControllers[(int)ControllerType.KeyboardArrows];
                controllerHistory[Time.frameCount].contollerThree = allControllers[(int)ControllerType.Controller0];
                controllerHistory[Time.frameCount].contollerFour  = allControllers[(int)ControllerType.Controller1];
                controllerHistory[Time.frameCount].contollerFive  = allControllers[(int)ControllerType.Controller2];
                controllerHistory[Time.frameCount].contollerSix   = allControllers[(int)ControllerType.Controller3];
                controllerHistory[Time.frameCount].contollerSeven = allControllers[(int)ControllerType.Controller4];
            }
        }

        if (replayState == ReplayState.Playing)
        {
            allControllers[(int)ControllerType.KeyboardWASD]   = controllerHistory[Time.frameCount].contollerOne;
            allControllers[(int)ControllerType.KeyboardArrows] = controllerHistory[Time.frameCount].contollerTwo;
            allControllers[(int)ControllerType.Controller0]    = controllerHistory[Time.frameCount].contollerThree;
            allControllers[(int)ControllerType.Controller1]    = controllerHistory[Time.frameCount].contollerFour;
            allControllers[(int)ControllerType.Controller2]    = controllerHistory[Time.frameCount].contollerFive;
            allControllers[(int)ControllerType.Controller3]    = controllerHistory[Time.frameCount].contollerSix;
            allControllers[(int)ControllerType.Controller4]    = controllerHistory[Time.frameCount].contollerSeven;
        }
    }
 public void StopRecording()
 {
     state = ReplayState.None;
     SaveToFile(filename);
 }
 public void StartReplaying(Game game)
 {
     game.Input = staticInput = new StaticInput();
     state = ReplayState.Replaying;
     Game.Random = new Random(0);
     game.SpawnRandomizer = new Random(0);
     mainCharPositionReplay = new Common.Interpolator3();
     groundPosition = new Common.Interpolator3();
     planePosition = new Common.Interpolator3();
 }
 public void StartRecording(Game game)
 {
     state = ReplayState.Recording;
     Game.Random = new Random(0);
     game.SpawnRandomizer = new Random(0);
 }
Example #34
0
        void AddReplay(ReplayMetadata replay, ScrollItemWidget template)
        {
            var item = ScrollItemWidget.Setup(template,
                () => selectedReplay == replay,
                () => SelectReplay(replay),
                () => WatchReplay());

            replayState[replay] = new ReplayState
            {
                Item = item,
                Visible = true
            };

            item.Text = Path.GetFileNameWithoutExtension(replay.FilePath);
            item.Get<LabelWidget>("TITLE").GetText = () => item.Text;
            item.IsVisible = () => replayState[replay].Visible;
            replayList.AddChild(item);
        }
 IEnumerator Forward()
 {
     while(state == ReplayState.Forward) {
         int previousIndex = timeIndex;
         timeIndex++;
         int currentIndex = timeIndex;
         if(currentIndex >= replay.SessionDict.Keys.Count) {
             state = ReplayState.Pause;
             timeIndex = replay.SessionDict.Keys.Count - 1;
         } else {
             ReplayData prev, cur;
             prev.time = replay.TimeLookup(previousIndex);
             prev.messages = replay.MessagesLookup(previousIndex);
             cur.time = replay.TimeLookup(currentIndex);
             cur.messages = replay.MessagesLookup(currentIndex);
             ReplayEventData ed = new ReplayEventData(prev, cur);
             yield return StartCoroutine(ReplayTransition(ed, true));
         }
     }
 }
 void Pause()
 {
     state = ReplayState.Pause;
     forwardButton.sprite = pauseSprite;
 }
 IEnumerator Replay()
 {
     state = ReplayState.Forward;
     elapsed = 0f;
     timeIndex = 0;
     while(state != ReplayState.Stop) {
         if(state == ReplayState.Forward) {
             yield return StartCoroutine(Forward());
         } else if(state == ReplayState.Reverse) {
             yield return StartCoroutine(Reverse());
         } else {
             yield return null; // Pause... don't tick up or down
         }
     }
     elapsed = 0f; // reset elapsed for the ui
 }
 IEnumerator Reverse()
 {
     while(state == ReplayState.Reverse) {
         int previousIndex = timeIndex;
         timeIndex--;
         int currentIndex = timeIndex;
         if(currentIndex < 0) {
             state = ReplayState.Pause;
             timeIndex = 0;
         } else {
             ReplayData prev, cur;
             prev.time = replay.TimeLookup(previousIndex);
             prev.messages = replay.MessagesLookup(previousIndex);
             cur.time = replay.TimeLookup(currentIndex);
             cur.messages = replay.MessagesLookup(currentIndex);
             ReplayEventData ed = new ReplayEventData(prev, cur);
             yield return StartCoroutine(ReplayTransition(ed, false));
         }
     }
     print ("Finished Playing");
 }
 void Unpause(ReplayState newState)
 {
     state = newState;
     forwardButton.sprite = playSprite;
 }