private void btnMoveDownLegs_Click(object sender, EventArgs e) { if (lstLegs.SelectedIndex >= 0 && lstLegs.SelectedIndex < lstLegs.Items.Count - 1) { PartLegs LegsPath = ListLegs[lstLegs.SelectedIndex]; string Legs = (string)lstLegs.Items[lstLegs.SelectedIndex]; int Index = lstLegs.SelectedIndex + 1; ListLegs.RemoveAt(lstLegs.SelectedIndex); lstLegs.Items.RemoveAt(lstLegs.SelectedIndex); //Selected Index is now -1. ListLegs.Insert(Index, LegsPath); lstLegs.Items.Insert(Index, Legs); lstLegs.SelectedIndex = Index; //Update the stats if the item was at position 0. if (Index == 1) { UpdatePartBoosts(); } } }
private void btnMoveUpLegs_Click(object sender, EventArgs e) { if (lstLegs.SelectedIndex > 0) { PartLegs LegsPath = ListLegs[lstLegs.SelectedIndex]; string Legs = (string)lstLegs.Items[lstLegs.SelectedIndex]; int Index = lstLegs.SelectedIndex - 1; ListLegs.RemoveAt(lstLegs.SelectedIndex); lstLegs.Items.RemoveAt(lstLegs.SelectedIndex); //Selected Index is now -1. ListLegs.Insert(Index, LegsPath); lstLegs.Items.Insert(Index, Legs); lstLegs.SelectedIndex = Index; //Update the stats if there's a new item at position 0. if (Index == 0) { UpdatePartBoosts(); } } }
private void UpdatePartBoosts() { Int32 BaseHP = 0; Int32 BaseEN = 0; Int32 BaseArmor = 0; Int32 BaseMobility = 0; float BaseMovement = 0; Int32 MEL = 0; Int32 RNG = 0; Int32 DEF = 0; Int32 EVA = 0; Int32 HIT = 0; #region Head if (ListHead.Count > 0 && lstHead.SelectedIndex >= 0) { PartHead ActiveHead = ListHead[lstHead.SelectedIndex]; BaseHP += ActiveHead.HP; BaseEN += ActiveHead.EN; BaseArmor += ActiveHead.Armor; BaseMobility += ActiveHead.Mobility; BaseMovement += ActiveHead.Movement; MEL += ActiveHead.MEL; RNG += ActiveHead.RNG; DEF += ActiveHead.DEF; EVA += ActiveHead.EVA; HIT += ActiveHead.HIT; #region Antena if (ActiveHead.ListPartAntena.Count > 0) { Part ActiveAntena = new Part(ListHead[lstHead.SelectedIndex].ListPartAntena[0], PartTypes.HeadAntena); BaseHP += ActiveAntena.BaseHP; BaseEN += ActiveAntena.BaseEN; BaseArmor += ActiveAntena.BaseArmor; BaseMobility += ActiveAntena.BaseMobility; BaseMovement += ActiveAntena.BaseMovement; MEL += ActiveAntena.MEL; RNG += ActiveAntena.RNG; DEF += ActiveAntena.DEF; EVA += ActiveAntena.EVA; HIT += ActiveAntena.HIT; } #endregion #region Ears if (ActiveHead.ListPartEars.Count > 0) { Part ActiveEars = new Part(ListHead[lstHead.SelectedIndex].ListPartEars[0], PartTypes.HeadEars); BaseHP += ActiveEars.BaseHP; BaseEN += ActiveEars.BaseEN; BaseArmor += ActiveEars.BaseArmor; BaseMobility += ActiveEars.BaseMobility; BaseMovement += ActiveEars.BaseMovement; MEL += ActiveEars.MEL; RNG += ActiveEars.RNG; DEF += ActiveEars.DEF; EVA += ActiveEars.EVA; HIT += ActiveEars.HIT; } #endregion #region Eyes if (ActiveHead.ListPartEyes.Count > 0) { Part ActiveEyes = new Part(ListHead[lstHead.SelectedIndex].ListPartEyes[0], PartTypes.HeadEyes); BaseHP += ActiveEyes.BaseHP; BaseEN += ActiveEyes.BaseEN; BaseArmor += ActiveEyes.BaseArmor; BaseMobility += ActiveEyes.BaseMobility; BaseMovement += ActiveEyes.BaseMovement; MEL += ActiveEyes.MEL; RNG += ActiveEyes.RNG; DEF += ActiveEyes.DEF; EVA += ActiveEyes.EVA; HIT += ActiveEyes.HIT; } #endregion #region CPU if (ActiveHead.ListPartCPU.Count > 0) { Part ActiveCPU = new Part(ListHead[lstHead.SelectedIndex].ListPartCPU[0], PartTypes.HeadCPU); BaseHP += ActiveCPU.BaseHP; BaseEN += ActiveCPU.BaseEN; BaseArmor += ActiveCPU.BaseArmor; BaseMobility += ActiveCPU.BaseMobility; BaseMovement += ActiveCPU.BaseMovement; MEL += ActiveCPU.MEL; RNG += ActiveCPU.RNG; DEF += ActiveCPU.DEF; EVA += ActiveCPU.EVA; HIT += ActiveCPU.HIT; } #endregion } #endregion #region Torso if (ListTorso.Count > 0 && lstTorso.SelectedIndex >= 0) { PartTorso ActiveTorso = ListTorso[lstTorso.SelectedIndex]; BaseHP += ActiveTorso.HP; BaseEN += ActiveTorso.EN; BaseArmor += ActiveTorso.Armor; BaseMobility += ActiveTorso.Mobility; BaseMovement += ActiveTorso.Movement; MEL += ActiveTorso.MEL; RNG += ActiveTorso.RNG; DEF += ActiveTorso.DEF; EVA += ActiveTorso.EVA; HIT += ActiveTorso.HIT; #region Core if (ActiveTorso.ListPartCore.Count > 0) { Part ActiveCore = new Part(ListTorso[lstTorso.SelectedIndex].ListPartCore[0], PartTypes.TorsoCore); BaseHP += ActiveCore.BaseHP; BaseEN += ActiveCore.BaseEN; BaseArmor += ActiveCore.BaseArmor; BaseMobility += ActiveCore.BaseMobility; BaseMovement += ActiveCore.BaseMovement; MEL += ActiveCore.MEL; RNG += ActiveCore.RNG; DEF += ActiveCore.DEF; EVA += ActiveCore.EVA; HIT += ActiveCore.HIT; } #endregion #region Radiator if (ActiveTorso.ListPartRadiator.Count > 0) { Part ActiveRadiator = new Part(ListTorso[lstTorso.SelectedIndex].ListPartRadiator[0], PartTypes.TorsoRadiator); BaseHP += ActiveRadiator.BaseHP; BaseEN += ActiveRadiator.BaseEN; BaseArmor += ActiveRadiator.BaseArmor; BaseMobility += ActiveRadiator.BaseMobility; BaseMovement += ActiveRadiator.BaseMovement; MEL += ActiveRadiator.MEL; RNG += ActiveRadiator.RNG; DEF += ActiveRadiator.DEF; EVA += ActiveRadiator.EVA; HIT += ActiveRadiator.HIT; } #endregion #region Shell if (ActiveTorso.ListPartShell.Count > 0) { Part ActiveShell = new Part(ListTorso[lstTorso.SelectedIndex].ListPartShell[0], PartTypes.Shell); BaseHP += ActiveShell.BaseHP; BaseEN += ActiveShell.BaseEN; BaseArmor += ActiveShell.BaseArmor; BaseMobility += ActiveShell.BaseMobility; BaseMovement += ActiveShell.BaseMovement; MEL += ActiveShell.MEL; RNG += ActiveShell.RNG; DEF += ActiveShell.DEF; EVA += ActiveShell.EVA; HIT += ActiveShell.HIT; } #endregion } #endregion #region Left arm if (ListLeftArm.Count > 0 && lstLeftArm.SelectedIndex >= 0) { PartArm ActiveLeftArm = ListLeftArm[lstLeftArm.SelectedIndex]; BaseHP += ActiveLeftArm.HP; BaseEN += ActiveLeftArm.EN; BaseArmor += ActiveLeftArm.Armor; BaseMobility += ActiveLeftArm.Mobility; BaseMovement += ActiveLeftArm.Movement; MEL += ActiveLeftArm.MEL; RNG += ActiveLeftArm.RNG; DEF += ActiveLeftArm.DEF; EVA += ActiveLeftArm.EVA; HIT += ActiveLeftArm.HIT; #region Shell if (ActiveLeftArm.ListPartShell.Count > 0) { Part ActiveShell = new Part(ListLeftArm[lstLeftArm.SelectedIndex].ListPartShell[0], PartTypes.Shell); BaseHP += ActiveShell.BaseHP; BaseEN += ActiveShell.BaseEN; BaseArmor += ActiveShell.BaseArmor; BaseMobility += ActiveShell.BaseMobility; BaseMovement += ActiveShell.BaseMovement; MEL += ActiveShell.MEL; RNG += ActiveShell.RNG; DEF += ActiveShell.DEF; EVA += ActiveShell.EVA; HIT += ActiveShell.HIT; } #endregion #region Strength if (ActiveLeftArm.ListPartStrength.Count > 0) { Part ActiveStrength = new Part(ListLeftArm[lstLeftArm.SelectedIndex].ListPartStrength[0], PartTypes.Strength); BaseHP += ActiveStrength.BaseHP; BaseEN += ActiveStrength.BaseEN; BaseArmor += ActiveStrength.BaseArmor; BaseMobility += ActiveStrength.BaseMobility; BaseMovement += ActiveStrength.BaseMovement; MEL += ActiveStrength.MEL; RNG += ActiveStrength.RNG; DEF += ActiveStrength.DEF; EVA += ActiveStrength.EVA; HIT += ActiveStrength.HIT; } #endregion } #endregion #region Right arm if (ListRightArm.Count > 0 && lstRightArm.SelectedIndex >= 0) { PartArm ActiveRightArm = ListRightArm[lstRightArm.SelectedIndex]; BaseHP += ActiveRightArm.HP; BaseEN += ActiveRightArm.EN; BaseArmor += ActiveRightArm.Armor; BaseMobility += ActiveRightArm.Mobility; BaseMovement += ActiveRightArm.Movement; MEL += ActiveRightArm.MEL; RNG += ActiveRightArm.RNG; DEF += ActiveRightArm.DEF; EVA += ActiveRightArm.EVA; HIT += ActiveRightArm.HIT; #region Shell if (ActiveRightArm.ListPartShell.Count > 0) { Part ActiveShell = new Part(ListRightArm[lstRightArm.SelectedIndex].ListPartShell[0], PartTypes.Shell); BaseHP += ActiveShell.BaseHP; BaseEN += ActiveShell.BaseEN; BaseArmor += ActiveShell.BaseArmor; BaseMobility += ActiveShell.BaseMobility; BaseMovement += ActiveShell.BaseMovement; MEL += ActiveShell.MEL; RNG += ActiveShell.RNG; DEF += ActiveShell.DEF; EVA += ActiveShell.EVA; HIT += ActiveShell.HIT; } #endregion #region Strength if (ActiveRightArm.ListPartStrength.Count > 0) { Part ActiveStrength = new Part(ListRightArm[lstRightArm.SelectedIndex].ListPartStrength[0], PartTypes.Strength); BaseHP += ActiveStrength.BaseHP; BaseEN += ActiveStrength.BaseEN; BaseArmor += ActiveStrength.BaseArmor; BaseMobility += ActiveStrength.BaseMobility; BaseMovement += ActiveStrength.BaseMovement; MEL += ActiveStrength.MEL; RNG += ActiveStrength.RNG; DEF += ActiveStrength.DEF; EVA += ActiveStrength.EVA; HIT += ActiveStrength.HIT; } #endregion } #endregion #region Legs if (ListLegs.Count > 0 && lstLegs.SelectedIndex >= 0) { PartLegs ActiveLegs = ListLegs[lstLegs.SelectedIndex]; BaseHP += ActiveLegs.HP; BaseEN += ActiveLegs.EN; BaseArmor += ActiveLegs.Armor; BaseMobility += ActiveLegs.Mobility; BaseMovement += ActiveLegs.Movement; MEL += ActiveLegs.MEL; RNG += ActiveLegs.RNG; DEF += ActiveLegs.DEF; EVA += ActiveLegs.EVA; HIT += ActiveLegs.HIT; #region Shell if (ActiveLegs.ListPartShell.Count > 0) { Part ActiveShell = new Part(ListLegs[lstLegs.SelectedIndex].ListPartShell[0], PartTypes.Shell); BaseHP += ActiveShell.BaseHP; BaseEN += ActiveShell.BaseEN; BaseArmor += ActiveShell.BaseArmor; BaseMobility += ActiveShell.BaseMobility; BaseMovement += ActiveShell.BaseMovement; MEL += ActiveShell.MEL; RNG += ActiveShell.RNG; DEF += ActiveShell.DEF; EVA += ActiveShell.EVA; HIT += ActiveShell.HIT; } #endregion #region Strength if (ActiveLegs.ListPartStrength.Count > 0) { Part ActiveStrength = new Part(ListLegs[lstLegs.SelectedIndex].ListPartStrength[0], PartTypes.Strength); BaseHP += ActiveStrength.BaseHP; BaseEN += ActiveStrength.BaseEN; BaseArmor += ActiveStrength.BaseArmor; BaseMobility += ActiveStrength.BaseMobility; BaseMovement += ActiveStrength.BaseMovement; MEL += ActiveStrength.MEL; RNG += ActiveStrength.RNG; DEF += ActiveStrength.DEF; EVA += ActiveStrength.EVA; HIT += ActiveStrength.HIT; } #endregion } #endregion #region Label text #region Unit boosts lblBaseHPBoost.Text = BaseHP.ToString(); if (BaseHP > 0) { lblBaseHPBoost.ForeColor = Color.Green; } else if (BaseHP < 0) { lblBaseHPBoost.ForeColor = Color.Red; } else { lblBaseHPBoost.ForeColor = Color.Black; } lblBaseENBoost.Text = BaseEN.ToString(); if (BaseEN > 0) { lblBaseENBoost.ForeColor = Color.Green; } else if (BaseEN < 0) { lblBaseENBoost.ForeColor = Color.Red; } else { lblBaseENBoost.ForeColor = Color.Black; } lblBaseArmorBoost.Text = BaseArmor.ToString(); if (BaseArmor > 0) { lblBaseArmorBoost.ForeColor = Color.Green; } else if (BaseArmor < 0) { lblBaseArmorBoost.ForeColor = Color.Red; } else { lblBaseArmorBoost.ForeColor = Color.Black; } lblBaseMobilityBoost.Text = BaseMobility.ToString(); if (BaseMobility > 0) { lblBaseMobilityBoost.ForeColor = Color.Green; } else if (BaseMobility < 0) { lblBaseMobilityBoost.ForeColor = Color.Red; } else { lblBaseMobilityBoost.ForeColor = Color.Black; } lblBaseMovementBoost.Text = BaseMovement.ToString(); if (BaseMovement > 0) { lblBaseMovementBoost.ForeColor = Color.Green; } else if (BaseMovement < 0) { lblBaseMovementBoost.ForeColor = Color.Red; } else { lblBaseMovementBoost.ForeColor = Color.Black; } #endregion #region Unit's Pilot stats boosts lblMELBoost.Text = MEL.ToString(); if (MEL > 0) { lblMELBoost.ForeColor = Color.Green; } else if (MEL < 0) { lblMELBoost.ForeColor = Color.Red; } else { lblMELBoost.ForeColor = Color.Black; } lblRNGBoost.Text = RNG.ToString(); if (RNG > 0) { lblRNGBoost.ForeColor = Color.Green; } else if (RNG < 0) { lblRNGBoost.ForeColor = Color.Red; } else { lblRNGBoost.ForeColor = Color.Black; } lblDEFBoost.Text = DEF.ToString(); if (DEF > 0) { lblDEFBoost.ForeColor = Color.Green; } else if (DEF < 0) { lblDEFBoost.ForeColor = Color.Red; } else { lblDEFBoost.ForeColor = Color.Black; } lblEVABoost.Text = EVA.ToString(); if (EVA > 0) { lblEVABoost.ForeColor = Color.Green; } else if (EVA < 0) { lblEVABoost.ForeColor = Color.Red; } else { lblEVABoost.ForeColor = Color.Black; } lblHITBoost.Text = HIT.ToString(); if (HIT > 0) { lblHITBoost.ForeColor = Color.Green; } else if (HIT < 0) { lblHITBoost.ForeColor = Color.Red; } else { lblHITBoost.ForeColor = Color.Black; } #endregion #endregion }
protected void ListMenuItemsSelected(List <string> Items) { if (Items == null) { return; } for (int I = 0; I < Items.Count; I++) { switch (ItemSelectionChoice) { case ItemSelectionChoices.Pilot: Character NewPilot = new Character(Items[I], null, DicRequirement, DicEffect); if (NewPilot != null) { if (lstPilots.Items.Contains(NewPilot.Name)) { MessageBox.Show("This pilot is already listed.\r\n" + NewPilot.Name); return; } ListPilot.Add(NewPilot); lstPilots.Items.Add(Items[I]); } break; case ItemSelectionChoices.Head: string HeadName = Items[I].Substring(0, Items[I].Length - 5).Substring(27); PartHead NewHead = new PartHead(HeadName); if (lstHead.Items.Contains(NewHead.FullName)) { MessageBox.Show("This head is already listed.\r\n" + NewHead.FullName); return; } ListHead.Add(NewHead); lstHead.Items.Add(HeadName); break; case ItemSelectionChoices.Torso: string TorsoName = Items[I].Substring(0, Items[I].Length - 5).Substring(28); PartTorso NewTorso = new PartTorso(TorsoName); if (NewTorso != null) { if (lstTorso.Items.Contains(NewTorso.FullName)) { MessageBox.Show("This torso is already listed.\r\n" + NewTorso.FullName); return; } ListTorso.Add(NewTorso); lstTorso.Items.Add(TorsoName); } break; case ItemSelectionChoices.LeftArm: string LeftArmName = Items[I].Substring(0, Items[I].Length - 5).Substring(26); PartArm NewLeftArm = new PartArm(LeftArmName); if (NewLeftArm != null) { if (lstLeftArm.Items.Contains(NewLeftArm.FullName)) { MessageBox.Show("This left arm is already listed.\r\n" + NewLeftArm.FullName); return; } ListLeftArm.Add(NewLeftArm); lstLeftArm.Items.Add(LeftArmName); } break; case ItemSelectionChoices.RightArm: string RightArmName = Items[I].Substring(0, Items[I].Length - 5).Substring(26); PartArm NewRightArm = new PartArm(RightArmName); if (NewRightArm != null) { if (lstRightArm.Items.Contains(NewRightArm.FullName)) { MessageBox.Show("This right arm is already listed.\r\n" + NewRightArm.FullName); return; } ListRightArm.Add(NewRightArm); lstRightArm.Items.Add(RightArmName); } break; case ItemSelectionChoices.Legs: string LegsName = Items[I].Substring(0, Items[I].Length - 5).Substring(27); PartLegs NewLegs = new PartLegs(LegsName); if (NewLegs != null) { if (lstLegs.Items.Contains(NewLegs.FullName)) { MessageBox.Show("This head is already listed.\r\n" + NewLegs.FullName); return; } ListLegs.Add(NewLegs); lstLegs.Items.Add(LegsName); } break; } } }