// When a row in the datagridview is clicked, check to make sure it's not the header then store the row's itemID in the currentID variable // Query the database to find the appropriate item and populate the fields with it's data. In the case of comboboxes match the Index with the name. private void dgv_ammunition_DoubleClick(object sender, EventArgs e) { btn_save.Enabled = true; if (dgv_ammunition.CurrentRow.Index != -1) { Ammunition ammunition = new Ammunition(); currentID = Convert.ToInt32(dgv_ammunition.CurrentRow.Cells["col_ammunitionID"].Value); using (EFTDBEntities context = new EFTDBEntities()) { ammunition = context.Ammunitions.Where(a => a.AmmunitionID == currentID).FirstOrDefault(); string caliberName = context.Calibers.Where(c => c.CaliberID == ammunition.CaliberID).FirstOrDefault().Name; txt_name.Text = ammunition.Name; txt_damage.Text = ammunition.Damage.ToString(); txt_penetration.Text = ammunition.Penetration.ToString(); txt_armourDamage.Text = ammunition.ArmourDamage.ToString(); txt_accuracy.Text = ammunition.Accuracy.ToString(); txt_recoil.Text = ammunition.Recoil.ToString(); txt_fragmentationChance.Text = ammunition.FragmentationChance.ToString(); txt_ricochetChance.Text = ammunition.RicochetChance.ToString(); txt_speed.Text = ammunition.Speed.ToString(); cbox_caliberID.SelectedIndex = cbox_caliberID.FindStringExact(caliberName); } btn_delete.Enabled = true; btn_add.Enabled = false; } }
// Check if the user is sure about deleting, then get the itemID from the currentID and change the entity state to Deleted in the context. // When the changes are saved the database will delete the row using a standard DELETE query. private void btn_delete_Click(object sender, EventArgs e) { if (MessageBox.Show($"Are you sure you want to Delete {txt_name.Text}?", "SQL deletion operation", MessageBoxButtons.YesNo) == DialogResult.Yes) { Ammunition ammunition = new Ammunition(); using (EFTDBEntities context = new EFTDBEntities()) { ammunition = context.Ammunitions.Where(a => a.AmmunitionID == currentID).FirstOrDefault(); var entry = context.Entry(ammunition); // Make sure the entity is being tracked by the context. if (entry.State == EntityState.Detached) { context.Ammunitions.Attach(ammunition); } // Change the entities state to deleted. context.Ammunitions.Remove(ammunition); // Save changes made to the context (removing the deleted entity) to the database. context.SaveChanges(); // Reload the datasources. LoadData(); } Clear(); } // Enable/Disable appropriate buttons. btn_delete.Enabled = false; btn_save.Enabled = false; btn_add.Enabled = true; }
// If the data is valid, create a new instance of the appropriate entity and input the data. Change the entity state to Modified in the context // When the changes are saved the database will update the row using a standard UPDATE query. private void btn_save_Click(object sender, EventArgs e) { if (ValidateData()) { using (EFTDBEntities context = new EFTDBEntities()) { int caliberID = context.Calibers.Where(c => c.Name == cbox_caliberID.Text).FirstOrDefault().CaliberID; Ammunition ammunition = new Ammunition() { AmmunitionID = currentID, Name = txt_name.Text, Damage = int.Parse(txt_damage.Text), Penetration = int.Parse(txt_penetration.Text), ArmourDamage = int.Parse(txt_armourDamage.Text), Accuracy = int.Parse(txt_accuracy.Text), Recoil = int.Parse(txt_recoil.Text), FragmentationChance = decimal.Parse(txt_fragmentationChance.Text), RicochetChance = decimal.Parse(txt_ricochetChance.Text), Speed = int.Parse(txt_speed.Text), CaliberID = caliberID }; context.Entry(ammunition).State = EntityState.Modified; context.SaveChanges(); LoadData(); MessageBox.Show($"Updated {ammunition.Name} successfully!"); } Clear(); btn_save.Enabled = false; btn_add.Enabled = true; btn_delete.Enabled = false; } }
// If the data is valid create a new instance of the DBContext and add the entity. // When the changes are saved the database will insert the row using a standard INSERT query. private void btn_add_Click(object sender, EventArgs e) { if (ValidateData()) { using (EFTDBEntities context = new EFTDBEntities()) { // Fetch the corresponding caliberID from the database by using a LINQ to Entity query, returning the first row or null. int caliberID = context.Calibers.Where(c => c.Name == cbox_caliberID.Text).FirstOrDefault().CaliberID; Ammunition ammunition = new Ammunition() { Name = txt_name.Text, Damage = int.Parse(txt_damage.Text), Penetration = int.Parse(txt_penetration.Text), ArmourDamage = int.Parse(txt_armourDamage.Text), Accuracy = int.Parse(txt_accuracy.Text), Recoil = int.Parse(txt_recoil.Text), FragmentationChance = decimal.Parse(txt_fragmentationChance.Text), RicochetChance = decimal.Parse(txt_ricochetChance.Text), Speed = int.Parse(txt_speed.Text), CaliberID = caliberID }; // Add the new entity to the context with the Added state. context.Ammunitions.Add(ammunition); // Save changes made to the context to the database. context.SaveChanges(); // Reload the datasources. LoadData(); MessageBox.Show($"Added {ammunition.Name} successfully!"); } Clear(); } }
public static Character BuildTestWizard() { Character wizard = new Character(); wizard.kind = CreatureKinds.Humanoids; wizard.name = "Morkin"; wizard.raceClass = "Human Wizard"; wizard.alignment = "Chaotic Neutral"; wizard.baseArmorClass = 10; GenerateRandomAttributes(wizard); wizard.remainingHitDice = "1 d8"; wizard.level = 1; wizard.inspiration = 0; wizard.initiative = 2; wizard.baseSpeed = 30; wizard.hitPoints = 33; wizard.tempHitPoints = 0; wizard.maxHitPoints = 127; wizard.proficiencyBonus = 2; wizard.savingThrowProficiency = Ability.Intelligence | Ability.Charisma; wizard.proficientSkills = Skills.arcana | Skills.slightOfHand | Skills.deception; wizard.Equip(Weapon.buildShortSword()); wizard.Pack(Weapon.buildBlowgun()); wizard.Pack(Ammunition.buildBlowgunNeedlePack()); return(wizard); }
public void ThrowGren(Transform t, Player p, Ammunition GrenadeType, int grenNum) { if (MainNode.HasNode(_primedGrenade1Name)) { if (grenNum == 1) { _primedGrenade1.Throw(t); } else { _primedGrenade2.Throw(t); } } else { PrimeGren(p, GrenadeType, grenNum); } if (grenNum == 1) { _primedGrenade1 = null; } else { _primedGrenade2 = null; } }
public void RoundTrip_Ammunition2() { Ammunition ammo = new Ammunition() { BallisticCoefficient = new BallisticCoefficient(0.295, DragTableId.G1), Weight = new Measurement <WeightUnit>(9.1, WeightUnit.Gram), MuzzleVelocity = new Measurement <VelocityUnit>(2956.5, VelocityUnit.FeetPerSecond), }; SerializerRoundtrip serializer = new SerializerRoundtrip(); var node = serializer.Serialize(ammo); node.Should().NotBeNull(); var ammo1 = serializer.Deserialize <Ammunition>(node); ammo1.Should().NotBeNull(); ammo1.BallisticCoefficient.Should().Be(ammo.BallisticCoefficient); ammo1.Weight.Should().Be(ammo.Weight); ammo1.MuzzleVelocity.Should().Be(ammo.MuzzleVelocity); ammo1.BulletDiameter.Should().Be(ammo.BulletDiameter); ammo1.BulletLength.Should().Be(ammo.BulletLength); }
public InputController(Camera camera, Transform transform, Ship ship, Transform barrel, float force, Rigidbody2D bullet) { _camera = camera; _transform = transform; _ship = ship; _ammunition = new Ammunition(bullet, barrel, force); }
public Ammunition Direct() { _frame.Position = 0; return(Ammunition.CreateFromBinary( frame: _frame, recordTypeConverter: null)); }
/// ========================================= /// LoadItemLists() /// ========================================= public static List <Ammunition> LoadAmmoLists() { List <Ammunition> ammo = new List <Ammunition>(); try { XDocument xml = XDocument.Parse(Properties.Resources.AmmoList); XElement root = xml.Element("Ammunitions"); var Ammunitions = root.Elements("Ammunition"); foreach (XElement elem in Ammunitions) { Ammunition ammunition = new Ammunition() { Name = (string)elem.Attribute("name"), Quantity = (string)elem.Attribute("qty") }; ammo.Add(ammunition); } } catch (Exception e) { Console.WriteLine(e.StackTrace); MessageBox.Show("Error: Default ammunition list not loaded successfully", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } return(ammo); }
/// <summary> Removes a certain ammount of ammunition over the ammoboxes </summary> /// <param name="value"> The ammount of ammunition to remove </param> /// <returns> If there is enough ammo left </returns> public bool SubstractAmmo(Ammunition ammotype, uint value = 1u) { AmmoBox [] boxes = System.Array.FindAll(Parts.GetAll <AmmoBox>(), x => x.AmmoType == ammotype); if (boxes.Length == 0) { return(false); } while (true) { foreach (AmmoBox box in boxes) { if (value == 0u) { return(true); } if (GetAmmo(ammotype) == 0u) { return(false); } if (box.Ammunition > 0u) { box.Ammunition--; value--; } } } }
void LoadWeapon(int id) { currentAmmoId = id; currentAmmo = ammunitions[id]; currentAmmoQuantity = currentAmmo.quantity; timeOfAction = 0f; }
/// <summary> /// Fires the one shot. /// </summary> /// <param name="_target">Target.</param> public void FireOneShot(Transform _target) { if (Ammunition.Enabled) { Ammunition.Fire(_target); } if (Recoil.Enabled) { Recoil.Start(); } if (LaunchSound.Enabled) { LaunchSound.Play(); } if (MuzzleFlash.Enabled) { MuzzleFlash.Start(); } if (Shell.Enabled) { Shell.Start(); } if (Effect.Enabled) { Effect.Start(OwnerComponent); } }
public IEnumerator Reload(int playerNumber, Ammunition ammunition) { if (AmmoClip.IsFull() || IsReloading) { yield break; // if already reloading, then return } else { IsReloading = true; //Debug.Log(this.name + ": Reloading..."); AudioManager.Play(ReloadSound); EventAggregator.GetInstance().Publish <OnWeaponReloadEvent>(new OnWeaponReloadEvent(playerNumber, this)); for (float timer = ReloadTime; timer > 0; timer -= 0.25f) { if (ReloadCancel) { IsReloading = ReloadCancel = false; yield break; } yield return(new WaitForSeconds(0.25f)); } AudioManager.Stop(ReloadSound); AmmoClip.LoadAmmunition(ammunition); EventAggregator.GetInstance().Publish(new OnWeaponAmmoChangedEvent(playerNumber, AmmoClip.GetCurrentAmmo())); EventAggregator.GetInstance().Publish(new OnPlayerAmmoChangedEvent(playerNumber, ammunition)); AudioManager.Play(ReloadFinishSound); IsReloading = false; } }
public void Should_be_empty_when_initialLoadout_is_zero() // Value object specific { // ARRANGE Ammunition target = new Ammunition(Zero); Check.That(target.IsEmpty()).IsTrue(); }
public void RemoveAmmunition(string macro) { List <ShipAmmunitionItemData> tempList = null; try { tempList = Ammunition.Where(a => a.Ware == macro).ToList(); if (tempList.Count > 1) { throw new Exception("There is more than one ware entry of that type. That can't be right!"); } else if (tempList.Count < 1) { throw new Exception("There is no ware entry of that type."); } ShipAmmunitionItemData temp = tempList.First(); temp.RemoveNode(); Ammunition.Remove(temp); } catch (Exception ex) { throw new Exception("Unable to remove ware entry", ex); } }
protected override void ShotFire() { if (Target == null) { Attack = false; return; } if (Attack) { bool canShot = Vector3.Distance(transform.position, Target.transform.position) <= ShotRange; // Lasers from laser gameobject Ammunition ammunition = Ammunitions[GameData.LocalPlayer.SelectedAmmo[0]]; if (ammunition.Ready) { if (canShot) { CreateBullet(Game.Damage(Damage, ammunition), ammunition, lasers); } else { Debug.LogError("Cel poza zasiegiem!"); } } // Rockets from ship transform //ammunition = Ammunitions[GameData.LocalPlayer.SelectedAmmo[1]]; //if (ammunition.Ready && canShot) //{ // List<Transform> trans = new List<Transform>(); // trans.Add(transform); // CreateBullet(Game.Damage((int)(1000 * ammunition.Multiplier), ammunition), ammunition, trans); //} } }
public bool Fire() { if (currentReloadTime <= 0 && currentClipSize > 0) { Ammunition projectile = Instantiate(ammunition, ammunitionSpawnPoint); projectile.transform.parent = null; currentClipSize--; if (currentClipSize == 0) { currentClipSize = clipSize; currentReloadTime = reloadTime; } else { currentReloadTime = fireRate; } if (shootingSound != null) { shootingSound.Play(); } return(true); } return(false); }
public Ammunition Direct() { _frame.Position = 0; return(Ammunition.CreateFromBinary( frame: _frame, translationParams: null)); }
protected virtual void Start() { NewPosition = transform.position; foreach (Transform engine in EngineTransform) { engines.Add(engine.GetComponent <ParticleSystem>()); } foreach (Transform laser in LaserTransform) { lasers.Add(laser); } ShipNameGameObject.GetComponent <TextMesh>().text = Name + " [" + Level + "]"; engine = true; Engines = false; foreach (LaserBullets laser in AmmunitionsLaser) { Ammunition ammunition = new Ammunition(); ammunition.Bullet = GameData.LaserObjects[laser]; ammunition.TimeReload = GameData.LaserObjects[laser].GetComponent <Bullet>().TimeReload; Ammunitions.Add(ammunition); } foreach (RocketBullets rocket in AmmunitionsRocket) { Ammunition ammunition = new Ammunition(); ammunition.Bullet = GameData.RocketObjects[rocket]; ammunition.TimeReload = GameData.RocketObjects[rocket].GetComponent <Bullet>().TimeReload; Ammunitions.Add(ammunition); } }
public RangeWeapon(Texture2D texture, string name, int maxInStack, int nowInStack, int durability, ItemType itemType, int damage, int range, int ammunition, Ammunition ammunitionType) : base(damage, range, texture, name, maxInStack, nowInStack, durability, ItemType.RangeWeapon) { Clip = ammunition; AmmunitionType = ammunitionType; }
public ControlHitList(Hit h) { InitializeComponent(); txt_No.IsReadOnly = true; txt_No.Text = h.hitNo.ToString(); ComboBoxItem cbI_W = new ComboBoxItem(); cbI_W.Content = Weapon.GetNameFromID(h.weaponID); cbI_W.Tag = h.weaponID; cb_Weapon.Items.Add(cbI_W); cb_Weapon.IsReadOnly = true; cb_Weapon.SelectedItem = cbI_W; ComboBoxItem cbI_A = new ComboBoxItem(); cbI_A.Content = Ammunition.GetNameFromID(h.ammuID); cbI_A.Tag = h.ammuID; cb_Ammo.Items.Add(cbI_A); cb_Ammo.IsReadOnly = true; cb_Ammo.SelectedItem = cbI_A; txt_Distance.Text = h.distance.ToString(); txt_Distance.IsReadOnly = true; txt_WeaponPt.Text = h.weaponPt.ToString(); txt_WeaponPt.IsReadOnly = true; txt_Damage.Text = h.dmg.ToString(); txt_Damage.IsReadOnly = true; }
public override string ToString() { return($"Tank {TankName}: " + $"Ammunition - {Ammunition.ToString()}, " + $"Armor - {Armor.ToString()}, " + $"Maneuverability - {Maneuverability.ToString()}"); }
private void FillComboboxes(Loadout_Line line) { IEnumerable <Weapon> ieW = Weapon.GetAll(); foreach (Weapon ob in ieW) { ComboBoxItem cbI = new ComboBoxItem(); cbI.Content = ob.name; cbI.Tag = ob.id; cbWeapon.Items.Add(cbI); if (line.weaponID == ob.id) { cbWeapon.SelectedItem = cbI; } } IEnumerable <Ammunition> ieA = Ammunition.GetAll(); foreach (Ammunition ob in ieA) { ComboBoxItem cbI = new ComboBoxItem(); cbI.Content = ob.name; cbI.Tag = ob.id; cbAmmunition.Items.Add(cbI); if (line.ammunitionID == ob.id) { cbAmmunition.SelectedItem = cbI; } } }
public void TestRangedWeaponAttack() { RangedWeapon longBow = new RangedWeapon() { Name = "Longbow" , WeaponType = "Martial Ranged", AmmunitionType = "Arrow", CloseRange = 150, MaxRange = 600, Cost = new CoinPurse() { Gold = 50 }, Weight = 2, Properties = new [] { "heavy", "two-handed" } }; longBow.WeaponDamages.Add(new Damage() { DefaultDamage = 4, QuantityOfDice = 2, SidesOfDice = 8, DamageType = "piercing" }); Ammunition basicArrows = new Ammunition() { AmmunitionType = "Arrow", Name = "Basic Arrows", Quantity = 20 }; DamageRealized attack = longBow.WeaponHit(ref basicArrows); Console.WriteLine(attack.DamageDescription); Assert.AreEqual(19, basicArrows.Quantity); }
private IEnumerator BurstFireBulletGroups() { int bulletsFired = 0; while (bulletsFired < BurstFireRate) { bulletsFired++; yield return(new WaitForSeconds(0.1f)); Ammunition ammo = Instantiate(Ammo, transform.position + (transform.forward), transform.rotation); ammo.DamageOfRound = DamagePerHit; ammo.LaunchTowards(transform.position + (transform.forward * Range)); if (EnableSideFire) { Ammunition rightShot = Instantiate(Ammo, transform.position + (transform.right), transform.rotation); rightShot.DamageOfRound = DamagePerHit; rightShot.LaunchTowards(transform.position + (transform.right * Range)); Ammunition leftShot = Instantiate(Ammo, transform.position + (-transform.right), transform.rotation); leftShot.DamageOfRound = DamagePerHit; leftShot.LaunchTowards(transform.position + (-transform.right * Range)); } } }
public static bool Prefix(CharacterEquipment __instance, ref Ammunition __result) { var self = __instance; if (self.GetEquippedItem(EquipmentSlot.EquipmentSlotIDs.RightHand) is Weapon weapon && weapon.ItemID == ManaBowID) { var character = At.GetValue(typeof(CharacterEquipment), self, "m_character") as Character; if (!character.Inventory.HasEquipped(ManaArrowID)) { if (!character.Inventory.OwnsItem(ManaArrowID)) { var newAmmo = ItemManager.Instance.GenerateItemNetwork(ManaArrowID) as Ammunition; newAmmo.ChangeParent(self.GetMatchingEquipmentSlotTransform(EquipmentSlot.EquipmentSlotIDs.Quiver)); __result = newAmmo; return(false); } else { var ammoFromID = character.Inventory.GetOwnedItems(ManaArrowID); ammoFromID[0].ChangeParent(self.GetMatchingEquipmentSlotTransform(EquipmentSlot.EquipmentSlotIDs.Quiver)); __result = ammoFromID[0] as Ammunition; return(false); } } else { __result = self.GetEquippedItem(EquipmentSlot.EquipmentSlotIDs.Quiver) as Ammunition; return(false); } } return(true); }
//Deprecated public BombView(Ammunition bomb, IFrameWork framework) : base(bomb, framework) { initOnScene(); fly(); refreshPosition(); }
void Start() { if (Weapon == null) { Debug.Log("Weapon not connected to WeaponSetter"); return; } _spriteRenderer = GetComponent <SpriteRenderer>(); _ammo = GetComponent <Ammunition>(); if (_ammo != null) { _ammo.Initialize(Weapon); } if (_spriteRenderer != null) { _spriteRenderer.sprite = Weapon.Avatar; } var shooter = GetComponent <WeaponShooter>(); shooter.SetFireRate(Weapon.FireRate); }
public void offhandAnimateHOldMag(Ammunition ArgAmmo) { int gt = (int)ArgAmmo; // Debug.Log(gt); _anim.SetInteger("AnimMagType", gt); }
private void AmmoCollect(int objectID, Ammunition ammo) { switch (ammo.Classification) { case AmmunitionClassification.Bullet: Bullets.Count += ammo.Count; break; case AmmunitionClassification.Shell: Shells.Count += ammo.Count; break; case AmmunitionClassification.Grenade: Grenades.Count += ammo.Count; break; } }
public static void AmmoUpdateEvent(int objectID, Ammunition clip, Ammunition reserve) { AmmoUpdateEventHandler(objectID, clip, reserve); }
public static void AmmoCollectEvent(int objectID, Ammunition ammo) { AmmoCollectEventHandler(objectID, ammo); }
override protected void Start() { _ammo = GetComponentInChildren<Ammunition>(); base.Start(); }