Beispiel #1
0
        private void DisplayInputSimulation()
        {
            GUILayout.Label("Input simulations options", EditorStyles.boldLabel);

            EditorGUILayout.IntField("ControllerId : ", _controllerId);

            //Vertical axis input
            float verticalValue = _rbBaseInput.GetVerticalAxis();

            verticalValue = EditorGUILayout.Slider("Vertical axis", verticalValue, -1f, 1f);
            _rbBaseInput.SetVerticalAxis(verticalValue);

            //Vertical axis input
            float horizontalValue = _rbBaseInput.GetHorizontalAxis();

            horizontalValue = EditorGUILayout.Slider("Horizontal axis", horizontalValue, -1f, 1f);
            _rbBaseInput.SetHorizontalAxis(horizontalValue);

            //Button inputs
            GUILayout.Label("Buttons press options : ", EditorStyles.boldLabel);
            int oldNumOfInputs = _numOfInputs;

            _numOfInputs = EditorGUILayout.IntField("NumOfInputs : ", _numOfInputs);

            if (_numOfInputs != oldNumOfInputs)
            {
                _rbBaseInput = new RollbackInputBaseActions(1 + _numOfInputs / 8);
            }

            for (int i = 0; i < _numOfInputs; i++)
            {
                EditorGUILayout.BeginHorizontal();
                bool initValue = _rbBaseInput.GetValueBit(i);
                initValue = EditorGUILayout.Toggle(_rollbackManager.GetRBInputManager().GetActionName(i), initValue);
                _rbBaseInput.SetOrClearBit(i, initValue);
                EditorGUILayout.EndHorizontal();
            }

            //Correction of inputs
            if (GUILayout.Button("Correct Inputs"))
            {
                if (_rollbackManager != null)
                {
                    RollbackInputBaseActions[] rbInputs = new RollbackInputBaseActions[_numFramesToSimulate];
                    for (int i = 0; i < _numFramesToSimulate; i++)
                    {
                        rbInputs[i] = _rbBaseInput;
                    }

                    DateTime currentTime = System.DateTime.Now;
                    _rollbackManager.GetRBInputManager().CorrectInputs(_controllerId, _numFramesToSimulate, rbInputs);
                    _rollbackManager.ReSimulate(_numFramesToSimulate);
                    _spentTimeToResimulate = System.DateTime.Now - currentTime;
                }
            }

            if (_spentTimeToResimulate != null)
            {
                GUILayout.Label("Time to resimulate " + _numFramesToSimulate + " frames : " + _spentTimeToResimulate.TotalMilliseconds + "ms.");
            }
        }