public PawnInputData GetInput() { PawnInputData curInput = new PawnInputData(); switch (binding) { default: case ControllerBinding.AI_DRIFT: break; case ControllerBinding.AI_BRAIN: break; case ControllerBinding.KEYBOARD: GetKeyboardInput(ref curInput); break; case ControllerBinding.CONTROLLER0: GetControllerInput(0, ref curInput); break; } return(curInput); }
// Update is called once per frame public override void Update() { float deltaTime = Time.deltaTime; lastInput = curInput; curInput = controller.GetInput(); Vector3 desiredMoveVector = new Vector3(curInput.axisX, curInput.axisY); motor.SetDesiredMoveVector(desiredMoveVector); motor.UpdateMotor(deltaTime); UpdateAttached(deltaTime); if (stomachTimer != null && stomachTimer.Tick(deltaTime)) { ad.stomach = Mathf.Max(ad.stomach - 1, 0); if (ad.stomach == 0) { ad.hp -= 1; } } }
void GetKeyboardInput(ref PawnInputData curInput) { if (Input.GetKey(KeyCode.A)) { curInput.axisX -= 1f; } if (Input.GetKey(KeyCode.D)) { curInput.axisX += 1f; } if (Input.GetKey(KeyCode.W)) { curInput.axisY += 1f; } if (Input.GetKey(KeyCode.S)) { curInput.axisY -= 1f; } if (Input.GetKey(KeyCode.Space)) { curInput.alphaDown = true; } }
void GetControllerInput(int controller, ref PawnInputData curInput) { }