void LateUpdate() { if (!playerActive) { return; } if (InputDB.GetButtonDown("Fire1") && canKickback) { canKickback = false; } else if (InputDB.GetButtonUp("Fire1")) { canKickback = true; gameObject.BroadcastMessage("ReleaseFire", 1, SendMessageOptions.DontRequireReceiver); } if (weapons[selectedWeapon] != null) { if (/*!InputDB.GetButton ("Fire1") || */ Time.time > weapons[selectedWeapon].GetComponent <GunScript>().nextFireTime) { BroadcastMessage("Cooldown"); } } if (InputDB.GetButtonUp("Aim")) { gameObject.SendMessageUpwards("ReleaseFire", 2, SendMessageOptions.DontRequireReceiver); } }
void Update() { if (InputDB.GetButtonDown("Fire2")) { Cycle(); } }
void Update() { if (!walking) { notWalkingTime = Time.time - stopWalkingTime; } else { notWalkingTime = 0; } Vector3 weaponCameraLocalPos = weaponCamera.transform.localPosition; if (weaponCameraLocalPos.y > standardCamHeight) { weaponCameraLocalPos.y = standardCamHeight; } else if (weaponCameraLocalPos.y < crouchingCamHeight) { weaponCameraLocalPos.y = crouchingCamHeight; } if (grounded) { if (InputDB.GetButtonDown("Crouch")) { if (crouching) { stopCrouching = true; NormalSpeed(); return; } if (!crouching) { Crouch(); } } } if (crouching) { if (weaponCameraLocalPos.y > crouchingCamHeight) { weaponCameraLocalPos.y = Mathf.Clamp(weaponCameraLocalPos.y - crouchDeltaHeight * Time.deltaTime * 8, crouchingCamHeight, standardCamHeight); } } else { if (weaponCameraLocalPos.y < standardCamHeight) { weaponCameraLocalPos.y = Mathf.Clamp(weaponCameraLocalPos.y + standardCamHeight * Time.deltaTime * 8, 0, standardCamHeight); } } weaponCamera.transform.localPosition = weaponCameraLocalPos; }
public void Update() { if (InputDB.GetButtonDown("Store")) { if (!storeActive && canActivate && !GunScript.takingOut && !GunScript.puttingAway) { activateStore(); } else if (storeActive) { deActivateStore(); } } }
void Update() { if (!playerActive) { return; } /************************Interact****************************/ if (interactDistance > 0) { //Set up ray Ray ray; RaycastHit hit; ray = Camera.main.ScreenPointToRay(new Vector3(Screen.width / 2.0f, Screen.height / 2.0f, 0)); if (Physics.Raycast(ray, out hit, interactDistance, interactMask)) { //We hit something new if (lastHit != hit.transform) { //Last object isn't still highlighted if (lastHit) { lastHit.SendMessage("HighlightOff", SendMessageOptions.DontRequireReceiver); } //New one is lastHit = hit.transform; lastHit.SendMessage("HighlightOn", SendMessageOptions.DontRequireReceiver); } } else if (lastHit != null) { //We hit nothing, but still have a object highlighted, so unhighlight it lastHit.SendMessage("HighlightOff", SendMessageOptions.DontRequireReceiver); lastHit = null; } //Interact if (InputDB.GetButtonDown("Interact") && lastHit != null) { lastHit.SendMessage("Interact", this.gameObject, SendMessageOptions.DontRequireReceiver); } } /**********************Fire & Reload******************************/ // Did the user press fire? if (InputDB.GetButton("Fire1") && (autoFire || charge) && canFire) { transform.root.BroadcastMessage("Fire", SendMessageOptions.DontRequireReceiver); } else if (InputDB.GetButtonDown("Fire1") && canFire) { transform.root.BroadcastMessage("Fire", SendMessageOptions.DontRequireReceiver); } if (InputDB.GetButton("Fire2") && canFire && (autoFire || charge)) { BroadcastMessage("Fire2", SendMessageOptions.DontRequireReceiver); } else if (InputDB.GetButtonDown("Fire2") && canFire) { BroadcastMessage("Fire2", SendMessageOptions.DontRequireReceiver); } if (InputDB.GetButtonDown("Reload")) { BroadcastMessage("Reload", SendMessageOptions.DontRequireReceiver); } /*************************Weapon Switching***************************/ if (!AimMode.canSwitchWeaponAim || hidden || !canSwitchWeapon || Avoidance.collided) { return; } if (InputDB.GetButtonDown("SelectWeapon")) { int temp = WeaponSelector.selectedWeapon; if (weapons.Length > temp && (selectedWeapon != temp || weapons[selectedWeapon] == null) && temp >= 0) { if (weapons[temp] != null) { if (!weapons[temp].gameObject.GetComponent <WeaponInfo>().locked) { SelectWeapon(temp); selectedWeapon = temp; displayMessage = false; } else { SlotEmptyMessage(temp + 1); } } else { SlotEmptyMessage(temp + 1); } } } }