public static void ePickUpGun(bl_OnPickUpInfo e) { if (OnPickUpGun != null) { OnPickUpGun(e); } }
/// <summary> /// /// </summary> public void PickUpGun(bl_OnPickUpInfo e) { if (PUM == null) { Debug.LogError("Need a 'Pick Up Manager' in scene!"); return; } //If not already equip if (!PlayerEquip.Exists(x => x.GunID == e.ID)) { int actualID = PlayerEquip[m_Current].GunID; int nextID = AllGuns.FindIndex(x => x.GunID == e.ID); //Get Info int[] info = new int[2]; info[0] = PlayerEquip[m_Current].numberOfClips; info[1] = PlayerEquip[m_Current].bulletsLeft; PlayerEquip[m_Current] = AllGuns[nextID]; //Send Info AllGuns[nextID].numberOfClips = e.Clips; AllGuns[nextID].bulletsLeft = e.Bullets; StartCoroutine(PickUpGun((PlayerEquip[m_Current].gameObject), AllGuns[nextID].gameObject, actualID, info)); } else { foreach (bl_Gun g in PlayerEquip) { if (g == AllGuns[e.ID]) { bl_EventHandler.OnAmmo(3);//Add 3 clips } } } }
/// <summary> /// /// </summary> public void PickUpGun(bl_OnPickUpInfo e) { if (PUM == null) { Debug.LogError("Need a 'Pick Up Manager' in scene!"); return; } //If not already equip if (!PlayerEquip.Exists(x => x != null && x.GunID == e.ID)) { int actualID = (PlayerEquip[m_Current] == null) ? -1 : PlayerEquip[m_Current].GunID; int nextID = AllGuns.FindIndex(x => x.GunID == e.ID); //Get Info int[] info = new int[2]; int clips = (PlayerEquip[m_Current] == null) ? 3 : PlayerEquip[m_Current].numberOfClips; info[0] = clips; info[1] = (PlayerEquip[m_Current] == null) ? 30 : PlayerEquip[m_Current].bulletsLeft; bool replace = true; if (PlayerEquip.Exists(x => x == null)) { int nullId = PlayerEquip.FindIndex(x => x == null); PlayerEquip[nullId] = AllGuns[nextID]; replace = false; } else { PlayerEquip[m_Current] = AllGuns[nextID]; } //Send Info AllGuns[nextID].numberOfClips = e.Clips; AllGuns[nextID].bulletsLeft = e.Bullets; AllGuns[nextID].Setup(true); bl_UIReferences.Instance.PlayerUI.LoadoutUI.ReplaceSlot(m_Current, AllGuns[nextID]); StartCoroutine(PickUpGun((PlayerEquip[m_Current].gameObject), AllGuns[nextID].gameObject, actualID, info, replace)); } else { foreach (bl_Gun g in PlayerEquip) { if (g != null && g.GunID == e.ID) { g.OnPickUpAmmo(e.Bullets, e.Clips, 1); break; } } } }
void PickUp(string mName, int id, int[] info, PhotonMessageInfo msgInfo) { // one of the messages might be ours // note: you could check "active" first, if you're not interested in your own, failed pickup-attempts. GameObject g = GameObject.Find(mName); if (g == null) { Debug.LogError("This Gun does not exist in this scene"); return; } //is mine if (msgInfo.sender == PhotonNetwork.player) { bl_OnPickUpInfo pi = new bl_OnPickUpInfo(); pi.ID = id; pi.ItemObject = g; pi.Clips = info[0]; pi.Bullets = info[1]; bl_EventHandler.OnPickUpGun(pi); } Destroy(g); }