public void SetPrefabValues() //When something is upgraded, the prefab is changed //So we need to set the current shot class values = the prefab's changes values { ShotClass prefabShotClass = this.GetComponent <ShotClass>(); ClickShoot shoot = clickShoot.GetComponent <ClickShoot>(); for (int i = 0; i < 10; i++) { if (name.Contains(clickShoot.Shots[i].name)) { prefabShotClass = shoot.Shots[i].GetComponent <ShotClass>(); break; } } if (name.Contains("Stalag")) { prefabShotClass = shoot.Stalags.GetComponent <ShotClass>(); } else if (name.Contains("Lava")) { prefabShotClass = shoot.Lavas.GetComponent <ShotClass>(); } affectDamageMultiplier = prefabShotClass.affectDamageMultiplier; damageMultiplier = prefabShotClass.damageMultiplier; amountToFire = prefabShotClass.amountToFire; affectHitRate = prefabShotClass.affectHitRate; affectTimeMultiplier = prefabShotClass.affectTimeMultiplier; }
private void FireWeapon(Vector2[] Dir) { for (int i = 0; i < Dir.Length; i++) { GameObject clone = (GameObject)Pooling.Spawn(Shots [selection], shotSpawnPos, Quaternion.identity); //Spawn the shot from the selection ShotClass cloneShotClass = clone.GetComponent <ShotClass> (); //Getting the shot class cloneShotClass.SetPrefabValues(); //Setting prefab values (to match upgrades) clone.GetComponent <Rigidbody2D> ().AddForce(Dir [i] + Dir [i], ForceMode2D.Impulse); clone.GetComponent <Collider2D> ().enabled = true; //Applying the force we passed in from calculating if (OnShoot != null) { OnShoot(selection, cloneShotClass.cooldown); } if (!cloneShotClass.lobShot) { clone.GetComponent <Rigidbody2D> ().gravityScale = 0; //Turn gravity off for straight shots } if (cloneShotClass.shotName.Equals("Stomp") || cloneShotClass.shotName.Equals("Lava")) { //play stomp animation shakeWait = .5f; } } }
void Start() { damageLevel = 0; splitLevel = 0; affectLevel = 0; weaponShotClass = weapon.GetComponent <ShotClass>(); //Getting weapon shot class if (subweapon != null) { subweaponShotClass = subweapon.GetComponent <ShotClass>(); //Getting subweapon } //shot class if there is one. Like stalagmites/lava SetStartValues(); }