public void UnequipWeaponBySlot(int slot) { string itemCode = string.Empty; Equip[] componentsInChildren = GetComponentsInChildren <Equip>(); if (componentsInChildren != null) { for (int i = 0; i < componentsInChildren.Length; i++) { TWeapon tWeapon = componentsInChildren[i].tItem as TWeapon; if (tWeapon != null && tWeapon.GetWeaponType() == (Weapon.TYPE)slot) { itemCode = tWeapon.code; if (tWeapon != null && tWeapon.IsTwoHands && WeaponLeft != null) { Object.DestroyImmediate(WeaponLeft.gameObject); WeaponLeft = null; currentWeaponLeft = null; } break; } } } Unequip(itemCode); }
public static void PreWeaponTrackingUpdate() { string[] argArray = new string[WeaponItemNames.Count]; WeaponItemNames.Values.CopyTo(argArray, 0); IObject[] list = GlobalGame.GetObjectsByName(argArray); for (int i = 0; i < list.Length; i++) { IObject obj = list[i]; bool found = false; for (int j = 0; j < WeaponTrackingList.Count; j++) { if (WeaponTrackingList[j].Object == obj) { found = true; break; } } if (found) { continue; } TWeapon weapon = PlayerDropWeaponUpdate(obj.GetWorldPosition(), ((IObjectWeaponItem)obj).WeaponItem); if (weapon == null) { weapon = new TWeapon(((IObjectWeaponItem)obj).WeaponItem); } weapon.Object = obj; WeaponTrackingList.Add(weapon); } }
public string GetPriceString(int sel, BUY_HOW buyHow) { if (sel >= prices.Count) { return(string.Empty); } int percent = 0; if (BuildOption.Instance.Props.usePriceDiscount && tItem.type == TItem.TYPE.WEAPON) { TWeapon tWeapon = (TWeapon)tItem; percent = tWeapon.GetDiscountRatio(); } int num = 0; for (int i = 0; i < prices.Count; i++) { if (prices[i].CanBuy(buyHow)) { if (num == sel) { return(prices[i].GetPriceString(buyHow, percent)); } num++; } } return(string.Empty); }
public DroppedItem(int _itemSeq, string _itemCode, int _bulletCount, int _bulletCount2, float x, float y, float z) { itemSeq = _itemSeq; itemCode = _itemCode; bulletCount = _bulletCount; bulletCount2 = _bulletCount2; TWeapon tWeapon = TItemManager.Instance.Get <TWeapon>(itemCode); eff = (UnityEngine.Object.Instantiate((UnityEngine.Object)GlobalVars.Instance.droppedEff, new Vector3(x, y, z), Quaternion.Euler(0f, 0f, 0f)) as GameObject); obj = (UnityEngine.Object.Instantiate((UnityEngine.Object)tWeapon.CurPrefab()) as GameObject); obj.transform.position = new Vector3(x, y, z); obj.transform.rotation = Quaternion.Euler(0f, 0f, 0f); obj.GetComponent <WeaponGadget>().enabled = true; obj.GetComponent <WeaponFunction>().enabled = false; obj.GetComponent <WeaponFunction>().ItemSeq = itemSeq; Aim component = obj.GetComponent <Aim>(); if (null != component) { component.enabled = false; } Scope component2 = obj.GetComponent <Scope>(); if (null != component2) { component2.enabled = false; } Recursively.SetLayer(obj.GetComponent <Transform>(), LayerMask.NameToLayer("Default")); }
public bool ChangeDropWeapon(string nextCode) { TWeapon tWeapon = TItemManager.Instance.Get <TWeapon>(nextCode); if (tWeapon == null) { return(false); } int[] array = new int[6] { -1, -1, 2, 1, 0, 3 }; int num = (int)tWeapon.slot; if (num < 0 || num >= array.Length) { return(false); } int num2 = array[num]; if (num2 < 0 || num2 >= drpItm.Length) { return(false); } drpItm[num2] = nextCode; return(true); }
private bool IsLock(TWeapon tWeapon) { int weaponOption = RoomManager.Instance.GetCurrentRoomInfo().weaponOption; switch (weaponOption) { case 0: return(false); case 1: if (tWeapon.cat == 4) { return(false); } if (tWeapon.cat == 5) { return(false); } break; } if (weaponOption == 2 && tWeapon.cat == 5) { return(false); } return(true); }
private void CheckBoxmen() { HitPart[] array = ExplosionUtil.CheckBoxmen(base.transform.position, Radius, includeFriendly: false); for (int i = 0; i < array.Length; i++) { PlayerProperty[] allComponents = Recursively.GetAllComponents <PlayerProperty>(array[i].transform, includeInactive: false); if (allComponents.Length == 1) { int num = Mathf.FloorToInt(array[i].damageFactor * CalcPowFrom(array[i].transform.position)); if (num > 0) { WeaponFunction component = GetComponent <WeaponFunction>(); if (null == component) { Debug.LogError("wpnFunc == null"); } TWeapon tWeapon = (TWeapon)GetComponent <Weapon>().tItem; if (tWeapon == null) { Debug.LogError("wpn == null"); } Item item = MyInfoManager.Instance.GetItemBySequence(component.ItemSeq); if (item == null) { item = MyInfoManager.Instance.GetUsingEquipByCode(tWeapon.code); } num = GlobalVars.Instance.applyDurabilityDamage(item?.Durability ?? (-1), tWeapon.durabilityMax, num); P2PManager.Instance.SendPEER_BOMBED(MyInfoManager.Instance.Seq, allComponents[0].Desc.Seq, num, Rigidity, (int)weaponBy); } } } }
public static TWeapon PlayerPickUpWeaponUpdate(Vector2 pos, WeaponItem id) { if (WeaponTrackingList.Count == 0) { return(null); } float dist = 16; TWeapon weapon = null; int index = 0; for (int i = 0; i < WeaponTrackingList.Count; i++) { if (!WeaponTrackingList[i].Object.RemovalInitiated) { continue; } float currentDist = (pos - WeaponTrackingList[i].Position).Length(); if (WeaponTrackingList[i].Weapon == id && currentDist <= dist) { weapon = WeaponTrackingList[i]; dist = currentDist; index = i; } } if (weapon == null) { return(null); } WeaponTrackingList.RemoveAt(index); return(weapon); }
private void EquipWeapon(string itemCode, int player = -1) { TWeapon tWeapon = TItemManager.Instance.Get <TWeapon>(itemCode); if (tWeapon != null) { Transform transform = base.transform.Find(tWeapon.bone); if (null == transform) { Debug.LogError("Fail to find the bone " + tWeapon.bone); } else { GameObject gameObject = Object.Instantiate((Object)tWeapon.CurPrefab()) as GameObject; Attach(gameObject.transform, transform, Quaternion.Euler(gameObject.GetComponent <Weapon>().carryRotation)); gameObject.GetComponent <Equip>().tItem = tWeapon; gameObject.GetComponent <WeaponGadget>().enabled = true; gameObject.GetComponent <WeaponFunction>().enabled = false; Aim component = gameObject.GetComponent <Aim>(); if (null != component) { component.enabled = false; } Scope component2 = gameObject.GetComponent <Scope>(); if (null != component2) { component2.enabled = false; } if (tWeapon.IsTwoHands) { WeaponLeft = (Object.Instantiate((Object)tWeapon.CurPrefab()) as GameObject); Attach(WeaponLeft.transform, transform, Quaternion.Euler(WeaponLeft.GetComponent <Weapon>().carryRotation)); currentWeaponLeft = WeaponLeft.GetComponent <Weapon>(); WeaponLeft.GetComponent <Equip>().tItem = tWeapon; WeaponLeft.GetComponent <WeaponGadget>().enabled = true; WeaponLeft.GetComponent <WeaponFunction>().enabled = false; WeaponLeft.GetComponent <GdgtGun>().LeftHand = true; component = WeaponLeft.GetComponent <Aim>(); if (null != component) { component.enabled = false; } component2 = WeaponLeft.GetComponent <Scope>(); if (null != component2) { component2.enabled = false; } GlobalVars.Instance.SetOullineColor(player, WeaponLeft); } if (isMirror) { BroadcastMessage("OnChangeCostume", tWeapon.slot); } GlobalVars.Instance.SetOullineColor(player, gameObject); } } }
private void Modify() { WeaponFunction component = GetComponent <WeaponFunction>(); if (null != component) { WpnMod wpnMod = WeaponModifier.Instance.Get((int)component.weaponBy); if (wpnMod != null) { maxAmmo = wpnMod.maxAmmo; explosionTime = wpnMod.explosionTime; speedFactor = wpnMod.fSpeedFactor; AtkPow = wpnMod.fAtkPow; Rigidity = wpnMod.fRigidity; throwForce = wpnMod.fThrowForce; Radius = wpnMod.radius; } WpnModEx ex = WeaponModifier.Instance.GetEx((int)component.weaponBy); if (ex != null) { persistTime = ex.persistTime; } TWeapon tWeapon = (TWeapon)GetComponent <Weapon>().tItem; Item item = MyInfoManager.Instance.GetItemBySequence(component.ItemSeq); if (item == null) { item = MyInfoManager.Instance.GetUsingEquipByCode(tWeapon.code); } if (item != null) { int num = 0; int grade = item.upgradeProps[num].grade; if (grade > 0) { float value = PimpManager.Instance.getValue((int)tWeapon.upgradeCategory, num, grade - 1); AtkPow += value; } num = 6; grade = item.upgradeProps[num].grade; if (grade > 0) { float value2 = PimpManager.Instance.getValue((int)tWeapon.upgradeCategory, num, grade - 1); throwForce += value2; } num = 7; grade = item.upgradeProps[num].grade; if (grade > 0) { float value3 = PimpManager.Instance.getValue((int)tWeapon.upgradeCategory, num, grade - 1); Radius += value3; } } } }
public void SetActiveCurrentWeapon(bool state) { if (currentWeapon != null) { currentWeapon.gameObject.SetActive(state); TWeapon tWeapon = currentWeapon.tItem as TWeapon; if (tWeapon != null && tWeapon.IsTwoHands && currentWeaponLeft != null) { currentWeaponLeft.gameObject.SetActive(state); } } }
public static TWeapon PlayerDropWeaponUpdate(Vector2 pos, WeaponItem id) { float dist = 16; TPlayer player = null; TWeapon weapon = null; for (int i = 0; i < PlayerList.Count; i++) { float currentDist = (pos - PlayerList[i].Position).Length(); if (currentDist <= dist) { bool hasWeapon = false; IPlayer pl = PlayerList[i].User.GetPlayer(); if (PlayerList[i].PrimaryWeapon != null && PlayerList[i].PrimaryWeapon.Weapon == id && (pl != null && pl.CurrentPrimaryWeapon.WeaponItem == WeaponItem.NONE) || pl == null) { hasWeapon = true; } else if (PlayerList[i].SecondaryWeapon != null && PlayerList[i].SecondaryWeapon.Weapon == id && (pl != null && pl.CurrentSecondaryWeapon.WeaponItem == WeaponItem.NONE) || pl == null) { hasWeapon = true; } else if (PlayerList[i].ThrownWeapon != null && PlayerList[i].ThrownWeapon.Weapon == id && (pl != null && pl.CurrentThrownItem.WeaponItem == WeaponItem.NONE) || pl == null) { hasWeapon = true; } if (hasWeapon) { player = PlayerList[i]; dist = currentDist; } } } if (player == null) { return(null); } if (player.PrimaryWeapon != null && player.PrimaryWeapon.Weapon == id) { weapon = player.PrimaryWeapon; player.PrimaryWeapon = null; } else if (player.SecondaryWeapon != null && player.SecondaryWeapon.Weapon == id) { weapon = player.SecondaryWeapon; player.SecondaryWeapon = null; } else if (player.ThrownWeapon != null && player.ThrownWeapon.Weapon == id) { weapon = player.ThrownWeapon; player.ThrownWeapon = null; } return(weapon); }
private void DoWeaponSlots() { Rect position = new Rect((size.x - crdSlotOutline.x) / 2f, 49f, crdSlotOutline.x, crdSlotOutline.y); Rect position2 = new Rect((size.x - crdWeaponSlotList.x) / 2f, 59f, crdWeaponSlotList.x, crdWeaponSlotList.y); GUI.Box(position, string.Empty, "BoxInnerLine"); GUI.BeginGroup(position2); for (int i = 0; i < MyInfoManager.Instance.WeaponSlots.Length; i++) { float x = (float)(i % 5) * (crdSlotBtn.x + 8f); float y = (float)(i / 5) * (crdSlotBtn.y + 8f); Rect rect = new Rect(x, y, crdSlotBtn.x, crdSlotBtn.y); TWeapon tWeapon = null; Item itemBySequence = MyInfoManager.Instance.GetItemBySequence(MyInfoManager.Instance.WeaponSlots[i]); if (itemBySequence != null && !itemBySequence.IsAmount && itemBySequence.Template != null && itemBySequence.Template.type == TItem.TYPE.WEAPON) { tWeapon = (TWeapon)itemBySequence.Template; } Texture2D icon = null; if (itemBySequence != null && tWeapon != null) { icon = tWeapon.CurIcon(); } string str = "BtnItemFixate"; if (GUI.Button(rect, string.Empty, str)) { ChangeWeapon(i); } DrawSlotIcon(itemBySequence, icon, rect); LabelUtil.TextOut(new Vector2(rect.x, rect.y + 5f), custom_inputs.Instance.GetKeyCodeName(key[i]), "MiniLabel", GlobalVars.Instance.txtMainColor, GlobalVars.txtEmptyColor, TextAnchor.UpperLeft); if (tWeapon != null && IsLock(tWeapon)) { TextureUtil.DrawTexture(new Rect(rect.x + (rect.width - (float)(slotLock.width / 2)) / 2f, rect.y + (rect.height - (float)(slotLock.height / 2)) / 2f, (float)(slotLock.width / 2), (float)(slotLock.height / 2)), slotLock); } bool flag = false; if (i >= 5) { TextureUtil.DrawTexture(new Rect(rect.x + rect.width - (float)premiumIcon.width - 5f, rect.y, (float)premiumIcon.width, (float)premiumIcon.height), premiumIcon); if (!premiumAccount) { flag = true; TextureUtil.DrawTexture(new Rect(rect.x + (rect.width - (float)(slotLock.width / 2)) / 2f, rect.y + (rect.height - (float)(slotLock.height / 2)) / 2f, (float)(slotLock.width / 2), (float)(slotLock.height / 2)), slotLock); } } if (!flag && itemBySequence != null && itemBySequence.IsLimitedByStarRate) { flag = true; TextureUtil.DrawTexture(new Rect(rect.x + (rect.width - crdLock.width) / 2f, rect.y + (rect.height - crdLock.height) / 2f, crdLock.width, crdLock.height), slotLock); } } GUI.EndGroup(); }
public override string ToString() { TWeapon tWeapon = TItemManager.Instance.Get <TWeapon>(code); if (tWeapon == null) { return(string.Empty); } string key = (diff <= 0) ? "REPAIR_EVENT" : "DECAY_EVENT"; float num = (float)durability / (float)tWeapon.durabilityMax * 100f; float num2 = (float)Mathf.Abs(diff) / (float)tWeapon.durabilityMax * 100f; return(string.Format(StringMgr.Instance.Get(key), tWeapon.Name, num.ToString("0.##"), num2.ToString("0.##"))); }
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); }
private GameObject Equip(string itemCode) { TWeapon tWeapon = TItemManager.Instance.Get <TWeapon>(itemCode); if (tWeapon != null) { return(AttachWeapon(tWeapon.CurPrefab(),tWeapon)); } GameObject gameObject = TItemManager.Instance.FindPrefab(itemCode); if (null != gameObject) { return(AttachWeapon(gameObject,null)); } return(null); }
private void DoWeapon(TWeapon tWeapon) { if (tWeapon.CurPrefab() != null) { Weapon component = tWeapon.CurPrefab().GetComponent <Weapon>(); if (null == component) { Debug.LogError("Error, Fail to get weapon component from prefab "); } else { switch (component.slot) { case Weapon.TYPE.MAIN: LabelUtil.TextOut(crdExpl, StringMgr.Instance.Get("MAIN_WEAPON"), "MiniLabel", Color.white, GlobalVars.txtEmptyColor, TextAnchor.UpperLeft); DoGunProperty(tWeapon.CurPrefab().GetComponent <Gun>(), tWeapon.CurPrefab().GetComponent <Scope>(), tWeapon.CurPrefab().GetComponent <Aim>()); break; case Weapon.TYPE.AUX: LabelUtil.TextOut(crdExpl, StringMgr.Instance.Get("AUX_WEAPON"), "MiniLabel", Color.white, GlobalVars.txtEmptyColor, TextAnchor.UpperLeft); DoGunProperty(tWeapon.CurPrefab().GetComponent <Gun>(), tWeapon.CurPrefab().GetComponent <Scope>(), tWeapon.CurPrefab().GetComponent <Aim>()); break; case Weapon.TYPE.MELEE: LabelUtil.TextOut(crdExpl, StringMgr.Instance.Get("MELEE_WEAPON"), "MiniLabel", Color.white, GlobalVars.txtEmptyColor, TextAnchor.UpperLeft); DoMeleeProperty(tWeapon.CurPrefab().GetComponent <MeleeWeapon>()); break; case Weapon.TYPE.PROJECTILE: { LabelUtil.TextOut(crdExpl, StringMgr.Instance.Get("SPEC_WEAPON"), "MiniLabel", Color.white, GlobalVars.txtEmptyColor, TextAnchor.UpperLeft); Grenade component2 = tWeapon.CurPrefab().GetComponent <Grenade>(); if (component2 != null) { DoGrenade(component2); } HandBomb component3 = tWeapon.CurPrefab().GetComponent <HandBomb>(); if (component3 != null) { DoHandBomb(component3); } break; } } } } }
public void Respawn(bool full = true) { JumpCount = 0; MeleeDamageTaken = 0; ProjectileDamageTaken = 0; ExplosionDamageTaken = 0; FallDamageTaken = 0; BlocksCount = 0; FireDamageTaken = 0; DelayedDamage = 0; Bleeding = false; Status = 0; IsDiving = false; StatusDisplay.SetText(""); PrimaryWeapon = null; SecondaryWeapon = null; ThrownWeapon = null; InSmoke = 0; StunTime = 0; if (full) { Equipment.Clear(); ProjectileDamageFactor = 5.75f; FallDamageFactor = 3.5f; MeleeDamageFactor = 2f; ExplosionDamageFactor = 7.5f; FireDamageFactor = 3; Hp = 100; DyingChance = 75; AliveChance = 50; OvercomeChance = 25; WeaponBreakingChance = 15; WeaponExplosionChance = 50; IsSlow = false; StartBleedingProjectile = 15; StartBleedingMelee = 20; DyingHealth = 5; StableHealth = 10; OvercomeHealth = 20; ReviveHealth = 40; DyingSpeed = 0.007f; OvercomeSpeed = 0.1f; IsAdrenaline = false; AdrenalineDamageFactor = 0.5f; DamageDelaySpeed = 0.5f; } }
private void Modify() { if (RoomManager.Instance.CurrentRoomType != Room.ROOM_TYPE.BUNGEE) { WeaponFunction component = GetComponent <WeaponFunction>(); if (null != component) { WpnMod wpnMod = WeaponModifier.Instance.Get((int)component.weaponBy); if (wpnMod != null) { maxAmmo = wpnMod.maxAmmo; explosionTime = wpnMod.explosionTime; speedFactor = wpnMod.fSpeedFactor; throwForce = wpnMod.fThrowForce; } WpnModEx ex = WeaponModifier.Instance.GetEx((int)component.weaponBy); if (ex != null) { persistTime = ex.persistTime; } TWeapon tWeapon = (TWeapon)GetComponent <Weapon>().tItem; Item item = MyInfoManager.Instance.GetItemBySequence(component.ItemSeq); if (item == null) { item = MyInfoManager.Instance.GetUsingEquipByCode(tWeapon.code); } if (item != null) { int num = 0; int grade = item.upgradeProps[num].grade; if (grade > 0) { float value = PimpManager.Instance.getValue((int)tWeapon.upgradeCategory, num, grade - 1); throwForce += value; } num = 8; grade = item.upgradeProps[num].grade; if (grade > 0) { float num2 = persistTime = PimpManager.Instance.getValue((int)tWeapon.upgradeCategory, num, grade - 1); } } } } }
private GameObject AttachWeapon(GameObject weaponPrefab,TWeapon tItem) { if (null == weaponPrefab || null == rightHand) { return(null); } GameObject gameObject = Object.Instantiate((Object)weaponPrefab) as GameObject; gameObject.GetComponent <Weapon>().tItem = tItem; gameObject.GetComponent <WeaponFunction>().enabled = true; gameObject.GetComponent <WeaponFunction>().SetDrawn(draw: false); if (tItem != null && tItem.IsTwoHands) { WeaponLeft = (Object.Instantiate((Object)weaponPrefab) as GameObject); WeaponLeft.GetComponent <Weapon>().tItem = tItem; WeaponLeft.GetComponent <WeaponFunction>().enabled = true; WeaponLeft.GetComponent <WeaponFunction>().SetDrawn(draw: false); WeaponLeft.GetComponent <Gun>().LeftHand = true; WeaponLeft.GetComponent <Gun>().TwoHands = true; } if (RoomManager.Instance.CurrentRoomType != 0 && tItem != null) { gameObject.GetComponent <WeaponFunction>().category = tItem.cat; if (WeaponLeft != null) { WeaponLeft.GetComponent <WeaponFunction>().category = tItem.cat; } } Recursively.SetLayer(gameObject.GetComponent <Transform>(),LayerMask.NameToLayer("FPWeapon")); if (WeaponLeft != null) { Recursively.SetLayer(WeaponLeft.GetComponent <Transform>(),LayerMask.NameToLayer("FPWeapon")); } Attach(gameObject.transform,rightHand,Quaternion.Euler(0f,90f,90f)); if (WeaponLeft != null) { Attach(WeaponLeft.transform,leftHand,Quaternion.Euler(0f,90f,90f)); } gameObject.SetActive(value: false); if (WeaponLeft != null) { WeaponLeft.SetActive(value: false); } return(gameObject); }
private int DoWeapon(TWeapon tWeapon) { int result = 0; if (tWeapon.CurPrefab() != null) { Weapon component = tWeapon.CurPrefab().GetComponent <Weapon>(); if (null == component) { Debug.LogError("Error, Fail to get weapon component from prefab "); } else { result = tWeapon.GetDiscountRatio(); } } return(result); }
public string GetDefaultBrickPrice() { BUY_HOW buyHow = BUY_HOW.BRICK_POINT; PriceTag defaultPriceTag = GetDefaultPriceTag(buyHow); if (defaultPriceTag == null) { return(string.Empty); } int percent = 0; if (tItem.type == TItem.TYPE.WEAPON) { TWeapon tWeapon = (TWeapon)tItem; percent = tWeapon.GetDiscountRatio(); } return(defaultPriceTag.GetPriceString(buyHow, percent)); }
public string GetDefaultTokenPrice() { BUY_HOW buyHow = BUY_HOW.CASH_POINT; PriceTag defaultPriceTag = GetDefaultPriceTag(buyHow); if (defaultPriceTag == null) { return(string.Empty); } int percent = 0; if (BuildOption.Instance.Props.usePriceDiscount && tItem.type == TItem.TYPE.WEAPON) { TWeapon tWeapon = (TWeapon)tItem; percent = tWeapon.GetDiscountRatio(); } return(defaultPriceTag.GetPriceString(buyHow, percent)); }
public Good[] GetGoodsByCat(int catType, int catKind, int classify, int category, int myLevel) { List <Good> list = new List <Good>(); foreach (KeyValuePair <string, Good> item in dic) { if (item.Value.tItem.catType == catType && item.Value.IsVisible() && (catKind <= 0 || item.Value.tItem.catKind == catKind)) { switch (classify) { case 1: if (!item.Value.IsCashable) { goto default; } goto case 0; default: if ((classify != 2 || !item.Value.IsPointable) && (classify != 3 || !item.Value.IsBrickPointable)) { break; } goto case 0; case 0: if (category >= 0) { TWeapon tWeapon = (TWeapon)item.Value.tItem; if (tWeapon.cat == category) { list.Add(item.Value); } } else { list.Add(item.Value); } break; } } } list.Sort((Good prev, Good next) => prev.Compare(next, myLevel)); return(list.ToArray()); }
public static bool IsPlayerDropWeapon(Vector2 pos, WeaponItem id) { float dist = 16; TWeapon weapon = null; for (int i = 0; i < WeaponTrackingList.Count; i++) { if (!WeaponTrackingList[i].Object.RemovalInitiated) { continue; } float currentDist = (pos - WeaponTrackingList[i].Position).Length(); if (WeaponTrackingList[i].Weapon == id && currentDist <= dist) { weapon = WeaponTrackingList[i]; dist = currentDist; } } return(weapon != null); }
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 void SwapWeapon(long itemSeq,string itemCode,int ammo,int ammo2) { TWeapon tWeapon = TItemManager.Instance.Get <TWeapon>(itemCode); if (tWeapon != null) { int weaponType = (int)tWeapon.GetWeaponType(); GlobalVars.Instance.DropWeapon(weaponType); HideWeapon(equipments[weaponType]); Object.DestroyImmediate(equipments[weaponType]); equipments[weaponType] = null; if (weaponType == 2 && WeaponLeft != null) { Object.DestroyImmediate(WeaponLeft); WeaponLeft = null; } GameObject gameObject = Equip(itemCode); WeaponFunction component = gameObject.GetComponent <WeaponFunction>(); if (!(null == component)) { component.ItemSeq = itemSeq; equipments[weaponType] = gameObject; prevWeaponType = -1; currentWeaponType = weaponType; WeaponChanger component2 = GetComponent <WeaponChanger>(); if (null != component2) { component2.Initialize(equipments); component2.Swap(); } GetComponent <LocalController>().SwitchWeapon(); GetComponent <LocalController>().ToIdle(); Gun component3 = equipments[weaponType].GetComponent <Gun>(); if (component3 != null) { component3.PickedAmmo = ammo; component3.PickedAmmo2 = ammo2; } } } }
public TWeapon[] GetCompleteWeaponArray() { List <TWeapon> list = new List <TWeapon>(); foreach (KeyValuePair <string, TItem> item2 in dic) { if (item2.Value.type == TItem.TYPE.WEAPON && item2.Value.CurIcon() != null) { list.Add((TWeapon)item2.Value); } } foreach (KeyValuePair <string, TItem> item3 in dic) { if (item3.Value.code == "s09" && item3.Value.CurIcon() != null) { TWeapon item = new TWeapon(item3.Value.code, item3.Value.name, string.Empty, null, null, item3.Value.CurIcon(), item3.Value.CurIcon(), 0, 0, 0, itemTakeoffable: false, TItem.SLOT.UPPER,string.Empty,null,itemDiscomposable: false,string.Empty,0,0,basic: false,0,"none","none","none",twohands: false,item3.Value._StarRate); list.Add(item); } } return(list.ToArray()); }
private void ChangeWeapon(int slot) { if (slot >= 0 && slot < 10) { if (slot >= 5 && !premiumAccount) { SystemMsgManager.Instance.ShowMessage(StringMgr.Instance.Get("ERR_WPN_CHG_PREMIUM_ONLY")); } else { long num = MyInfoManager.Instance.WeaponSlots[slot]; Item itemBySequence = MyInfoManager.Instance.GetItemBySequence(num); if (itemBySequence != null && itemBySequence.IsWeaponSlotAble) { TWeapon tWeapon = (TWeapon)itemBySequence.Template; if (!IsLock(tWeapon)) { Item currentWeaponBySlot = MyInfoManager.Instance.GetCurrentWeaponBySlot(tWeapon.slot); if (currentWeaponBySlot != null && currentWeaponBySlot.Template.type == TItem.TYPE.WEAPON) { TWeapon tWeapon2 = (TWeapon)currentWeaponBySlot.Template; if (currentWeaponBySlot.Seq == num) { SystemMsgManager.Instance.ShowMessage(StringMgr.Instance.Get("ERR_WPN_CHG_SAME_WEAPON")); } else if (itemBySequence.IsLimitedByStarRate) { SystemMsgManager.Instance.ShowMessage(StringMgr.Instance.Get("WEAPON_STAR_LIMIT")); } else { done = true; CSNetManager.Instance.Sock.SendCS_WEAPON_CHANGE_REQ(slot, num, tWeapon.code, tWeapon2.code); } } } } } } }
private void Modify() { WeaponFunction component = GetComponent <WeaponFunction>(); if (null != component) { WpnMod wpnMod = WeaponModifier.Instance.Get((int)component.weaponBy); if (wpnMod != null) { accuracy.accuracy = wpnMod.fZAccuracy; accuracy.accurateMin = wpnMod.fZAccurateMin; accuracy.accurateMax = wpnMod.fZAccurateMax; accuracy.inaccurateMin = wpnMod.fZInaccurateMin; accuracy.inaccurateMax = wpnMod.fZInaccurateMax; accuracy.accurateSpread = wpnMod.fZAccurateSpread; accuracy.accurateCenter = wpnMod.fZAccurateCenter; accuracy.inaccurateSpread = wpnMod.fZInaccurateSpread; accuracy.inaccurateCenter = wpnMod.fZInaccurateCenter; accuracy.moveInaccuracyFactor = wpnMod.fZMoveInaccuracyFactor; fov = wpnMod.fZFov; camSpeed = wpnMod.fZCamSpeed; } TWeapon tWeapon = (TWeapon)GetComponent <Weapon>().tItem; Item item = MyInfoManager.Instance.GetItemBySequence(component.ItemSeq); if (item == null) { item = MyInfoManager.Instance.GetUsingEquipByCode(tWeapon.code); } if (item != null) { int num = 1; int grade = item.upgradeProps[num].grade; if (grade > 0) { float value = PimpManager.Instance.getValue((int)tWeapon.upgradeCategory, num, grade - 1); accuracy.accuracy += value; } } } }