void FixedUpdate() { if ((int)currentState == 0) { timer = timer + Time.deltaTime; timerText.text = timer.ToString("F2"); playerInput.getInputs(); playerInputStruct userInput = playerInput.getInputStruct(); inputRec.addToDictionary(timer, userInput); objectController.givenInputs(userInput); objectController.move(); playerInput.resetInput(); } if ((int)currentState == 1) { if (newPlayback == true) { playbackTimer = 0; newPlayback = false; } playbackTimer = playbackTimer + Time.deltaTime; timerText.text = playbackTimer.ToString("F2"); if (inputRec.keyExists(playbackTimer)) { playerInputStruct recordedInputs = inputRec.getRecordedInputs(playbackTimer); if (recordedInputs.buttonPressed == true) { Debug.Log("At" + playbackTimer + "the value of the button press is" + recordedInputs.buttonPressed); } objectController.givenInputs(recordedInputs); objectController.move(); } } if ((int)currentState == 2) { timer = 0; timerText.text = "0.00"; } }
public void givenInputs(playerInputStruct inputs) { horizontalValue = inputs.horizontalInput; verticalValue = inputs.verticalInput; buttonValue = inputs.buttonPressed; }
//Adds the timeStamp and playerInputs into the dictionary //The timeStamp is the key //The inputStruct (inputs) is the value of the key //This function is used by the actorObject script as the dictionary is private public void addToDictionary(float time, playerInputStruct inputs) { playerInputRecord.Add(time, inputs); }
public playerInputStruct getInputStruct() { playerInputStruct playerInputs = new playerInputStruct(horizontalValue, verticalValue, keyPressed); return(playerInputs); }