/// <summary>Makes the unit from server data.</summary> /// <param name="unitType">Type of the unit.</param> /// <param name="size">The size.</param> /// <param name="unitID">The unit identifier.</param> /// <param name="context">The context.</param> /// <returns>A UnitViewModel</returns> public EditUnitViewModel.UnitViewModel MakeUnitFromServerData(int unitType, int size, int unitID, ArmyDataContext context) { Unit newUnit; switch (unitType) { case 1: newUnit = new Termagant(); break; case 2: newUnit = new HiveTyrant(); break; case 3: newUnit = new HiveGuard(); break; case 4: newUnit = new Lictor(); break; case 5: newUnit = new Zoanthrope(); break; case 6: newUnit = new Venomthrope(); break; case 7: newUnit = new Haruspex(); break; case 8: newUnit = new Pyrovore(); break; case 9: newUnit = new Gargoyle(); break; case 10: newUnit = new Harpy(); break; case 11: newUnit = new HiveCrone(); break; case 12: newUnit = new SporeMine(); break; case 13: newUnit = new Biovore(); break; case 14: newUnit = new Tyrannofex(); break; case 15: newUnit = new Deathleaper(); break; case 16: newUnit = new OldOneEye(); break; case 17: newUnit = new Hormagaunt(); break; case 18: newUnit = new RipperSwarm(); break; default: // TODO: make better default newUnit = new Termagant(); break; } newUnit.CurrentSize = size; newUnit.UnitID = unitID; var listWargear = (from wargear in context.Engage_Unit_Wargears join names in context.Engage_WargearUpgrades on wargear.WargearID equals names.WargearID where wargear.UnitID == unitID select new { wargear.Amount, names.Wargear }) .ToDictionary(a => a.Wargear, a => a.Amount); foreach (var wargear in listWargear) { newUnit.SetWargear(wargear.Key, wargear.Value); } var listRules = from rules in context.Engage_Unit_Rules join names in context.Engage_RulesUpgrades on rules.RuleID equals names.RuleID where rules.UnitID == unitID select names.RuleName; foreach (var rule in listRules) { newUnit.SetUpgrade(rule); } var editUrl = this.ModuleContext.EditUrl( "UnitId", unitID.ToString(CultureInfo.InvariantCulture), "EditUnit"); var newUnitModel = new EditUnitViewModel.UnitViewModel(newUnit, editUrl); return(newUnitModel); }
static void Main(string[] args) { World netherland = new World(); WeakWorld weakland = new WeakWorld(); Console.WriteLine(); Console.WriteLine("WILLKOMMEN IN WEAKLAND"); Console.WriteLine(); weakland.Print(); Console.WriteLine(); weakland.ShowInfo(); Console.WriteLine(); weakland.ShowAboutObjAtIndex(1); weakland.EraseFromWeakWorld(); Console.WriteLine(); weakland.Print(); Console.WriteLine(); weakland.ShowAboutObjAtIndex(1); weakland.ShowAboutObjAtIndex(2); Console.WriteLine(); weakland.ShowInfo(); Console.WriteLine(); Console.WriteLine("///////////////////////////////////"); Console.WriteLine(); Console.WriteLine("WILLKOMMEN IN NETHERLAND"); Console.WriteLine("Before sort: "); netherland.Print(); netherland.Sort(); Console.WriteLine(); Console.WriteLine("After sort: "); netherland.Print(); Console.WriteLine(); netherland.ShowInfo(); netherland.ShowAboutObjAtIndex(2); Console.WriteLine(); netherland.EraseFromWorld(0); netherland.Print(); Console.WriteLine(); netherland.ShowAboutObjAtIndex(2); netherland.ShowAboutObjAtIndex(0); Console.WriteLine(); netherland.ShowInfo(); Console.WriteLine(); netherland.EraseFromWorld(3); netherland.Print(); Console.WriteLine(); netherland.ShowAboutObjAtIndex(2); Console.WriteLine(); netherland.ShowInfo(); Console.WriteLine(); Console.WriteLine("////////////////////////////////////////"); Console.WriteLine(); Serializator serializator = new Serializator(); Pegasus taurus = new Pegasus("Taurus", 120, 40); serializator.SaveAsBinary(taurus, "taurusInfo.bin"); serializator.LoadFromBinary("taurusInfo.bin"); Dragon annoch = new Dragon("Annoch", 150, 60, "red dragon-warrior", "BUUURN!"); serializator.SaveAsSoap(annoch, "annochInfo.soap"); serializator.LoadFromSoap("annochInfo.soap"); Gargoyle sophist = new Gargoyle("Sophist", 100, 70); serializator.SaveAsXml(sophist, "sophistInfo.xml"); serializator.LoadFromXml("sophistInfo.xml"); Console.ReadKey(); }
public static void Main(string[] args) { Speaker speak = null; Informator info = null; Creature unicorn = new Unicorn("Saint", 100, 60); Console.WriteLine(); Creature dragon = new Dragon("Fire", 200, 50); Console.WriteLine(); Dragon special = new Dragon("Morroh", 200, 80, "black dragon", "Rise!"); Console.WriteLine(); Manticore manticore = new Manticore(); Console.WriteLine(); Creature phoenix = new Phoenix("Taurus", 100, 60); Console.WriteLine(); Phoenix derek = new Phoenix("Derek", 120, 70); derek.Age = 55; Console.WriteLine(); Gargoyle howley = new Gargoyle("Howley", 100, 60); Console.WriteLine(); Unicorn trevor = new Unicorn("Trevor", 100, 60); Console.WriteLine(); Pegasus rash = new Pegasus("Rash", 120, 70); Console.WriteLine(); ArrayList creatures = new ArrayList(); creatures.Add(unicorn); creatures.Add(derek); creatures.Add(special); creatures.Add(howley); creatures.Add(dragon); creatures.Add(phoenix); creatures.Add(trevor); creatures.Add(rash); foreach(Creature c in creatures) { react += c.React; speak += c.Say; info += c.Print; } info(); Console.WriteLine(); speak(); Console.WriteLine(); Console.WriteLine(); try { trevor.Fight(manticore); Console.WriteLine("{0}: {1}", manticore.Name, manticore.Health); trevor.Enchant(dragon); trevor.Fight(null); } catch(AttackingMonsterException e) { Console.WriteLine("{0}: {1}", e.GetType(), e.Message); } Console.WriteLine(); try { rash.Fight(howley); Console.WriteLine("{0}: {1}", howley.Name, howley.Health); Console.WriteLine(); rash.Fight(special); } catch(AttackingMonsterException e) { Console.WriteLine("{0}: {1}", e.GetType(), e.Message); } try { rash.Fight(null); } catch(AttackingMonsterException e) { Console.WriteLine("{0}: {1}", e.GetType(), e.Message); } Console.WriteLine(); Console.WriteLine(); Console.WriteLine("I summon you, Satan!"); Demon satan = Demon.Summon("Satan!"); satan.Print(); Console.WriteLine(); satan.Say(); Console.WriteLine(); satan.ApocalypsisEvent += new EventHandler<ApocalypsisEventArgs>(ReactionOfAnimals); satan.CarryChaos(); satan.ApocalypsisEvent -= new EventHandler<ApocalypsisEventArgs>(ReactionOfAnimals); Console.WriteLine(); Console.WriteLine("Damage from earthquake:"); Console.WriteLine("{0}: {1}", unicorn.Name, unicorn.Health); Console.WriteLine("{0}: {1}", derek.Name, derek.Health); Console.WriteLine("{0}: {1}", phoenix.Name, phoenix.Health); Console.WriteLine("{0}: {1}", trevor.Name, trevor.Health); Console.WriteLine("{0}: {1}", rash.Name, rash.Health); Console.WriteLine(); manticore.Poison(trevor); manticore.Fight(rash); Console.WriteLine("{0}: {1}", rash.Name, rash.Health); Console.ReadKey(); }