private void ShootingSystem() { if (fireArm.GetAmmo().GetClipSize() > 0) { fireArm.GetAmmo().SetClipSize(fireArm.GetAmmo().GetClipSize() - 1); RaycastHit[] hits = new RaycastHit[10]; Ray ray = new Ray(fireArm.GetFirePoint().position, fireArm.GetFirePointDirection()); hits = Physics.RaycastAll(ray, fireArm.GetShootingDistance(), fireArm.GetShootingLayers()); for (int i = 0; i < hits.Length; i++) { RaycastHit hit = hits[i]; Rigidbody rb = hit.collider.GetComponent <Rigidbody>(); Pedestrian.Pedestrian ped = hit.collider.GetComponentInParent <Pedestrian.Pedestrian>(); WeaponBehaviour wep = hit.collider.GetComponent <WeaponBehaviour>(); if (wep != null) { GetOwnerBehaviorValue().SetOwned(false); Rigidbody rbp = wep.GetComponentInParent <Rigidbody>(); if (rbp != null) { rbp.AddForce(-hit.normal * fireArm.GetForce()); } } if (rb != null) { rb.AddForce(-hit.normal * fireArm.GetForce()); } Debug.Log(hit.collider.gameObject.name); if (ped != null) { if (GetComponent <WeaponBehaviour>() != ped.GetWeapon()) { ped.SetHealth(ped.GetHealth() - 36); } } } } }
void Fire(int type) { Pedestrian.Pedestrian ped = GetComponentInParent <Pedestrian.Pedestrian>(); if (type == 0) { if (ped != null) { if (ped.IsFPS() == true) { ped.Fire(); } } } else if (type == 1) { if (ped != null) { if (ped.IsFPS() == false) { ped.Fire(); } } } }