void Update() { if (Input.GetKeyDown(KeyCode.Z)) { intent = FPSKebabiste.Action.GoUp; } if (Input.GetKeyDown(KeyCode.Q)) { intent = FPSKebabiste.Action.GoLeft; } if (Input.GetKeyDown(KeyCode.S)) { intent = FPSKebabiste.Action.GoDown; } if (Input.GetKeyDown(KeyCode.D)) { intent = FPSKebabiste.Action.GoRight; } if (Input.GetMouseButtonDown(0)) { intent = FPSKebabiste.Action.Shoot; } if (Input.GetKeyUp(KeyCode.Z)) { intent = FPSKebabiste.Action.StopUp; } if (Input.GetKeyUp(KeyCode.Q)) { intent = FPSKebabiste.Action.StopLeft; } if (Input.GetKeyUp(KeyCode.S)) { intent = FPSKebabiste.Action.StopDown; } if (Input.GetKeyUp(KeyCode.D)) { intent = FPSKebabiste.Action.StopRight; } if (Input.GetMouseButtonDown(0)) { intent = FPSKebabiste.Action.Shoot; } }
public void PlayActions(FPSKebabiste kebabiste) { float speed = 20.0f; kebabiste.RotateView(); FPSKebabiste.Action kebabisteIntent = kebabiste.GetIntent(); switch (kebabisteIntent) { case FPSKebabiste.Action.GoUp: //kebabiste.kebabistePrefab.transform.position+=Vector3.forward*Time.deltaTime; kebabiste.wantToGoDown = false; kebabiste.wantToGoUp = true; break; case FPSKebabiste.Action.GoDown: kebabiste.wantToGoUp = false; kebabiste.wantToGoDown = true; break; case FPSKebabiste.Action.GoRight: kebabiste.wantToGoLeft = false; kebabiste.wantToGoRight = true; break; case FPSKebabiste.Action.GoLeft: kebabiste.wantToGoRight = false; kebabiste.wantToGoLeft = true; break; case FPSKebabiste.Action.StopUp: //kebabiste.kebabistePrefab.transform.position+=Vector3.forward*Time.deltaTime; kebabiste.wantToGoUp = false; break; case FPSKebabiste.Action.StopDown: kebabiste.wantToGoDown = false; break; case FPSKebabiste.Action.StopRight: kebabiste.wantToGoRight = false; break; case FPSKebabiste.Action.StopLeft: kebabiste.wantToGoLeft = false; break; case FPSKebabiste.Action.Shoot: Shoot(kebabiste); break; case FPSKebabiste.Action.Hide: kebabiste.hiding = StartCoroutine(Hide(kebabiste)); break; case FPSKebabiste.Action.Reload: kebabiste.goingToreload = StartCoroutine(Reload(kebabiste)); break; case FPSKebabiste.Action.GoNear: kebabiste.goingNear = StartCoroutine(GoNear(kebabiste)); break; case FPSKebabiste.Action.None: default: break; } Vector3 wantedMovement = Vector3.zero; if (kebabiste.wantToGoUp) { wantedMovement += speed * Time.deltaTime * kebabiste.kebabistePrefab.transform.forward; } if (kebabiste.wantToGoDown) { wantedMovement -= speed * Time.deltaTime * kebabiste.kebabistePrefab.transform.forward; } if (kebabiste.wantToGoLeft) { wantedMovement -= speed * Time.deltaTime * kebabiste.kebabistePrefab.transform.right; } if (kebabiste.wantToGoRight) { wantedMovement += speed * Time.deltaTime * kebabiste.kebabistePrefab.transform.right; } if (wantedMovement != Vector3.zero) { kebabiste.KebabisteRigidbody.AddForce(wantedMovement, ForceMode.Impulse); } else { kebabiste.KebabisteRigidbody.velocity = Vector3.zero; } }