public override string ToString() { return($"Tank {TankName}: " + $"Ammunition - {Ammunition.ToString()}, " + $"Armor - {Armor.ToString()}, " + $"Maneuverability - {Maneuverability.ToString()}"); }
/// <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 static Bullet Spawn(Ammunition ammo, Vector3 position, Quaternion rotation, Vector3 velocity, bool friendly) { GameObject bullet = ammo.Source; //Spawn Objects Vector3 bullet_spawn_pos = position; GameObject bullet_obj = Object.Instantiate(bullet, bullet_spawn_pos, rotation); bullet_obj.name = "Bullet: " + ammo.ToString(); // Initialize the bullet Bullet bullet_inst = new Bullet(bullet_obj, ammo, friendly, velocity); BulletAttachment bullet_script = Loader.EnsureComponent <BulletAttachment>(bullet_obj); bullet_script.instance = bullet_inst; return(bullet_inst); }
public string GetTankStat() { string stats = "Ammunition = " + Ammunition.ToString() + " Armor level = " + ArmorLevel.ToString() + " Maneuverability = " + Maneuverability.ToString(); return(stats); }