static Character Newcharacter(string name) { Character C = new Character(); IEnergy ERESERVE = C; C.Name = name; int chance = prng.Next(1, 101); if (chance > 30) { ERESERVE = new EnergyReserve(); ERESERVE.MaxEnergy = prng.Next(1, 9) * 10; ERESERVE.Energy = ERESERVE.MaxEnergy; (ERESERVE as Power).calculatecost(); (ERESERVE as Entity).Name = "Energy Reserve"; (ERESERVE as EnergyReserve).User = C; C.addpower((Power)ERESERVE); } chance = prng.Next(1, 101); if (chance > 20) { EnergyBlast EBLAST = new EnergyBlast(); EBLAST.Name = "Energy Blast"; EBLAST.Dice = prng.Next(1, 6); EBLAST.EnergySource = ERESERVE; EBLAST.DamageClass = (damageclass)prng.Next(0, Enum.GetNames(typeof(damageclass)).Length + 1); EBLAST.DamageType = (damagetype)prng.Next(0, Enum.GetNames(typeof(damagetype)).Length + 1); EBLAST.User = C; EBLAST.calculatecost(); C.addpower(EBLAST); } if (chance > 60) { Armor ARMORPOWER = new Armor(); ARMORPOWER.Name = "Armor"; ARMORPOWER.REDEF = prng.Next(1, 10); ARMORPOWER.RPDEF = prng.Next(1, 10); ARMORPOWER.EnergySource = ERESERVE; ARMORPOWER.User = C; ARMORPOWER.calculatecost(); C.addpower(ARMORPOWER); } return(C); }
private void PowersListBox_SelectedIndexChanged(object sender, EventArgs e) { CharacterGroupBox.Visible = false; EnergyReserveGroupBox.Visible = false; ArmorGroupBox.Visible = false; if (PowersListBox.SelectedIndex < 0) { SelectedPower = null; return; } SelectedPower = (Power)PowersListBox.Items[PowersListBox.SelectedIndex]; CharNameTextBox.Text = SelectedPower.Name; if (SelectedPower is EnergyReserve) { SelectedType = selectiontype.Energy_Reserve; EnergyReserve EnRes = (EnergyReserve)SelectedPower; EnRes.calculatecost(); EnergyReservePointCostLabel.Text = "Cost: " + EnRes.RealPointCost; EnergyReserveNameTextBox.Text = EnRes.Name; EnergyReserveMaxEnergyUpDown.Value = EnRes.MaxEnergy; EnergyReserveRecoveryUpDown.Value = EnRes.Recovery; EnergyReserveGroupBox.Visible = true; EnergyReserveGroupBox.BringToFront(); } if (SelectedPower is EnergyBlast) { SelectedType = selectiontype.Energy_Blast; } if (SelectedPower is Armor) { SelectedType = selectiontype.Armor; Armor Arm = (Armor)SelectedPower; Arm.calculatecost(); ArmorPointCostLabel.Text = "Cost: " + Arm.RealPointCost; ArmorNameTextBox.Text = Arm.Name; ArmorRPDefUpDown.Value = Arm.RPDEF; ArmorREDefUpDown.Value = Arm.REDEF; ArmorGroupBox.Visible = true; ArmorGroupBox.BringToFront(); } }
static Character Newcharacter(string name) { Character C = new Character(); IEnergy ERESERVE = C; C.Name = name; int chance = prng.Next(1, 101); if (chance > 30) { ERESERVE = new EnergyReserve(); ERESERVE.MaxEnergy = prng.Next(1, 9) * 10; ERESERVE.Energy = ERESERVE.MaxEnergy; (ERESERVE as Power).calculatecost(); (ERESERVE as Entity).Name = "Energy Reserve"; (ERESERVE as EnergyReserve).User = C; C.addpower((Power)ERESERVE); } chance = prng.Next(1, 101); if (chance > 20) { EnergyBlast EBLAST = new EnergyBlast(); EBLAST.Name = "Energy Blast"; EBLAST.Dice = prng.Next(1, 6); EBLAST.EnergySource = ERESERVE; EBLAST.DamageClass = (damageclass)prng.Next(0, Enum.GetNames(typeof(damageclass)).Length + 1); EBLAST.DamageType = (damagetype)prng.Next(0, Enum.GetNames(typeof(damagetype)).Length + 1); EBLAST.User = C; EBLAST.calculatecost(); C.addpower(EBLAST); } if (chance > 60) { Armor ARMORPOWER = new Armor(); ARMORPOWER.Name = "Armor"; ARMORPOWER.REDEF = prng.Next(1, 10); ARMORPOWER.RPDEF = prng.Next(1, 10); ARMORPOWER.EnergySource = ERESERVE; ARMORPOWER.User = C; ARMORPOWER.calculatecost(); C.addpower(ARMORPOWER); } return C; }