void playHitSound(Weapon.TYPE weaponType, HitResult hitResult, Vector3 position) { // print ("playing hit sound"); AudioClip clip; List <AudioClips> soundClips = null; if (hitResult == HitResult.Hit) { soundClips = HitSound; } else if (hitResult == HitResult.Blocked) { soundClips = BlockedSound; } if (soundClips == null) { Debug.Log("Warning : no matching soundclip found"); return; } //get a random clip from the selection clip = soundClips.Where(x => x.Type == weaponType).ElementAt(0).Clips .ElementAt(Random.Range(0, soundClips.Where(x => x.Type == weaponType).ElementAt(0).Clips.Count)); AudioSource.PlayClipAtPoint(clip, position); }
public void AddAmmo(Weapon.TYPE weaponType,float percent) { if (!(equipments[(int)weaponType] == null)) { Gun component = equipments[(int)weaponType].GetComponent <Gun>(); if (component != null) { component.AddAmmo(percent); } } }
public void PlayHitSound(Weapon.TYPE weaponType, HitResult hitResult, Vector3 position) { if (PhotonNetwork.offlineMode) { playHitSound(weaponType, hitResult, position); } else { NetworkManager.SINGLETON.Targeted_RPC(photonView, "RPCPlayHitSound", weaponType, hitResult, position); } }
public Weapon GetWeaponBySlot(Weapon.TYPE weaponType) { Weapon[] componentsInChildren = GetComponentsInChildren <Weapon>(); foreach (Weapon weapon in componentsInChildren) { if (weapon.slot == weaponType) { return(weapon); } } return(null); }
public int GetWeaponQt(Weapon.TYPE _type) { foreach (Weapon VARIABLE in _weapons) { if (VARIABLE.Type == _type) { return(VARIABLE.Quantity); } } return(0); }
public int GetWeaponId(Weapon.TYPE _type) { foreach (Weapon VARIABLE in _weapons) { if (VARIABLE.Type == _type) { return(VARIABLE.Index); } } return(-1); }
public bool PickupFromFromInstance(long itemSeq) { Item itemBySequence = MyInfoManager.Instance.GetItemBySequence(itemSeq); if (itemBySequence == null) { return(false); } TWeapon tWeapon = (TWeapon)itemBySequence.Template; if (tWeapon == null) { return(false); } Weapon.TYPE weaponType = tWeapon.GetWeaponType(); string code = tWeapon.code; HideWeapon(equipments[(int)weaponType]); Object.DestroyImmediate(equipments[(int)weaponType]); if (weaponType == Weapon.TYPE.MAIN && WeaponLeft != null) { Object.DestroyImmediate(WeaponLeft); WeaponLeft = null; } GameObject gameObject = Equip(code); if (null == gameObject) { return(false); } WeaponFunction component = gameObject.GetComponent <WeaponFunction>(); if (null == component) { return(false); } component.ItemSeq = itemSeq; equipments[(int)weaponType] = gameObject; prevWeaponType = -1; currentWeaponType = (int)weaponType; WeaponChanger component2 = GetComponent <WeaponChanger>(); if (null != component2) { component2.Initialize(equipments); } return(true); }
public void AddWeapon(Weapon.TYPE _type, int _quantity) { bool _isPresent = false; foreach (Weapon wp in _weapons) { if (wp.Type == _type) { _isPresent = true; wp.Add(_quantity); break; } } if (!_isPresent) { _weapons.Add(new Weapon(_type, _quantity)); } }
private bool FillAmmo(Weapon.TYPE weaponType,TWeapon tWeapon) { if (tWeapon == null || equipments[(int)weaponType] == null) { return(false); } if (null == tWeapon.CurPrefab()) { return(false); } WeaponFunction component = tWeapon.CurPrefab().GetComponent <WeaponFunction>(); WeaponFunction component2 = equipments[(int)weaponType].GetComponent <WeaponFunction>(); if (component.weaponBy != component2.weaponBy || component2.IsFullAmmo()) { return(false); } component2.Reset(); return(true); }
public bool PickupFromTemplate(string weaponCode) { TWeapon tWeapon = TItemManager.Instance.Get <TWeapon>(weaponCode); if (tWeapon == null) { return(false); } Weapon.TYPE weaponType = tWeapon.GetWeaponType(); if (!IsEmptyHand(weaponType)) { return(FillAmmo(weaponType,tWeapon)); } equipments[(int)weaponType] = Equip(weaponCode); if (null == equipments[(int)weaponType]) { return(false); } prevWeaponType = -1; currentWeaponType = (int)weaponType; return(true); }
void RPCPlayHitSound(Weapon.TYPE weaponType, HitResult hitResult, Vector3 position) { playHitSound(weaponType, hitResult, position); }
public void ChangeWeapon(Weapon.TYPE weaponType) { if (!(null == rightHand) && (!(currentWeapon != null) || currentWeapon.slot != weaponType)) { Weapon weapon = null; if (weaponType == Weapon.TYPE.MODE_SPECIFIC) { VerifyClockBomb(); if (modeSpecific != null) { weapon = modeSpecific.GetComponent <Weapon>(); modeSpecific.SetActive(value: true); } } else if (RoomManager.Instance.CurrentRoomType == Room.ROOM_TYPE.BUNGEE && weaponType == Weapon.TYPE.MAIN && bungeeItemMain != null) { weapon = bungeeItemMain.GetComponent <Weapon>(); bungeeItemMain.SetActive(value: true); } else { Weapon[] componentsInChildren = GetComponentsInChildren <Weapon>(includeInactive: true); int num = 0; while (weapon == null && num < componentsInChildren.Length) { if (componentsInChildren[num].slot == weaponType && componentsInChildren[num].gameObject.layer == 0) { weapon = componentsInChildren[num]; } num++; } } SetActiveCurrentWeapon(state: true); Weapon componentInChildren = rightHand.GetComponentInChildren <Weapon>(); if (null != componentInChildren) { if (componentInChildren.slot == weaponType) { return; } if (componentInChildren.slot == Weapon.TYPE.MODE_SPECIFIC) { modeSpecific.SetActive(value: false); modeSpecific.transform.parent = null; } else if (RoomManager.Instance.CurrentRoomType == Room.ROOM_TYPE.BUNGEE && componentInChildren.slot == Weapon.TYPE.MAIN && bungeeItemMain != null) { bungeeItemMain.SetActive(value: false); bungeeItemMain.transform.parent = null; } else { Transform parent = base.transform.Find(((TWeapon)componentInChildren.tItem).bone); Attach(componentInChildren.transform, parent, Quaternion.Euler(componentInChildren.carryRotation)); TWeapon tWeapon = (TWeapon)componentInChildren.GetComponent <Weapon>().tItem; if (tWeapon != null && tWeapon.GetWeaponType() == Weapon.TYPE.MAIN && tWeapon.IsTwoHands && WeaponLeft != null) { Attach(WeaponLeft.transform, parent, Quaternion.Euler(currentWeaponLeft.carryRotation)); } } if (componentInChildren.slot == Weapon.TYPE.MAIN) { GdgtGun componentInChildren2 = componentInChildren.gameObject.GetComponentInChildren <GdgtGun>(); if (componentInChildren2 != null) { if (componentInChildren2.carryAnim) { componentInChildren.gameObject.animation.Play("carry"); } else { componentInChildren.gameObject.animation.Play("idle"); } } } } if (weapon == null) { Debug.LogError("Next Weapon is null " + weaponType); } else { currentWeapon = weapon; weapon.GetComponent <Weapon>().GadgetSound(Weapon.GADGET.BOLTUP); Attach(weapon.transform, rightHand, Quaternion.Euler(0f, 90f, 90f)); TWeapon tWeapon2 = (TWeapon)weapon.GetComponent <Weapon>().tItem; if (WeaponLeft != null && tWeapon2 != null && tWeapon2.IsTwoHands) { WeaponLeft.GetComponent <Weapon>().GadgetSound(Weapon.GADGET.BOLTUP); Attach(WeaponLeft.transform, leftHand, Quaternion.Euler(0f, 90f, 90f)); } if (weapon.slot == Weapon.TYPE.MAIN) { weapon.gameObject.animation.Play("idle"); if (tWeapon2 != null && tWeapon2.IsTwoHands) { WeaponLeft.gameObject.animation.Play("idle"); } } } } }
public bool IsEmptyHand(Weapon.TYPE weaponType) { return(equipments[(int)weaponType] == null); }