Example #1
0
 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 AddPowerButton_Click(object sender, EventArgs e)
 {
     if ((string)PowerTypeSelectionComboBox.SelectedItem == string.Empty)
     {
         return;
     }
     if (CharactersListBox.SelectedIndex < 0)
         return;
     if (string.Compare((string)PowerTypeSelectionComboBox.SelectedItem, "Energy Reserve") == 0)
     {
         EnergyReserve En = new EnergyReserve();
         En.Name = "Energy Reserve";
         (CharactersListBox.SelectedItem as Character).addpower(En);
     }
     if (string.Compare((string)PowerTypeSelectionComboBox.SelectedItem, "Armor") == 0)
     {
         Armor Arm = new Armor();
         Arm.Name = "Armor";
         (CharactersListBox.SelectedItem as Character).addpower(Arm);
     }
     if (string.Compare((string)PowerTypeSelectionComboBox.SelectedItem, "Energy Blast") == 0)
     {
         EnergyBlast En = new EnergyBlast();
         En.Name = "Energy Blast";
         En.EnergySource = SelectedCharacter;
         (CharactersListBox.SelectedItem as Character).addpower(En);
     }
     PowersListBox.DataSource = null;
     PowersListBox.DataSource = (CharactersListBox.SelectedItem as Character).Powers;
 }