public void SelectWeaponAction(int selectedWeapon) { if (selectedWeapon == 1 && firstWeapon != null) { objWeapon = Instantiate(firstWeapon.weaponPrefab, weaponPoint); objWeapon.transform.localPosition = firstWeapon.weaponPos; objWeapon.transform.localRotation = Quaternion.Euler(firstWeapon.weaponRot.x, firstWeapon.weaponRot.y, firstWeapon.weaponRot.z); activeShootWeapon = objWeapon.GetComponent <ShootWeapon>(); activeShootWeapon.ammoSlider = ammoSlider; ammoSlider.value = 0; if (activeShootWeapon.sniperCam != null) { characterStatus.sniper = true; sniperCam = activeShootWeapon.sniperCam; } characterIK.rHand.localPosition = firstWeapon.rHandPos; rotRight = Quaternion.Euler(firstWeapon.rHandRot.x, firstWeapon.rHandRot.y, firstWeapon.rHandRot.z); characterIK.rHand.localRotation = rotRight; activeShootWeapon.targetLook = targetLook; activeShootWeapon.cameraMain = cameraSystem; characterInput.shootWeapon = activeShootWeapon; characterIK.lHandTarget = activeShootWeapon.leftHandTarget; characterInput.SetShootDelegate(firstWeapon.type); anim.SetBool("Weapon", true); anim.SetInteger("WeaponType", 2); } if (selectedWeapon == 2 && secondWeapon != null) { objWeapon = Instantiate(secondWeapon.weaponPrefab, weaponPoint); objWeapon.transform.localPosition = secondWeapon.weaponPos; objWeapon.transform.localRotation = Quaternion.Euler(secondWeapon.weaponRot.x, secondWeapon.weaponRot.y, secondWeapon.weaponRot.z); activeShootWeapon = objWeapon.GetComponent <ShootWeapon>(); activeShootWeapon.ammoSlider = ammoSlider; ammoSlider.value = 0; characterIK.rHand.localPosition = secondWeapon.rHandPos; rotRight = Quaternion.Euler(secondWeapon.rHandRot.x, secondWeapon.rHandRot.y, secondWeapon.rHandRot.z); characterIK.rHand.localRotation = rotRight; activeShootWeapon.targetLook = targetLook; activeShootWeapon.cameraMain = cameraSystem; characterInput.shootWeapon = activeShootWeapon; characterIK.lHandTarget = activeShootWeapon.leftHandTarget; characterInput.SetShootDelegate(secondWeapon.type); anim.SetBool("Weapon", true); anim.SetInteger("WeaponType", 1); } if (selectedWeapon == 3) { anim.SetBool("Weapon", true); anim.SetInteger("WeaponType", 0); } }
private void OnTriggerExit(Collider other) { if (other.gameObject.tag == ("MagCollider")) { GameObject machineGun = GameObject.Find("MachineGun"); ShootWeapon shootScript = (ShootWeapon)machineGun.GetComponent <ShootWeapon>(); shootScript.GetMachineGunAmmo(0); shootScript.UpdateMachineGunCanvas(); Debug.Log("MagOut"); } }
void SetCurrentWeapon(Weapon newWeapon, Weapon lastWeapon, WeaponType type) { Weapon LocalLastWeapon = null; if (type == WeaponType.Shoot) { if (lastWeapon != null) { LocalLastWeapon = lastWeapon; } else if (newWeapon != equippedShootWeapon) { LocalLastWeapon = equippedShootWeapon; } if (LocalLastWeapon) { LocalLastWeapon.OnUnEquip(); } equippedShootWeapon = newWeapon as ShootWeapon; if (newWeapon) { newWeapon.OnEquip(); } } else if (type == WeaponType.Melee) { if (lastWeapon != null) { LocalLastWeapon = lastWeapon; } else if (newWeapon != equippedMeleeWeapon) { LocalLastWeapon = equippedMeleeWeapon; } if (LocalLastWeapon) { LocalLastWeapon.OnUnEquip(); } equippedMeleeWeapon = newWeapon as MeleeWeapon; if (newWeapon) { newWeapon.OnEquip(); } } }
//private Vector3 aimOffset = new Vector3(0,5,0); private void Awake() { if (instance == null) { instance = this; } else { Destroy(gameObject); return; } DontDestroyOnLoad(gameObject); }
void checkChange() { //武器変更感知 if (equipMan.CurrentShootWeapon.Id != weapon.Id) { weapon = equipMan.CurrentShootWeapon; reDefRange(); } //命中円変更感知 if (Math.Abs(abilities.ShootWide - shootWideRem) > 0.016f) { reDefWide(); } //画面の大きさの変更感知 if (Math.Abs(scrHeightRem - Screen.height) > 0.1f) { reDefRad(); } }
// Use this for initialization void Start() { weapon = equipMan.CurrentShootWeapon; //各種値を計算 //通常時の最大射程スクリーンの高さ hitScrHeight = weapon.Range * 2.0f * Mathf.Tan(camAimer.NonAimZoomFov * 0.5f * Mathf.Deg2Rad); //通常時の最大射程命中円の半径 shootRadius = abilities.ShootWide + weapon.Range / 100; //通常時の画面命中円の半径 radius = shootRadius / hitScrHeight * Screen.height; //エイム時の最大射程スクリーンの高さ aimIngHitScrHeight = weapon.Range * 2.0f * Mathf.Tan(camAimer.AimZoomFov * 0.5f * Mathf.Deg2Rad); //エイム時の画面命中円半径 aimIngRadius = shootRadius / aimIngHitScrHeight * Screen.height; //変更感知用に覚えておく shootWideRem = abilities.ShootWide; scrHeightRem = Screen.height; }
public void OnPointerDown(PointerEventData eventData) { if (!isFiring) { currentWeapon = weaponController.ActiveWeapon.GetComponent <ShootWeapon>(); reloadDuration = currentWeapon.ReloadDelay; isFiring = true; } if (currentWeapon.Ammo <= 0) { shoot += currentWeapon.Reload; shoot -= currentWeapon.Shoot; } else { shoot += currentWeapon.Shoot; shoot -= currentWeapon.Reload; } }
/// <summary> /// 該当武器を装備します /// </summary> /// <param name="weapon">装備したい武器</param> public virtual void equip(Weapon weapon) { //一度装備解除 disarm(); currentWeapon = weapon; registerWeapon(weapon); activateObject(weapon.UniqueId); if (CurrentWeaponType == WeaponType.SHOOT) { currentShootWeapon = (ShootWeapon) weapon; var obj = weapon.WeaponObj.GetComponent<ShootWeaponObject>(); //パラメータの設定 Switcher.switchShoot(obj.aimTransform,obj.shootFrom); //位置設定 rotateShootWeapon(obj); moveToGrip(obj.gameObject,obj.girp.position); } else { currentMeleeWeapon = (MeleeWeapon) weapon; var obj = weapon.WeaponObj.GetComponent<MeleeWeaponObject>(); //パラメータの設定 obj.animator = anim; obj.Enemytag = EnemyTag; obj.MeleeSys = MeleeSys; Switcher.switchMelee(); //位置設定 rotateMeleeWeapon(obj); moveToGrip(obj.gameObject,obj.grip.position); } //アニメータを編集 anim.runtimeAnimatorController = Instantiate(weapon.WeaponAnim); }
private void Start() { _shootWeaponScript = GameManager.Instance.Player.GetComponent <PlayerParts>().ShootWeapon; //GameObject.Find("Input Controller").GetComponent<ShootWeapon>(); }
/// <summary> /// 创建角色(base,无装备,有武器) /// </summary> /// <param name="id">ID</param> /// <param name="name">名字</param> /// <param name="faction">势力(玩家,友军,敌人)</param> /// <param name="type">(英雄,普通)</param> /// <param name="constitution">体质</param> /// <param name="strength">力量</param> /// <param name="agility">灵巧</param> /// <param name="dexterous">洞察</param> /// <param name="concentration">专注</param> /// <param name="weapon">武器</param> /// <param name="allExperience">全部经验</param> /// <param name="skills">技能</param> /// <param name="currentExperience">当前经验</param> public CharacterProperty(int id, string name, CharacterFaction faction, CharacterType type, string sprite, CharacterKind kind, int constitution, int strength, int agility, int dexterous, int concentration, Item weapon, float allExperience, float resistance = 0, int[] skills = null, float currentExperience = 0, int headID = 0, int clothID = 0, int pantsID = 0, int beltID = 0, BuffProp buffProp = null) { #region 装备处理 if (this.EquipmentProp == null) { this.EquipmentProp = new EquipProp(headID, clothID, pantsID, beltID); } if ((headID != 0) || (clothID != 0) || (pantsID != 0) || (beltID != 0)) { this.EquipmentProp = new EquipProp(headID, clothID, pantsID, beltID); resistance += EquipmentProp.Resistance; constitution += EquipmentProp.Constitution; strength += EquipmentProp.Strength; dexterous += EquipmentProp.Dexterous; agility += EquipmentProp.Agility; concentration += EquipmentProp.Concentration; } #endregion #region 加成处理 if (buffProp != null) { this.BuffItemProp = buffProp; constitution += buffProp.Constitution; strength += buffProp.Strength; dexterous += buffProp.Dexterous; agility += buffProp.Agility; concentration += buffProp.Concentration; //else ... } #endregion this.ID = id; this.Name = name; this.Faction = faction; this.Type = type; this.Sprite = sprite; this.AllExperience = allExperience; this.Resistance = resistance; this.Constitution = constitution; this.Strength = strength; this.Agility = agility; this.Dexterous = dexterous; this.Concentration = concentration; this.HealthLevel = 100; this.charKind = kind; this.Level = CountLevel(allExperience, out currentExperience); this.CurrentExperience = currentExperience; this.Power = constitution + strength + agility + dexterous + concentration; this.WeaponWith = weapon; //通常角色 if (type == CharacterType.Common) { this.MaxHealth = 100 + 3 * constitution; this.MaxStamina = 100 + 1 * constitution; this.HealthRecovery = 0.2f; this.StaminaRecovery = 5f; this.MoveSpeed = 1.3f * (1 + 0.01f * agility); this.AimingSpeed = 2 * (1 + 0.02f * concentration); this.Critical = 0.1f + 0.01f * dexterous; this.MeleeRaise = 1.5f; this.ShootRaise = 1.5f; this.ThrowRaise = 1.5f; this.MaxAngle = 10 * (1 - 0.01f * concentration); this.KickDamage = 20 + strength; this.PunchDamage = 20 + strength; if (weapon is MeleeWeapon) { MeleeWeapon melee = (MeleeWeapon)weapon; this.MeleeDamage = melee.MeleeDamage + strength; this.ThrowDamage = melee.ThrowDamage + strength; this.AttackInterval = melee.AttackInterval * (1 - 0.02f * agility); } else if (weapon is ShootWeapon) { ShootWeapon shoot = (ShootWeapon)weapon; this.MinAngle = (110 - shoot.Accuracy / 15); this.Capacity = shoot.Accuracy * MaxAngle / 10; this.PullingTime = shoot.LaShuanTime * (1 - 0.02f * agility); this.ReloadTime = shoot.ReloadTime * (1 - 0.01f * agility); this.MeleeDamage = shoot.MeleeDamage + strength; this.ShootDamage = shoot.ShootDamage; this.AttackInterval = shoot.AttackInterval * (1 - 0.01f * agility); this.DeclineRange = shoot.DamageRange; } } //英雄角色 else if (type == CharacterType.Hero) { this.SkillA = skills[0]; this.SkillB = skills[1]; this.SkillC = skills[2]; this.SkillD = skills[3]; this.SkillE = skills[4]; this.SkillF = skills[5]; this.SkillG = skills[6]; this.SkillH = skills[7]; this.SkillI = skills[8]; this.SkillJ = skills[9]; this.SkillK = skills[10]; this.SkillL = skills[11]; this.SkillM = skills[12]; this.SkillN = skills[13]; this.SkillO = skills[14]; this.SkillP = skills[15]; this.SkillQ = skills[16]; this.SkillR = skills[17]; this.SkillS = skills[18]; this.SkillT = skills[19]; this.MaxHealth = 100 + 3 * constitution + 20 * SkillA; this.MaxStamina = 100 + 1 * constitution + 20 * SkillF; this.HealthRecovery = 0.2f + 2 * SkillM + 100 * SkillN; this.StaminaRecovery = 5 + 2 * SkillL; this.MoveSpeed = 1.3f * (1 + 0.01f * agility + 0.15f * SkillR); this.AimingSpeed = 2f * (1 + 0.02f * concentration + 0.1f * SkillQ); this.Critical = 0.1f + 0.01f * dexterous + 0.04f * SkillD; this.MeleeRaise = 1.5f + 0.5f * SkillI; this.ShootRaise = 1.5f + 0.5f * SkillJ; this.ThrowRaise = 1.5f + 1 * SkillT; this.MaxAngle = 10 * (1 - 0.01f * concentration - 0.04f * SkillE); this.Resistance = this.Resistance + 0.04f * SkillG + 0.1f * SkillN; this.KickDamage = 20 + 20 * SkillH; if (weapon is MeleeWeapon) { MeleeWeapon melee = (MeleeWeapon)weapon; this.MeleeDamage = (melee.MeleeDamage + strength) * (1 + 0.04f * SkillB); this.AttackInterval = melee.AttackInterval * (1 - 0.02f * agility - 0.04f * SkillC); this.ThrowDamage = melee.ThrowDamage * (1 + SkillT) + strength; } else if (weapon is ShootWeapon) { ShootWeapon shoot = (ShootWeapon)weapon; this.MinAngle = (110 - shoot.Accuracy / 15) * (1 - 0.1f * SkillP); this.Capacity = shoot.Accuracy * MaxAngle / 10f; this.ReloadTime = shoot.ReloadTime * (1 - 0.01f * agility - 0.1f * SkillO); this.PullingTime = shoot.LaShuanTime * (1 - 0.02f * agility - 0.08f * SkillK); this.MeleeDamage = (shoot.MeleeDamage * (1 + SkillT) + strength) * (1 + 0.04f * SkillB); this.ShootDamage = shoot.ShootDamage; this.AttackInterval = shoot.AttackInterval * (1 - 0.01f * agility - 0.04f * SkillC); } } }
/// <summary> /// 解析物品信息 /// </summary> void ParseItemJson() { itemList = new List <Item>(); TextAsset itemText = Resources.Load <TextAsset>("Items"); string itemJson = itemText.text; JSONObject itemObjects = new JSONObject(itemJson); foreach (JSONObject temp in itemObjects.list) { Item.ItemType type = (Item.ItemType)System.Enum.Parse(typeof(Item.ItemType), temp["type"].str); int id = (int)temp["id"].n; string name = temp["name"].str; string description = temp["description"].str; Item.ItemTechnology technology = (Item.ItemTechnology)System.Enum.Parse(typeof(Item.ItemTechnology), temp["technology"].str); int value = (int)temp["value"].n; string sprite = temp["sprite"].str; int maxStark = (int)temp["maxStark"].n; Item item = null; switch (type) { #region 解析消耗品 case Item.ItemType.Consumable: int hp = temp.HasField("hp") ? (int)temp["hp"].n : 0; int eg = temp.HasField("eg") ? (int)temp["eg"].n : 0; int hl = temp.HasField("hl") ? (int)temp["hl"].n : 0; int tempConstitution = temp.HasField("tempConstitution") ? (int)temp["tempConstitution"].n : 0; int tempStrength = temp.HasField("tempStrength") ? (int)temp["tempStrength"].n : 0; int tempAgility = temp.HasField("tempAgility") ? (int)temp["tempAgility"].n : 0; int tempDexterous = temp.HasField("tempDexterous") ? (int)temp["tempDexterous"].n : 0; int tempConcentration = temp.HasField("tempConcentration") ? (int)temp["tempConcentration"].n : 0; int continuedTime = temp.HasField("continuedTime") ? (int)temp["continuedTime"].n : 0; int con_buffID = temp.HasField("buffID") ? (int)temp["buffID"].n : 0; item = new Consumable(id, name, description, type, technology, value, maxStark, sprite, hp, eg, hl, tempConstitution, tempStrength, tempAgility, tempDexterous, tempConcentration, continuedTime, con_buffID); break; #endregion #region 解析包裹 case Item.ItemType.Package: bool isGetOne = temp["isGetOne"].n == 1 ? true : false; int[] itemIDs = temp.HasField("itemIDs") ? new int[temp["itemIDs"].list.Count] : null; if (itemIDs != null) { for (int i = 0; i < temp["itemIDs"].list.Count; i++) { itemIDs[i] = int.Parse(temp["itemIDs"].list[i].str); } } Item.ItemType[] itemTypes = temp.HasField("itemTypes") ? new Item.ItemType[temp["itemTypes"].list.Count] : null; if (itemTypes != null) { for (int i = 0; i < temp["itemTypes"].list.Count; i++) { itemTypes[i] = (Item.ItemType)System.Enum.Parse(typeof(Item.ItemType), temp["itemTypes"].list[i].str); } } Item.ItemTechnology[] itemTechnologies = temp.HasField("itemTechnologies") ? new Item.ItemTechnology[temp["itemTechnologies"].list.Count] : null; if (itemTechnologies != null) { for (int i = 0; i < temp["itemTechnologies"].list.Count; i++) { itemTechnologies[i] = (Item.ItemTechnology)System.Enum.Parse(typeof(Item.ItemTechnology), temp["itemTechnologies"].list[i].str); } } int[] itemCount = new int[temp["itemCount"].list.Count]; for (int i = 0; i < temp["itemCount"].list.Count; i++) { itemCount[i] = int.Parse(temp["itemCount"].list[i].str); } float[] itemProbabilities = new float[temp["itemProbabilities"].list.Count]; for (int i = 0; i < temp["itemProbabilities"].list.Count; i++) { itemProbabilities[i] = float.Parse(temp["itemProbabilities"].list[i].str); } item = new Package(id, name, description, type, technology, value, maxStark, sprite, isGetOne, itemIDs, itemTypes, itemTechnologies, itemCount, itemProbabilities); break; #endregion #region 解析装备 case Item.ItemType.Equipment: int equipmentID = (int)temp["equipmentID"].n; Equipment.EquipmentType equipmentType = (Equipment.EquipmentType)System.Enum.Parse(typeof(Equipment.EquipmentType), temp["equipmentType"].str); int resistance = (int)temp["resistance"].n; int constitution = (int)temp["constitution"].n; int strength = (int)temp["strength"].n; int agility = (int)temp["agility"].n; int dexterous = (int)temp["dexterous"].n; int concentration = (int)temp["concentration"].n; item = new Equipment(id, name, description, type, technology, value, maxStark, sprite, equipmentID, equipmentType, resistance, constitution, strength, agility, dexterous, concentration); break; #endregion #region 解析武器 case Item.ItemType.MeleeWeapon: int meleeWeaponID = (int)temp["meleeWeaponID"].n; int meleeDamage = (int)temp["meleeDamage"].n; int throwDamage = (int)temp["throwDamage"].n; float attackInterval = temp["attackInterval"].n; MeleeWeapon.MeleeWeaponType mwType = (MeleeWeapon.MeleeWeaponType)System.Enum.Parse(typeof(MeleeWeapon.MeleeWeaponType), temp["mwType"].str); item = new MeleeWeapon(id, name, description, type, technology, value, maxStark, sprite, meleeWeaponID, meleeDamage, throwDamage, attackInterval, mwType); break; case Item.ItemType.ShootWeapon: int shootWeaponID = (int)temp["shootWeaponID"].n; int shootDamage = (int)temp["shootDamage"].n; int s_meleeDamage = (int)temp["meleeDamage"].n; float s_attackInterval = temp["attackInterval"].n; float lashuanTime = temp["lashuanTime"].n; float reloadTime = temp["reloadTime"].n; float damageRange = temp["damageRange"].n; ShootWeapon.ShootWeaponType swType = (ShootWeapon.ShootWeaponType)System.Enum.Parse(typeof(ShootWeapon.ShootWeaponType), temp["swType"].str); ShootWeapon.AmmoType amType = (ShootWeapon.AmmoType)System.Enum.Parse(typeof(ShootWeapon.AmmoType), temp["amType"].str); int ammoCount = (int)temp["ammoCount"].n; int accuracy = (int)temp["accuracy"].n; item = new ShootWeapon(id, name, description, type, technology, value, maxStark, sprite, shootWeaponID, shootDamage, s_meleeDamage, s_attackInterval, lashuanTime, reloadTime, damageRange, swType, amType, ammoCount, accuracy); break; #endregion #region 解析材料,蓝图,子弹 case Item.ItemType.Unuseable: item = new Unuseable(id, name, description, type, technology, value, maxStark, sprite); break; case Item.ItemType.Blueprint: int[] craftIDs = new int[temp["craftIDs"].list.Count]; for (int i = 0; i < temp["craftIDs"].list.Count; i++) { craftIDs[i] = int.Parse(temp["craftIDs"].list[i].str); } item = new Blueprint(id, name, description, type, technology, value, maxStark, sprite, craftIDs); break; case Item.ItemType.Ammo: item = new Ammo(id, name, description, type, technology, value, maxStark, sprite); break; #endregion #region 解析BUFF,技能 case Item.ItemType.Buff: int buffID = (int)temp["buffID"].n; int durationTime = (int)temp["durationTime"].n; string effectDescription = temp["effectDescription"].str; string[] effectProp = new string[temp["effectProp"].list.Count]; int[] effectValue = new int[temp["effectValue"].list.Count]; for (int i = 0; i < temp["effectProp"].list.Count; i++) { effectProp[i] = temp["effectProp"].list[i].str; } for (int i = 0; i < temp["effectValue"].list.Count; i++) { effectValue[i] = int.Parse(temp["effectValue"].list[i].str); } item = new Buff(id, name, description, type, technology, value, maxStark, sprite, buffID, durationTime, effectDescription, effectProp, effectValue); break; case Item.ItemType.Skill: int skillID = (int)temp["skillID"].n; int maxPoint = (int)temp["maxPoint"].n; string skillDescription = temp["skillDescription"].str; int[] preSkillID = new int[temp["preSkillID"].list.Count]; for (int i = 0; i < temp["preSkillID"].list.Count; i++) { preSkillID[i] = int.Parse(temp["preSkillID"].list[i].str); } int[] eachSkillNeed = new int[temp["eachSkillNeed"].list.Count]; for (int i = 0; i < temp["eachSkillNeed"].list.Count; i++) { eachSkillNeed[i] = int.Parse(temp["eachSkillNeed"].list[i].str); } item = new Skill(id, name, description, type, technology, value, maxPoint, sprite, skillID, maxPoint, skillDescription, preSkillID, eachSkillNeed); break; #endregion } itemList.Add(item); } //拳头,只用于属性调整 MeleeWeapon hand = new MeleeWeapon(999, "拳头", " ", Item.ItemType.MeleeWeapon, Item.ItemTechnology.T0, 0, 1, " ", 0, 20, 0, 2, MeleeWeapon.MeleeWeaponType.刀); itemList.Add(hand); }
private void Start() { Panel_EndLevel.SetActive(false); Panel_PlayerDies.SetActive(false); Panel_Shop.SetActive(false); data = GameObject.FindObjectOfType <DataController>(); upgrades = data.GetUpgrades(); for (int i = 0; i < upgrades.Length; i++) { GameObject u = Instantiate(UpgradePrefab, new Vector3(UpgradePrefab.transform.position.x, UpgradePrefab.transform.position.y, UpgradePrefab.transform.position.z), Quaternion.identity, ScrollPanel.transform) as GameObject; u.GetComponent <RectTransform>().anchoredPosition = new Vector3(UpgradePrefab.transform.position.x + (i * 30), UpgradePrefab.transform.position.y, UpgradePrefab.transform.position.z); u.transform.GetChild(0).GetComponent <Text>().text = upgrades[i].cost; if (upgrades[i].type == "ammo") { u.transform.GetChild(1).GetComponent <Image>().sprite = AmmoImg; } else if (upgrades[i].type == "reloadTime") { u.transform.GetChild(1).GetComponent <Image>().sprite = ReloadImg; } else if (upgrades[i].type == "fireTime") { u.transform.GetChild(1).GetComponent <Image>().sprite = FireTimeImg; } u.transform.GetChild(2).GetComponent <Text>().text = upgrades[i].description; u.transform.GetChild(3).GetComponent <Text>().text = "(" + upgrades[i].gun.ToUpper() + ")"; u.GetComponent <Button>().onClick.AddListener(delegate { int upgradeIndex = 0; for (int c = 0; c < ScrollPanel.transform.childCount; c++) { if (ScrollPanel.transform.GetChild(c) == u.transform) { upgradeIndex = c; } } ShootWeapon sw = GameObject.FindObjectOfType <ShootWeapon>(); bool buyed = false; if (upgrades[upgradeIndex].type == "ammo") { if (upgrades[upgradeIndex].gun == "pistol") { if (upgrades[upgradeIndex].percentage == "y") { buyed = sw.UpgradePistol_TotalAmmo(int.Parse(upgrades[upgradeIndex].cost), sw.PistolTotalAmmo * Mathf.FloorToInt(float.Parse(upgrades[upgradeIndex].amount) / 100)); } else { buyed = sw.UpgradePistol_TotalAmmo(int.Parse(upgrades[upgradeIndex].cost), int.Parse(upgrades[upgradeIndex].amount)); } } else if (upgrades[upgradeIndex].gun == "shotgun") { if (upgrades[upgradeIndex].percentage == "y") { buyed = sw.UpgradeShotgun_TotalAmmo(int.Parse(upgrades[upgradeIndex].cost), sw.ShotgunTotalAmmo * Mathf.FloorToInt(float.Parse(upgrades[upgradeIndex].amount) / 100)); } else { buyed = sw.UpgradeShotgun_TotalAmmo(int.Parse(upgrades[upgradeIndex].cost), int.Parse(upgrades[upgradeIndex].amount)); } } } else if (upgrades[upgradeIndex].type == "reloadTime") { if (upgrades[upgradeIndex].gun == "pistol") { if (upgrades[upgradeIndex].percentage == "y") { buyed = sw.UpgradePistol_ReloadTime(int.Parse(upgrades[upgradeIndex].cost), sw.PistolReloadTime * (float.Parse(upgrades[upgradeIndex].amount) / 100)); } else { buyed = sw.UpgradePistol_TotalAmmo(int.Parse(upgrades[upgradeIndex].cost), int.Parse(upgrades[upgradeIndex].amount)); } } else if (upgrades[upgradeIndex].gun == "shotgun") { if (upgrades[upgradeIndex].percentage == "y") { buyed = sw.UpgradeShotgun_ReloadTime(int.Parse(upgrades[upgradeIndex].cost), sw.ShotgunReloadTime * (float.Parse(upgrades[upgradeIndex].amount) / 100)); } else { buyed = sw.UpgradeShotgun_TotalAmmo(int.Parse(upgrades[upgradeIndex].cost), int.Parse(upgrades[upgradeIndex].amount)); } } } else if (upgrades[upgradeIndex].type == "fireTime") { if (upgrades[upgradeIndex].gun == "pistol") { if (upgrades[upgradeIndex].percentage == "y") { buyed = sw.UpgradePistol_FireTime(int.Parse(upgrades[upgradeIndex].cost), sw.PistolFireTime * (float.Parse(upgrades[upgradeIndex].amount) / 100)); } else { buyed = sw.UpgradePistol_FireTime(int.Parse(upgrades[upgradeIndex].cost), int.Parse(upgrades[upgradeIndex].amount)); } } else if (upgrades[upgradeIndex].gun == "shotgun") { if (upgrades[upgradeIndex].percentage == "y") { buyed = sw.UpgradeShotgun_FireTime(int.Parse(upgrades[upgradeIndex].cost), sw.ShotgunFireTime * (float.Parse(upgrades[upgradeIndex].amount) / 100)); } else { buyed = sw.UpgradeShotgun_FireTime(int.Parse(upgrades[upgradeIndex].cost), int.Parse(upgrades[upgradeIndex].amount)); } } } if (buyed) { u.GetComponent <Button>().interactable = false; } }); } }