public ShotControllerState GetControllerState() { ShotControllerState ret = new ShotControllerState(); ret.shotA = Input.GetMouseButtonDown(0); ret.shotB = Input.GetMouseButtonDown(1); ret.toss = Input.GetKeyDown("space"); return(ret); }
// Update is called once per frame void Update() { Vector2 cStateMove = moveController.GetDirection(); rb.AddForce(new Vector3(cStateMove.x, 0, cStateMove.y) * runSpeed - rb.velocity, ForceMode.VelocityChange); if (cStateMovePrev == Vector2.zero && cStateMove != Vector2.zero) { runSound.Play(); } else if (cStateMovePrev != Vector2.zero && cStateMove == Vector2.zero) { runSound.Stop(); } cStateMovePrev = cStateMove; AimControllerState cStateAim = aimController.GetAim(); aimMark.transform.position = cStateAim.aim; ShotControllerState cStateShot = shotController.GetControllerState(); aimVia = cStateAim.aimVia; if (shottable) { if (cStateShot.shotA) { ballController.projectile(cStateAim.aim, cStateAim.aimVia, spinA); shotSound.Play(); } else if (cStateShot.shotB) { ballController.projectile(cStateAim.aim, cStateAim.aimVia, spinB); shotSound.Play(); } } else if (cStateShot.toss) { if (ballController.bounds >= 2) { toss(3); } } }
public ShotControllerState GetControllerState() { ShotControllerState cState = new ShotControllerState(); if (Mathf.Sign(ballRigidbody.transform.position.z) == Mathf.Sign(gameObject.transform.position.z) && Mathf.Sign(ballRigidbody.velocity.z) == Mathf.Sign(gameObject.transform.position.z)) { result = !result; if (Random.Range(0.0f, 1.0f) < 0.5f) { cState.shotA = result; } else { cState.shotB = result; } } prev = cState; return(cState); }
void Awake() { ballRigidbody = ball.GetComponent <Rigidbody>(); prev = new ShotControllerState(); }