private bool hasPressedDown() { bool flag = InputWrapper.GetMouseButtonDown(0); if (UnityEngine.Input.touchSupported && !flag) { flag = InputWrapper.touchCount > 0 && InputWrapper.GetTouch(0).phase == TouchPhase.Began; } return(flag); }
public virtual void Update() { if (isLocalPlayer) { if (coolDownTimer >= 0) { coolDownTimer -= Time.deltaTime; } //the player has pressed the button identified by the weaponUseKey field //and the weapon is not on cooldown if (InputWrapper.GetKeyDown(weaponUseKey) || InputWrapper.GetMouseButtonDown(1)) { //if enough ammo to use weapon, check for cooldown if (ammoCount >= ammoUsePerActivation) { //if weapon not on cooldown, activate it and do cleanup if (coolDownTimer <= 0) { //take ammo away from the player ammoCount -= ammoUsePerActivation; //restart the cooldown timer coolDownTimer = coolDownTotalSeconds; ActivateWeapon(); //if ammo is now zero, report the depletion if (ammoCount == 0) { AmmoDepleted(); } } //if weapon is on cooldown, report activation while on cooldown else { WeaponActivatedOnCooldown(); } } //if not enough ammo to use weapon, report activation while no ammo else { WeaponActivatedNotEnoughAmmo(); } } if (InputWrapper.GetKeyDown(addAmmoKey)) { AddAmmo(1); } } }
//Get input for player void Update() { if (isLocalPlayer) { oldKeysDown = KeysDown; KeysDown.forward = InputWrapper.GetKey(forwardKey); KeysDown.backwards = InputWrapper.GetKey(backwardsKey); KeysDown.left = InputWrapper.GetKey(leftKey); KeysDown.right = InputWrapper.GetKey(rightKey); KeysDown.fireCannon = InputWrapper.GetKey(cannonFireKey); KeysDown.fireSwivelGun = InputWrapper.GetKey(swivelGunFireKey); //detect meaningful change in input to send to server if (oldKeysDown.forward != KeysDown.forward || oldKeysDown.backwards != KeysDown.backwards || oldKeysDown.left != KeysDown.left || oldKeysDown.right != KeysDown.right) { CmdBounceInput(KeysDown); //just a struct of 6 bools, shouldn't be weighty at all } if (KeysDown.fireSwivelGun) { foreach (SwivelGun sScript in swivelGunScripts) { if (sScript.CanFire()) { //Pass information to server and spawn cannonball on all cients CmdFire(sScript.GetCannonBallPosition(), sScript.GetCannonBallVelocity()); } } } if (KeysDown.fireCannon || InputWrapper.GetMouseButtonDown(0)) { foreach (BroadsideCannonFireNetworked cScript in cannonScripts) { if (cScript.CanFire()) { //Pass information to server and spawn cannonball on all cients CmdFire(cScript.GetCannonBallPosition(), cScript.GetCannonBallVelocity() * cannonBallSpeedScale); cScript.ResetFireTimer(); } } } boatCam.gameIsPaused = gameIsPaused; //assign game is paused value to boat cam } // Boat speed is visible for testing purposes speed = this.GetComponent <Rigidbody>().velocity.magnitude; }
private TouchPhaseExtended getTouchPhase(out Vector3 touchPosition) { TouchPhaseExtended touchPhaseExtended = TouchPhaseExtended.NoEvent; touchPhaseExtended = ((!InputWrapper.GetMouseButtonDown(0)) ? (InputWrapper.GetMouseButton(0) ? TouchPhaseExtended.Moved : ((!InputWrapper.GetMouseButtonUp(0)) ? TouchPhaseExtended.Mouse : TouchPhaseExtended.Ended)) : TouchPhaseExtended.Began); if (UnityEngine.Input.touchSupported && InputWrapper.touchCount > 0) { touchPhaseExtended = (TouchPhaseExtended)InputWrapper.GetTouch(0).phase; touchPosition = InputWrapper.GetTouch(0).position; } else { touchPosition = InputWrapper.mousePosition; } return(touchPhaseExtended); }