void Update() { // slowCooldown -= Time.deltaTime; if (Input.GetKeyDown(KeyCode.LeftShift)) { // slowTime = Time.time; && slowCooldown <= 0 Time.timeScale = .5f; } if (Input.GetKeyUp(KeyCode.LeftShift)) { Time.timeScale = 1; // slowCooldown = 10; || slowTime < Time.time + 3 } playerMovement(); //attaking using space or LMB if ((Input.GetKeyDown(KeyCode.Space) || Input.GetMouseButtonDown(0)) && attackCooldown <= Time.time) { GameLogic.ghostInput temp; attackCooldown = Time.time + 0.7f; StartCoroutine(doAttack()); temp = new GameLogic.ghostInput("Space", 0, Time.time - GameLogic.Instance.startTime); GameLogic.Instance.currentGhost.Add(temp); } if (Input.GetKeyDown(KeyCode.R)) { transform.position = startPosition; } }
public ghostInput(GameLogic.ghostInput toCopy) { keyPress = toCopy.keyPress; pressTime = toCopy.pressTime; pressStart = toCopy.pressStart; }
void recordInput() { GameLogic.ghostInput temp; //Get time at start of key press if (Input.GetKeyDown(KeyCode.W)) { WStart = Time.time - startTime; } if (Input.GetKeyDown(KeyCode.A)) { AStart = Time.time - startTime; } if (Input.GetKeyDown(KeyCode.S)) { SStart = Time.time - startTime; } if (Input.GetKeyDown(KeyCode.D)) { DStart = Time.time - startTime; } //get total key press time and enter to list if (Input.GetKeyUp(KeyCode.W)) { WEnd = Time.time - WStart; temp = new GameLogic.ghostInput("W", WEnd, WStart); currentGhost.Add(temp); } if (Input.GetKeyUp(KeyCode.A)) { AEnd = Time.time - AStart; temp = new GameLogic.ghostInput("A", AEnd, AStart); currentGhost.Add(temp); } if (Input.GetKeyUp(KeyCode.S)) { SEnd = Time.time - SStart; temp = new GameLogic.ghostInput("S", SEnd, SStart); currentGhost.Add(temp); } if (Input.GetKeyUp(KeyCode.D)) { DEnd = Time.time - DStart; temp = new GameLogic.ghostInput("D", DEnd, DStart); currentGhost.Add(temp); } /* * if ((Input.GetKey(KeyCode.Space) || Input.GetMouseButton(0)) && lastAttackTime >= Time.time -0.3f) { * lastAttackTime = Time.time; * attackStart = Time.time - startTime; * temp = new GameLogic.ghostInput("Space", 0, attackStart); * currentGhost.Add(temp); * } */ }