/// <summary> /// Initializes a new instance of the <see cref="PlayerInGameControl.Weapon"/> class. /// </summary> /// <param name="weaponObject">Weapon object, 3D model with a bullet spawn object as a child</param> /// <param name="weaponConfig">Weapon config, different settings we want the weapon to operate under</param> public Weapon(GameObject weaponObject, WeaponConfiguration weaponConfig) { // Set the weapon configurations weaponConfiguration = weaponConfig; // Don't bother trying to get a bullet spawn from a null object if (weaponObject == null) { return; } // Hook up bullet spawn and model this.weaponModel = weaponObject; this.bulletSpawn = weaponModel.transform.FindChild ("BulletSpawn"); }
/// <summary> /// Creates a weapon configuration based on the weapon type passed in. /// ( A chaingun fires faster than a rocket launcher ) /// </summary> /// <returns>The weapon configuration.</returns> /// <param name="weapon">Weapon.</param> public static WeaponConfiguration getWeaponConfiguration(PrebuiltWeaponType weapon) { WeaponConfiguration config; switch (weapon){ case PrebuiltWeaponType.Chaingun: config = new WeaponConfiguration(4f, .02f, .15f, 0.05f, .8f, Resources.Load<GameObject> ("Particle/Bullet Impact")); config.Name = "SKULL F****R"; return config; case PrebuiltWeaponType.MissileLauncher: config = new WeaponConfiguration(50f, .2f, .05f, 1f, .95f, new ProjectileConfiguration(Resources.Load<GameObject>("Projectiles/Missile"))); config.Name = "ROCKET LAWNCHER"; return config; } return new WeaponConfiguration(); }
public void setRightWeapon(WeaponConfiguration rightWeapon) { this.rightWeapon = rightWeapon; }
/// <summary> /// Genereates a description from the given configuration /// </summary> /// <returns>The description of weapon configuration.</returns> /// <param name="config">Config.</param> private string getDescriptionOfWeaponConfiguration(WeaponConfiguration config) { string configText = config.Name+"\n\n"; if (config.IsProjectileBased) { configText += "Projectile Based\n"; } else { configText += "Damage: " + config.damagePerFire + "\n"; } configText += "Accuracy: " + (int)(config.Accuracy*100) + "%\n"; configText += "Fire rate: " + 1f/config.fireRate + " rps\n"; configText += "Heat Index: " + (int)((config.heatPerFireIncrement / config.cooldownRate) * 100); return configText; }
public void setLeftWeapon(WeaponConfiguration leftWeapon) { this.leftWeapon = leftWeapon; }