public void LoadDataFromJSON(string jsonName) { string asset = jsonName.Replace(".json", ""); gunStatJsonString = Resources.Load <TextAsset>(StringPathsInfo.GUNS_TEXTFILES_PATH + asset).text; if (gunStatJsonString.Length == 0) { return; } #region PARSE_DATA GunStats gunStat = JsonUtility.FromJson <GunStats>(gunStatJsonString); if (gunStat.Equals(GunStats.Empty)) { return; } this.id = gunStat.Id; this.GunName = gunStat.GunName; this.AmmoStats.AmmoSize = gunStat.AmmoStats.AmmoSize; this.AmmoStats.CurrentAmmo = gunStat.AmmoStats.CurrentAmmo; this.AmmoStats.DeltaAmmo = gunStat.AmmoStats.DeltaAmmo; this.AttackRate = gunStat.AttackRate; this.MinAngle = gunStat.MinAngle; this.MaxAngle = gunStat.MaxAngle; this.Powerfull = gunStat.Powerfull; this.GunType = gunStat.GunType; this.maxAmmoSize = gunStat.MaxAmmoSize; this.maxPowerFull = gunStat.MaxPowerFull; this.maxAttackRate = gunStat.MaxAttackRate; this.levelToOpen = gunStat.LevelToOpen; #endregion }
private void Seed() { using (CargoContext cargoContext = new CargoContext()) { List <GunStats> gunStats = cargoContext.GunsStats.Where(gs => gs.GunName == "2 x 7.7mm MG GL.2").ToList(); if (gunStats == null || gunStats.Count == 0) { GunStats gun = new GunStats(); gun.GunName = "2 x 7.7mm MG GL.2"; gun.GunTech = "T0"; gun.Rld = 75; gun.Rld3 = 70; gun.Rld6 = 66; gun.RldMax = 60; gun.Dmg = 9; gun.Dmg3 = 12; gun.Dmg6 = 17; gun.DmgMax = 22; cargoContext.GunsStats.Add(gun); } cargoContext.SaveChanges(); } }
// Start is called before the first frame update void Start() { gun = PlayerCombat.activeWeapon; // encontra a referencia GetAngle(); rb.velocity = shootAngle * speed; Destroy(gameObject, timeToAutoDestroy); }
public TweenCallback AimComplete(GunStats cGun, int index) { if (OnAllGunsAimed != null) { OnAllGunsAimed(cGun, index); } return(null); }
//public void RayCastFire() //{ // if (!isFiring) // { // return; // } // else // { // //RaycastHit hit; // //Physics.Raycast(transform.position, transform.TransformDirection(Vector3.forward), out hit); // //Instantiate(explosion, hit.point, Quaternion.identity); // //Debug.DrawRay(transform.position, transform.TransformDirection(Vector3.forward) * hit.distance, Color.yellow); // if (timer >= fireRate) // { // timer = 0; // Instantiate(explodeBullet, spawnTransform); // //Instantiate(lighting, spawnTransform); // } // } //} public void GetGunStats(GunStats myStats, GunModel.bulletSpeed bS, GunModel.damageRange dR) { gStats = myStats; bSpd = bS; dRng = dR; SetFireRate(); SetBulletEffect(); }
void FromJsonToObjects(string json) { string[] objects = json.Split(objSeperators, System.StringSplitOptions.RemoveEmptyEntries); for (int i = 0; i < objects.Length; i++) { string[] objectParts = objects[i].Split('|'); string Type = objectParts[0]; string Name = objectParts[1]; string Description = objectParts[2]; string ImgUrl = objectParts[3]; string Object = objectParts[4]; print("Type: " + Type); print("Name: " + Name); print("Description: " + Description); print("ImgUrl: " + ImgUrl); print("objecet: " + Object); Sprite spriteFromUrl = GetSprite(ImgUrl, value => spriteFromUrl = value); switch (Type) { case "Gun": GunStats gunStats = JsonUtility.FromJson <GunStats>(Object); GunSettings gun = ScriptableObject.CreateInstance <GunSettings>(); gun.Fill(gunStats, Name, Description); gun.Sprite = spriteFromUrl; Data.Instance.AddGun(gun); break; case "Vest": VestStats vestStats = JsonUtility.FromJson <VestStats>(Object); VestSettings vest = ScriptableObject.CreateInstance <VestSettings>(); vest.Sprite = spriteFromUrl; vest.Fill(Name, Description, vestStats); Data.Instance.AddVest(vest); break; case "Knife": KnifeStats knifeStats = JsonUtility.FromJson <KnifeStats>(Object); KnifeSettings knife = ScriptableObject.CreateInstance <KnifeSettings>(); knife.Fill(knifeStats, Name, Description); knife.Sprite = spriteFromUrl; Data.Instance.AddKnife(knife); break; case "Grenade": GrenadeStats grenadeStats = JsonUtility.FromJson <GrenadeStats>(Object); GrenadeSettings grenade = ScriptableObject.CreateInstance <GrenadeSettings>(); grenade.Fill(grenadeStats, Name, Description); grenade.Sprite = spriteFromUrl; Data.Instance.AddGrenade(grenade); break; default: Debug.Log("Unrecognised item type"); break; } } itemsLoaded = true; }
//public TMP_Text tmproTx; // Start is called before the first frame update void Start() { myStats = new GunStats(); tempStats = new GunStats(); FillColors(); RunStats(); SetColors(); //tmproTx = GameObject.Find("TMPRO").GetComponent<TextMeshProUGUI>(); }
public void setMyStats(GunStats gs, GameObject mCreator) { moveSpeed = gs.moveSpeed; colliding = gs.colliding; friendly = gs.friendly; damage = gs.damage; bulletLifetime = gs.bulletLifespan; creator = mCreator; creation = gs.CreateOnProjectileDeath; }
// Start is called before the first frame update void Start() { m_body = GetComponent <Transform>(); gs = GetComponent <GunStats>(); maxRotSpeed = gs.maxRotSpeed; accelRotSpeed = gs.accelRotSpeed; slowRotSpeed = gs.dampenRotSpeed; ip = new InputPacket(); //if (playerControl) //playerInput = GetComponent<PlayerInputTurret>(); }
public void Fire(GunStats gunStats) { Vector3 forward = transform.TransformDirection(Vector3.right) * gunStats.speed; float angle = -gunStats.spread * 0.5f; for (int i = 0; i < gunStats.shellSplitCount; ++i) { FireSingle(Quaternion.AngleAxis(angle, Vector3.back) * forward, gunStats.round); angle += gunStats.spread / (gunStats.shellSplitCount - 1); } }
public static GunStats operator *(GunStats g1, GunStats g2) { GunStats g = new GunStats(); g.name = g1.name + " " + g2.name; g.damage = g1.damage * g2.damage; g.spread = g1.spread * g2.spread; g.numProjectiles = g1.numProjectiles + g2.numProjectiles; g.speed = g1.speed * g2.speed; g.description = g1.description; return(g); }
public static GunStats Clone(GunStats g) { GunStats r = new GunStats(); r.name = g.name; r.damage = g.damage; r.spread = g.spread; r.numProjectiles = g.numProjectiles; r.speed = g.speed; r.description = g.description; return(r); }
// Start is called before the first frame update void Start() { m_body = GetComponent <Transform>(); gs = GetComponent <GunStats>(); inputSource = GetComponent <AITurret>(); //inputSource = GetComponent<testerTurret>(); if (gs != null) { rotSpeed = gs.maxRotSpeed; } ip = new InputPacket(); }
public static GunStats operator +(GunStats g1, GunStats g2) { GunStats g = new GunStats(); g.name = g1.name + " " + g2.name; g.damage = Mathf.Max(0, g1.damage - 1 + g2.damage - 1); g.spread = Mathf.Max(0, g1.spread - 1 + g2.spread - 1); g.numProjectiles = Mathf.Max(1, g1.numProjectiles + g2.numProjectiles); g.speed = Mathf.Max(0.01f, g1.speed + g2.speed); g.description = g1.description; return(g); }
// Start is called before the first frame update void Start() { ip = new InputPacket(); gs = GetComponent <GunStats>(); cooldownMax = gs.cooldown; if (gs.preignitor == false) { curCooldown = cooldownMax; } autoLoader = gs.autoLoader; offset = gs.offset; }
public void SetPiece(GunStats gunPart) { if (gunPart.GetType() == typeof(Grip)) { } else if (gunPart.GetType() == typeof(Barrel)) { } else if (gunPart.GetType() == typeof(Ammo)) { } }
public void FireGuns(GunStats cGun, int coroutineIndex) { if (fireRoutineList.Count < gunList.Count) { fireRoutineList.Add(StartCoroutine(FireRoutine(cGun, coroutineIndex))); } else { if (fireRoutineList[coroutineIndex] != null) { StopAllCoroutines(); } fireRoutineList[coroutineIndex] = StartCoroutine(FireRoutine(cGun, coroutineIndex)); } }
public IEnumerator FireRoutine(GunStats cGun, int index) { int ammountOfShots = (int)(Random.Range(cGun.shotsInBurst.x, cGun.shotsInBurst.y + 1)); for (int i = 0; i < ammountOfShots; i++) { // Debug.Break(); yield return(new WaitForSeconds(Random.Range(cGun.fireRateRange.x, cGun.fireRateRange.y))); ShootProjectile(cGun, index); } yield return(null); }
// public GunStats GetStats(GunScript.GunType type) { GunStats returnGun = pistol; switch (type) { case GunScript.GunType.Pistol: returnGun = pistol; break; case GunScript.GunType.Shotgun: returnGun = shotgun; break; default: Assert.IsTrue(false); break; } return(returnGun); }
public void RunStatMods(gripModel grip, GunStats stats) { switch (grip) { case gripModel.pistol: stats.fireRate += 4; stats.stability = 5; stats.damage += 4; stats.accuracy += 5; stats.durability += 5; stats.ammo += 7; break; case gripModel.subMG: stats.fireRate += 12; stats.stability = 5; stats.damage += 4; stats.accuracy += 5; stats.durability += 5; stats.ammo += 20; break; case gripModel.assaultR: stats.fireRate += 8; stats.stability = 5; stats.damage += 8; stats.accuracy += 5; stats.durability += 5; stats.ammo += 12; break; case gripModel.shotG: stats.fireRate += 4; stats.stability = 5; stats.damage += 12; stats.accuracy += 5; stats.durability += 5; stats.ammo += 5; break; case gripModel.none: break; default: break; } }
/* * Spawns a heavy class enemy at the given location. * */ public Transform spawnHeavyEnemy(Vector3 spawnPoint) { Transform enemy = Instantiate(heavyEnemy, spawnPoint, Quaternion.identity) as Transform; EnemyCharacter script = enemy.GetComponent <EnemyHeavy>(); Transform LRWeapon = Instantiate(heavyEnemyGun, script.RightHand.position, Quaternion.identity) as Transform; GunStats gunstats = LRWeapon.gameObject.GetComponentInChildren <GunStats>(); LRWeapon.transform.parent = script.RightHand; //attach the weapon to the right hand //initialising hand IK targets script.LRWeapon = LRWeapon.gameObject; script.LHandPos = gunstats.LHandPos; script.RHandPos = gunstats.RHandPos; script.shot_source = gunstats.bulletSpawn; return(enemy); }
public void GetNewWeapon(GameObject newGun) { if (ActiveGun && Player_Controller.Aiming) { Player_Controller.PutGunDown(); } if (ActiveGun) { ActiveGun.SetActive(false); } ActiveGun = newGun; ActiveGun.SetActive(true); GunStats = newGun.GetComponentInChildren <GunStats>(); secondsPerBullet = 60 / GunStats.FireRate; Player_Controller.RefreshAnimation(); ResetWeapon(); }
// Ativa a arma selecionada e desativa as outras private void ActiveSelectedWeapon() { int i = 0; foreach (Transform weapon in transform) { if (i == selectedWeapon) { // pega a referencia da arma selecionada e seta ela como ativa selectedWeaponReference = weapon.GetComponent <GunStats>(); weapon.gameObject.SetActive(true); } else { weapon.gameObject.SetActive(false); } i++; } }
void Update() { GunStats currentGun = inventory.GetCurrentGun(); if (currentGun != null && inventory.HasAGun()) { textMesh.gameObject.SetActive(true); gunIcon.gameObject.SetActive(true); textMesh.text = inventory.GetAmmoCount(currentGun.type).ToString(); gunIcon.sprite = currentGun.smallIcon; } else { textMesh.gameObject.SetActive(false); gunIcon.gameObject.SetActive(false); } heatlhBar.SetSizeWithCurrentAnchors(RectTransform.Axis.Horizontal, fullHeathRect.width * playerDamage.CurrentHealth / playerDamage.maxHealth); }
// Metodo de atirar do player private void HandleFire() { // Pega a referencia da arma selecionada if (selectedWeapon != weaponChange.selectedWeapon) { activeWeapon.cancelReload(); // cancela um reload se estiver acontecendo cancelMeleeAttack(); // cancela um ataque melee selectedWeapon = weaponChange.selectedWeapon; // pega o numero referencia da arma selecionada activeWeapon = weaponChange.selectedWeaponReference; // pega a referencia da arma selecionada UpdateAmmoUI(); } // Se pode atirar if (Input.GetMouseButtonDown(0) && activeWeapon.canShoot && !activeWeapon.isAutomatic) //left button { if (Time.time > lastShootTime + activeWeapon.fireRate) { FindObjectOfType <AudioManager>().Play("PistolFire"); lastShootTime = Time.time; activeWeapon.cancelReload(); // cancela um reload se estiver acontecendo cancelMeleeAttack(); // cancela um ataque melee activeWeapon.SpendAmmo(); // gasta municao Instantiate(Bullet, firePosition.position, firePosition.rotation); // instancia um objeto bullet playerAnimation.Play("Base Layer.Fire"); // executa animacao de tiro do player } } if (Input.GetMouseButton(0) && activeWeapon.canShoot && activeWeapon.isAutomatic) //left button { if (Time.time > lastShootTime + activeWeapon.fireRate) { FindObjectOfType <AudioManager>().Play("RifleFire"); lastShootTime = Time.time; activeWeapon.cancelReload(); // cancela um reload se estiver acontecendo cancelMeleeAttack(); // cancela um ataque melee activeWeapon.SpendAmmo(); // gasta municao Instantiate(Bullet, firePosition.position, firePosition.rotation); // instancia um objeto bullet playerAnimation.Play("Base Layer.Fire"); // executa animacao de tiro do player } } else if (Input.GetMouseButtonDown(0) && activeWeapon.canReload && !activeWeapon.IsLoaded()) { // Sem municao. Da o reload ao tentar atirar activeWeapon.Reload(); } }
// Use this for initialization void Start() { targetPlayers = FindObjectOfType <SteamVR_Camera>(); OnAllGunsAimed += FireGuns; GetComponent <RobotCenterHealth>().OnDeath += OnDeathCutOfFireRoutines; GunStats tempGunStats = new GunStats(); for (int i = 0; i < gunList.Count; i++) { tempGunStats = gunList[i]; tempGunStats.barrelEnding = gunList[i].gunModel.GetComponentInChildren <ProjectileSpawnPoint>().transform; gunList[i] = tempGunStats; } cAmmo = new int[gunList.Count]; for (int i = 0; i < gunList.Count; i++) { cAmmo[i] = gunList[i].maxAmmo; } }
private void ParseGuns(string guns) { Regex regex = new Regex(@"\[\'(.+?)\'\]\s*=\s*{(.+?)}}"); Match gun = regex.Match(guns); while (gun.Success) { string gunName = gun.Groups[1].Value; regex = new Regex(@"(T[0-9])\s*=\s*{Rld=\s*([0-9]{1,3}),\s*Rld3=\s*([0-9]{1,3}),\s*Rld6=\s*([0-9]{1,3}),\s*RldMax=\s*([0-9]{1,3}),\s*Dmg=\s*([0-9]{1,3}),\s*Dmg3=\s*([0-9]{1,3}),\s*Dmg6=\s*([0-9]{1,3}),\s*DmgMax=\s*([0-9]{1,3})}?"); Match tier = regex.Match(gun.Groups[2].Value); while (tier.Success) { GunStats gunStats = new GunStats(); gunStats.GunName = gunName; gunStats.GunTech = tier.Groups[1].Value; gunStats.Rld = int.Parse(tier.Groups[2].Value); gunStats.Rld3 = int.Parse(tier.Groups[3].Value); gunStats.Rld6 = int.Parse(tier.Groups[4].Value); gunStats.RldMax = int.Parse(tier.Groups[5].Value); gunStats.Dmg = int.Parse(tier.Groups[6].Value); gunStats.Dmg3 = int.Parse(tier.Groups[7].Value); gunStats.Dmg6 = int.Parse(tier.Groups[8].Value); gunStats.DmgMax = int.Parse(tier.Groups[9].Value); GunsStats.Add(gunStats); tier = tier.NextMatch(); } gun = gun.NextMatch(); } if (GunsStats.Count == 0) { Logger.Write($"Error in parsing guns for DPS calculations.", this.GetType().ToString()); } }
public void SetData() { GunStats toSet = tempStat[currentGunIndex]; #region fillingTexts if (powerFullStatText) { powerFullStatText.text = toSet.Powerfull.ToString(); } if (attackRateStatText) { attackRateStatText.text = toSet.AttackRate.ToString(); } if (ammoSizeStatText) { ammoSizeStatText.text = toSet.AmmoStats.AmmoSize.ToString(); } if (gunTypeStatText) { gunTypeStatText.text = toSet.GunType.ToString(); } #endregion #region fillingImages if (powerFullStatImage) { powerFullStatImage.fillAmount = toSet.Difference((float)toSet.Powerfull, (float)toSet.MaxPowerFull); } if (attackRateStatImage) { attackRateStatImage.fillAmount = toSet.Difference((float)toSet.MaxAttackRate, (float)toSet.AttackRate); } if (ammoSizeStatImage) { ammoSizeStatImage.fillAmount = toSet.Difference((float)toSet.AmmoStats.AmmoSize, (float)toSet.MaxAmmoSize); } if (gunTypeStatImage) { gunTypeStatImage.fillAmount = toSet.Difference((float)toSet.GunType, (float)GunStats.GunTypeEnum.Ultimate); } #endregion }
public GunStats(GunStats gunStat) { if (gunStat == null) { return; } this.id = gunStat.id; this.gunName = gunStat.gunName; this.AmmoStats.AmmoSize = gunStat.AmmoStats.AmmoSize; this.AmmoStats.CurrentAmmo = gunStat.AmmoStats.CurrentAmmo; this.AmmoStats.DeltaAmmo = gunStat.AmmoStats.DeltaAmmo; this.attackRate = gunStat.attackRate; this.minAngle = gunStat.minAngle; this.maxAngle = gunStat.maxAngle; this.powerfull = gunStat.powerfull; this.gunType = gunStat.gunType; this.maxAmmoSize = gunStat.maxAmmoSize; this.maxPowerFull = gunStat.maxPowerFull; this.maxAttackRate = gunStat.maxAttackRate; this.levelToOpen = gunStat.levelToOpen; }
static void CreateFont() { GunStats gunStats = ScriptableObject.CreateInstance <GunStats>(); string path = AssetDatabase.GetAssetPath(Selection.activeObject); if (path == "") { } else if (Path.GetExtension(path) != "") { path = path.Replace(Path.GetFileName(AssetDatabase.GetAssetPath(Selection.activeObject)), ""); } string assetPathAndName = AssetDatabase.GenerateUniqueAssetPath(path + "/New Gun.asset"); AssetDatabase.CreateAsset(gunStats, assetPathAndName); AssetDatabase.SaveAssets(); EditorUtility.FocusProjectWindow(); Selection.activeObject = gunStats; }
void Start() { motor = GetComponent<PlayerMotor>(); GunStats = weapon.GetComponent<GunStats>(); }
// Guns with projectiles! public Weapon(string name, float fireRate, int ammo, float reloadSpeed, float dmg, float kick, string projType) { itemName = name; itemType = ItemType.Weapon; gunStats = new GunStats(fireRate, reloadSpeed, ammo, dmg, kick, projType); gunStats.Init(); }