public IEnumerator autoIntent() { yield return null; while(true) { if(left) { legOne.footAdvanceFactor = -1f; legTwo.footAdvanceFactor = -1f; } currentLegsIntent = LegsIntent.STAND; if(walking) { currentLegsIntent = LegsIntent.WALK; } if(crouching) { currentLegsIntent = LegsIntent.CROUCH; } if(jumping) { currentLegsIntent = LegsIntent.JUMP; } yield return new WaitForEndOfFrame(); } }
public IEnumerator getIntentFromInputs() { yield return null; while(true) { float xAxis = Input.GetAxis("Horizontal"); legOne.footAdvanceFactor = xAxis; legTwo.footAdvanceFactor = xAxis; if(Input.GetKeyDown(KeyCode.G)) { currentGravity = lastGravity; lastGravity = Physics2D.gravity; Physics2D.gravity = currentGravity; } if(Input.GetKeyDown(KeyCode.D)) { delayJump = !delayJump; if(delayJump) { legIntentToFunction[LegsIntent.JUMP] = MovementUtility.delayJump; } else { legIntentToFunction[LegsIntent.JUMP] = MovementUtility.jump; } } currentLegsIntent = LegsIntent.STAND; if(Input.GetKey(KeyCode.LeftControl)) { currentLegsIntent = LegsIntent.CROUCH; } else if(Input.GetKey(KeyCode.Space) || Input.GetKey(KeyCode.Joystick2Button0)) { currentLegsIntent = LegsIntent.JUMP; } else if(!(Mathf.Approximately(xAxis, 0f))) { currentLegsIntent = LegsIntent.WALK; } yield return null; } }