private void Update() { ///limit these checks to when the game is actually running if (!gameIsOn) { return; } if (!enemy) { anim.SetFloat("Movement", rBody.velocity.x); } else { anim.SetFloat("Movement", -rBody.velocity.x); } if (!enemy) { if (transform.position.x >= winPosX) { inputManager.EndGame(WinState.Win); } if (transform.position.x <= losePosX) { inputManager.EndGame(WinState.Loss); } } }
private IEnumerator TimerSpriteChange() { yield return(new WaitForSeconds(stateDuration)); currentState++; audioSource.Play(); sRenderer.sprite = sprites[currentState]; if (sRenderer.sprite == sprites[sprites.GetUpperBound(0)]) { print(" Timer Done"); inputManager.EndGame(WinState.Neutral); yield break; } StartCoroutine(TimerSpriteChange()); }