public IEnumerator ControlWizard(int playerNumber, OptionsMenuButton button) { VirtualControlManager.SetupDefaultControls(playerNumber); yield return(new WaitForEndOfFrame()); yield return(new WaitForEndOfFrame()); yield return(new WaitForEndOfFrame()); foreach (string inputName in VirtualControlManager.inputNames) { cInput.ChangeKey(inputName + playerNumber); button.text.text = string.Format("Press key/button for {0}", inputName); yield return(new WaitForEndOfFrame()); yield return(new WaitForEndOfFrame()); yield return(new WaitForEndOfFrame()); yield return(new WaitUntil(() => !cInput.scanning)); } button.text.text = "Set controls for player " + (playerNumber + 1); }
void Awake() { main = this; //Poorly implemented singleton thing, I guess. hud = FindObjectOfType <HUDManager>(); musicPlayer = GetComponentInChildren <MusicSelector>(); VirtualControlManager.SetAllDefaultPlayerControls(); enemyPlacer = GetComponent <EnemyPlacer>(); }
void FixedUpdate() { InputData input = VirtualControlManager.SampleInput(main.playerNumber); Vector3 moveVector = new Vector3(input.Horizontal, 0f, input.Vertical); moveVector = Vector3.ClampMagnitude(moveVector, 1f); if (!stunned) { rigid.velocity = moveVector * moveSpeed; } }
void Update() { InputData input = VirtualControlManager.SampleInput(main.playerNumber); //Aim 360 degrees around if (aimMode == AimMode.Joystick) { if (input.AimHorizontal != 0 || input.AimVertical != 0) { Vector3 aimInput = new Vector3(input.AimHorizontal, 0f, input.AimVertical); Quaternion aimDirection = Quaternion.LookRotation(aimInput, Vector3.up); transform.rotation = aimDirection; } } else if (aimMode == AimMode.Mouse) { Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition); RaycastHit hit; if (Physics.Raycast(ray, out hit, Mathf.Infinity, aimMask)) { Vector3 aimVector = hit.point - transform.position; aimVector = Vector3.ProjectOnPlane(aimVector, Vector3.up); Quaternion aimDirection = Quaternion.LookRotation(aimVector, Vector3.up); transform.rotation = aimDirection; } } //Shoot if (fireRateTimer > 0) { fireRateTimer -= Time.deltaTime; } if (canFire(input)) { //if(input.Fire1 || (Input.GetKey(KeyCode.Alpha1) && main.playerNumber != 0)) { if (fireRateTimer <= 0f) { FireBullet(); fireRateTimer = fireRate; } } }
void Start() { VirtualControlManager.SetupDefaultControls(playerNumber); vfx.SetVFXColors(playerColor); }
void Awake() { VirtualControlManager.SetAllDefaultPlayerControls(); }