void TrowGunRPC(int id, Vector3 point, string prefix, int[] info, bool AutoDestroy) { GameObject trow = null; bl_GunInfo ginfo = GameData.GetWeapon(id); if (ginfo.PickUpPrefab == null) { Debug.LogError(string.Format("The weapon: '{0}' not have a pick up prefab in Gun info", ginfo.Name)); return; } trow = ginfo.PickUpPrefab.gameObject; GameObject p = FindPlayerRoot(info[2]); GameObject gun = Instantiate(trow, point, Quaternion.identity) as GameObject; Collider[] c = p.GetComponentsInChildren <Collider>(); for (int i = 0; i < c.Length; i++) { Physics.IgnoreCollision(c[i], gun.GetComponent <Collider>()); } gun.GetComponent <Rigidbody>().AddForce(p.transform.forward * ForceImpulse); int clips = info[0]; bl_GunPickUp gp = gun.GetComponent <bl_GunPickUp>(); gp.Info.Clips = clips; gp.Info.Bullets = info[1]; gp.AutoDestroy = AutoDestroy; gun.name = gun.name.Replace("(Clone)", string.Empty); gun.name += prefix; gun.transform.parent = transform; }
private void OnEnable() { script = (bl_GunPickUp)target; info = bl_GameData.Instance.GetWeapon(script.GunID); if (script.m_DetectMode == bl_GunPickUp.DetectMode.Trigger) { if (script.gameObject.layer != LayerMask.NameToLayer("Ignore Raycast")) { script.gameObject.layer = LayerMask.NameToLayer("Ignore Raycast"); } } else { if (script.gameObject.layer == LayerMask.NameToLayer("Ignore Raycast")) { script.gameObject.layer = 0; } SphereCollider sc = script.GetComponent <SphereCollider>(); Rigidbody rb = script.GetComponent <Rigidbody>(); BoxCollider bc = script.GetComponent <BoxCollider>(); if (sc != null && sc.radius < 0.5f) { sc.radius += 0.2f; } if (sc == null || rb == null || bc == null) { isSetUp = false; } } }
/// <summary> /// /// </summary> void Fire() { Ray r = new Ray(transform.position, transform.forward); if (Physics.Raycast(r, out RayHit, DistanceCheck, DetectLayers, QueryTriggerInteraction.Ignore)) { OnHit(); } else { if (gunPickup != null) { gunPickup.FocusThis(false); gunPickup = null; } } }
/// <summary> /// /// </summary> void OnHit() { bl_GunPickUp gp = RayHit.transform.GetComponent <bl_GunPickUp>(); if (gp != null) { if (gunPickup != null && gunPickup != gp) { gunPickup.FocusThis(false); } gunPickup = gp; gunPickup.FocusThis(true); } else { if (gunPickup != null) { gunPickup.FocusThis(false); gunPickup = null; } } }
public void SetPickUp(bool show, int id = 0, bl_GunPickUp gun = null, bool equiped = false) { if (show) { bl_GunInfo info = bl_GameData.Instance.GetWeapon(id); #if LOCALIZATION string t = (equiped) ? string.Format(LocaleStrings[7], info.Name) : string.Format(LocaleStrings[8], bl_GameData.Instance.GetWeapon(id).Name); #else string t = (equiped) ? string.Format(bl_GameTexts.PickUpWeaponEquipped, info.Name) : string.Format(bl_GameTexts.PickUpWeapon, bl_GameData.Instance.GetWeapon(id).Name); #endif PlayerUI.PickUpText.text = t.ToUpper(); PlayerUI.PickUpUI.SetActive(true); if (PlayerUI.PickUpIconUI != null) { PlayerUI.PickUpIconUI.transform.GetChild(0).GetComponent <Image>().sprite = info.GunIcon; PlayerUI.PickUpIconUI.SetActive(info.GunIcon != null); } } else { PlayerUI.PickUpUI.SetActive(false); } CacheGunPickUp = gun; }