private void lstWeaponList_SelectedIndexChange(ListBox sender) { if (lstWeaponList.SelectedItem == null) { return; } //get default weaponType on the selected slot AKunit u = spawner.Spawned as AKunit; AKunitType.WeaponItem wi = cbxWeaponSlots.SelectedItem as AKunitType.WeaponItem; AKunitType.AlternateWeaponItem awi = lstWeaponList.SelectedItem as AKunitType.AlternateWeaponItem; string selectedBodyPartName = GetBodyPartNameFromActiveButton(); int selectedBodyPartIndex = GetBodyPartIndex(selectedBodyPartName); string weaponAlias = wi.MapObjectAlias; MapObjectAttachedObject o = u.GetFirstAttachedObjectByAlias(weaponAlias); MapObjectAttachedMapObject mo = o as MapObjectAttachedMapObject; u.Detach(mo); Weapon w = Entities.Instance.Create(awi.WeaponType, Map.Instance) as Weapon; w.PostCreate(); MapObjectAttachedMapObject amo = new MapObjectAttachedMapObject(); amo.MapObject = w; amo.PositionOffset = mo.PositionOffset; amo.Alias = mo.Alias; amo.Body = mo.Body; amo.BoneSlot = mo.BoneSlot; amo.RotationOffset = mo.RotationOffset; amo.ScaleOffset = mo.ScaleOffset; u.Attach(amo); Gun g = w as Gun; float multiplier = 1 / g.Type.NormalMode.BetweenFireTime; float rateOfFire = multiplier; if (g.Type.NormalMode.BulletExpense != 0) { rateOfFire = rateOfFire * g.Type.NormalMode.BulletExpense; } txtWeaponInfo.Text = string.Format( "Weapon Name: {0}\r\nWeapon Type: {1}\r\nDamage: {2}\r\nHeat: {3}\r\nRate of Fire: {4}\r\nPrice: {5}", w.Type.Name, "Not Implemented", g.Type.NormalMode.BulletType.Damage, g.Type.NormalMode.AKGunHeatGeneration, rateOfFire.ToString("F1"), awi.Price); }
private void btnAddWeapon_Click(Button sender) { if (cbxWeaponSlots.SelectedItem == null || lstWeaponList.SelectedItem == null) { return; } AKunit u = spawner.Spawned as AKunit; AKunitType.WeaponItem wi = cbxWeaponSlots.SelectedItem as AKunitType.WeaponItem; AKunitType.AlternateWeaponItem awi = lstWeaponList.SelectedItem as AKunitType.AlternateWeaponItem; string selectedBodyPartName = GetBodyPartNameFromActiveButton(); int selectedBodyPartIndex = GetBodyPartIndex(selectedBodyPartName); int weaponFireGroup = u.Bp[selectedBodyPartIndex].Weapons[cbxWeaponSlots.SelectedIndex].FireGroup; u.Bp[selectedBodyPartIndex].Weapons[cbxWeaponSlots.SelectedIndex].Ammo = awi.Ammo; u.Bp[selectedBodyPartIndex].Weapons[cbxWeaponSlots.SelectedIndex].MagazineCapacity = awi.MagazineCapacity; u.Bp[selectedBodyPartIndex].Weapons[cbxWeaponSlots.SelectedIndex].WeaponType = awi.WeaponType; TextBlock bodyPartBlock = variant.FindChild(selectedBodyPartName); if (bodyPartBlock == null) { bodyPartBlock = variant.AddChild(selectedBodyPartName); } if (bodyPartBlock != null) { TextBlock wBlock = bodyPartBlock.FindChild(wi.MapObjectAlias); if (wBlock == null) { wBlock = bodyPartBlock.AddChild(wi.MapObjectAlias); } if (wBlock != null) { wBlock.SetAttribute("i", lstWeaponList.SelectedIndex.ToString()); wBlock.SetAttribute("g", weaponFireGroup.ToString()); } } UpdateVariantCost(awi.Price); PopulateWeaponSlotsDropDown(selectedBodyPartName); }
private void cbxWeaponSlots_SelectedIndexChange(ListBox sender) { lstWeaponList.Items.Clear(); if (cbxWeaponSlots.SelectedItem == null) { return; } AKunitType.WeaponItem wi = cbxWeaponSlots.SelectedItem as AKunitType.WeaponItem; foreach (AKunitType.AlternateWeaponItem awi in wi.Alternates) { lstWeaponList.Items.Add(awi); } }