void Update() { if (gameStartIndicator.isGamePlaying() && Time.deltaTime != 0) { if (!inputs.inputContinuous()) { rotControl.changePower(); gameObject.transform.rotation = Quaternion.Euler(new Vector3(0, 0, rotControl.getCurrent())); } if (ammunition.hasAmmo()) { if (inputs.inputUp()) { fire(); resetCannon(); } if (inputs.inputContinuous()) { velControl.changePower(); } inputs.informAI(velControl.getCurrentPercent(), rotControl.getCurrentPercent()); } } }
private void fire() { ammunition.useAmmo(); float theta = Mathf.Deg2Rad * rotControl.getCurrent(); Vector2 direction = new Vector2(Mathf.Cos(theta), Mathf.Sin(theta)); Vector2 vel = direction * velControl.getCurrent(); Quaternion rotation = Quaternion.Euler(new Vector3(0, 0, theta)); loadedThrowable = Account.spawnRandom(spawnpoint, true, deck); loadedThrowable.transform.localRotation = rotation; loadedThrowable.transform.SetParent(throwableInstanceHolder.transform); loadedThrowable.GetComponent <Rigidbody2D> ().velocity = vel; loadedThrowable.GetComponent <Team> ().team = team; loadedThrowable.GetComponent <FirstCollision> ().hasBeenLaunched(); }