/// <summary> Fires the weapon once </summary> public void Shoot() { if (reload_timer < ReloadSpeed * 2) { return; } Ammunition current_ammo = ParentShip.CurrentAmmo; if (!ParentShip.SubstractAmmo(current_ammo, 1u) || ooo_time > 0) { return; } if (heat > 1) { ooo_time = init_ooo_time; return; } // Spawn the bullet Bullet.Spawn( current_ammo, Transform.position + (Transform.rotation * ShootPos), Transform.rotation, SceneGlobals.ReferenceSystem.RelativeVelocity(ParentShip.Velocity) + Transform.forward * BulletSpeed, ParentShip.Friendly ); //Spawn Objects Vector3 hull_spawn_pos = Transform.position + (Transform.rotation * EjectPos / 2); GameObject hull_obj = Object.Instantiate(empty_hull, hull_spawn_pos, Transform.rotation * Quaternion.Euler(-90, 0, 0)); hull_obj.name = "Hull: " + current_ammo.ToString(); // Initialize the hull const double hull_mass = 2e-4; // 200g Hull hull_inst = new Hull(hull_obj, hull_mass, SceneGlobals.ReferenceSystem.RelativeVelocity(ParentShip.Velocity)); hull_inst.Velocity -= HullSpeed * EjectPos.normalized; hull_inst.AngularVelocity = HandyTools.RandomVector * 10f; HullAttachment hull_script = Loader.EnsureComponent <HullAttachment>(hull_obj); hull_script.instance = hull_inst; // Plays the sound if (ParentShip.IsPlayer) { Globals.audio.ShootingSound("gettling"); } reload_timer = 0.0f; heat += .05f; }
public void Shoot() { if (delta_time < reload_speed || !Enabled) { return; } if (heat >= 1) { ooo_time = init_ooo_time; return; } for (int i = 0; i < muzzle_positions.Length; i++) { if (!ParentShip.SubstractAmmo(ammo_type, 1)) { return; } // Initialize Bullet Bullet.Spawn( ammo_type, Position + barrels.rotation * muzzle_positions [i], BarrelRot, SceneGlobals.ReferenceSystem.RelativeVelocity(ParentShip.Velocity) + BarrelRot * Vector3.back * muzzle_velocity, ParentShip.Friendly ); // Initialize Hull // --------- // To Come // --------- } if (anim != null) { anim.SetTrigger("fire"); } if (ParentShip.IsPlayer) { Globals.audio.ShootingSound(sound_name); } heat += .2f; delta_time = 0f; }