protected void UpdateShootingPointInFireArm() { GameObject weapon = fire_arms[weapon_in_use]; FireArm controller = weapon.GetComponent <FireArm>(); controller.UpdateShootingPoint(getShootingpoint()); }
public Projectile Cycle(FireArm fireArm) { if (transform.childCount == 0) { Debug.Log("Run out of ammo"); return(null); } Transform child = transform.GetChild(0); Projectile p = transform.GetChild(0).GetComponent <Projectile>(); if (p == null) { Debug.LogError(gameObject.name + "'s child " + child + " is not a projectile"); return(null); } p.transform.SetParent(null); p.transform.position = fireArm.Barrel.position; p.transform.rotation = fireArm.Barrel.rotation; return(p); }
/* * void OnTriggerEnter(Collider other) * { * if (heldWeapon != null || !other.gameObject.CompareTag("Weapon")) * { * return; * } * * heldWeapon = other.gameObject; * } * * /* * void OnTriggerExit(Collider other) * { * if (heldWeapon!=null&&other.gameObject.CompareTag("Weapon")&&other.gameObject.Equals(heldWeapon)) * { * heldWeapon = null; * } * }*/ // Update is called once per frame void Update() { var device = SteamVR_Controller.Input((int)trackedObject.index); if (/*body != null && */ heldWeapon != null && device.GetPressDown(SteamVR_Controller.ButtonMask.Trigger)) { FireArm arm = heldWeapon.GetComponent <FireArm>(); arm.Fire(); device.TriggerHapticPulse(arm.PulseDuration()); } /*else if (body == null && heldWeapon != null && device.GetPressDown(SteamVR_Controller.ButtonMask.Grip)) * { * body = heldWeapon.GetComponent<Rigidbody>(); * body.transform.position = transform.position; * body.useGravity = false; * body.isKinematic = true; * body.transform.SetParent(transform); * joint.connectedBody = body; * body.isKinematic = true; * body.detectCollisions = true; * * } * else if (body != null && heldWeapon != null && device.GetPressUp(SteamVR_Controller.ButtonMask.Grip)) * { * body.velocity = device.velocity; * body.angularVelocity = device.angularVelocity; * body.useGravity = true; * body.isKinematic = false; * body.transform.parent = null; * body = null; * joint.connectedBody = null; * heldWeapon = null; * }*/ }
private void UpdateShootingPointHandBased() { //This point will be updated with the leap motion int index_finger = 1; GameObject weapon = fire_arms[weapon_in_use]; FireArm controller = weapon.GetComponent <FireArm>(); controller.UpdateShootingPoint(GetShootingPoint()); }
public PlayerState_Normal(Player p) { player = p; rigidbody = player.GetComponent<Rigidbody2D> (); fireDelayTimer = new CountdownTimer(); fireArm = player.gameObject.GetComponentInChildren<FireArm>(); animator = player.GetComponent<Animator>(); }
private void Start() { _player = FindObjectOfType <Player>(); _fireArm = Instantiate(_fireArms[Random.Range(0, _fireArms.Count)], _holder); _targetHead = Instantiate(_targetHeads[Random.Range(0, _targetHeads.Count)], _holder); _movementLeg = Instantiate(_movementLegs[Random.Range(0, _movementLegs.Count)], _holder); Instantiate(_ammoArms[Random.Range(0, _ammoArms.Count)], _holder); Instantiate(_statTorsos[Random.Range(0, _statTorsos.Count)], _holder); Instantiate(_statBoots[Random.Range(0, _statBoots.Count)], _holder); }
private void Start() { firearmScript = GetComponent <FireArm>(); gunCanvasCurrentAmmo.GetComponent <Text>().text = ammoInMagCurrent.ToString(); if (ammoPerShot <= 0) { gunCanvas.gameObject.SetActive(false); } }
public void Aim(bool aiming) { if (aiming) { if (inHand && inHand.GetType() == typeof(FireArm)) { FireArm fireArm = (FireArm)inHand; playerCamera.SetZoom(fireArm.zoomMultiplyer); } } else { playerCamera.SetZoom(0); } }
public void UpdateCurrentWeapon() { for (int i = 0; i < firearms.Count; i++) { if (currentWeaponIndex != i) { firearms[i].gameObject.SetActive(false); } else { firearms[i].gameObject.SetActive(true); fireArm = firearms[i].GetComponent <FireArm>(); journal.Instance.Log(fireArm.weponName); } } }
// Update is called once per frame void Update() { if (currentWeapon != null && fireArm != null) { ammoDisplay.SetActive(true); infinity.gameObject.SetActive(false); currentAmmo.SetText(fireArm.ammo.ToString()); totalAmmo.SetText(fireArm.reserveAmmo.ToString()); } else if (currentWeapon != null) { fireArm = currentWeapon.GetComponent <FireArm>(); if (fireArm == null) { ammoDisplay.SetActive(false); infinity.gameObject.SetActive(true); } } }
private void CheckGestures() { //This method checks if the trigger is pressed to to dath the angles of the index finger are analyzed FingerModel finger = hand_model.fingers[1]; float f2 = finger.GetFingerJointStretchMecanim(1); //Debug.Log("f1 "+f1+" f2 "+f2+" f3 "+f3); //78.0 limit value. if (f2 < -78.0f & ready_to_shoot) { Debug.Log("Shooting"); ready_to_shoot = false; FireArm arm = fire_arms[0].GetComponent <FireArm>(); arm.TriggerFire(); } if (f2 > -68.0f) { ReadyToShoot(); } }
public void ReloadFireArm() { try { FireArm fa = (FireArm)inHand; Magazine mag = _equipmentManager.ammoReserve.GetMagazine(fa.projectileType); if (mag) { fa.Reload(new object[] { mag, transform.position }); } else { Debug.Log("There are no magazines of the type " + fa.projectileType + " in the reserves"); } Debug.Log("Reload"); } catch (InvalidCastException) { Debug.Log("The item in hand is not a FireArm"); } }
public void setFireArm(FireArm newfirearm) { fireArm = newfirearm; }
private void Start() { fireArm = GetComponent <FireArm>(); }
void Start() { anim = GetComponent <Animator>(); fireArmScript = GetComponent <FireArm>(); }