private void RunCustomGenericTypes() { Musketeers <Element> elements = new Musketeers<Element>( new Element(ElementType.Nitrogen), new Element(ElementType.Beryllium), new Element(ElementType.Neon)); Console.WriteLine(elements); }
internal static void CityProduction(City city) { if (city == null || city.Size == 0 || city.Tile == null) { return; } Player player = Game.GetPlayer(city.Owner); IProduction production = null; // Create 2 defensive units per city if (player.HasAdvance <LaborUnion>()) { if (city.Tile.Units.Count(x => x is MechInf) < 2) { production = new MechInf(); } } else if (player.HasAdvance <Conscription>()) { if (city.Tile.Units.Count(x => x is Riflemen) < 2) { production = new Riflemen(); } } else if (player.HasAdvance <Gunpowder>()) { if (city.Tile.Units.Count(x => x is Musketeers) < 2) { production = new Musketeers(); } } else if (player.HasAdvance <BronzeWorking>()) { if (city.Tile.Units.Count(x => x is Phalanx) < 2) { production = new Phalanx(); } } else { if (city.Tile.Units.Count(x => x is Militia) < 2) { production = new Militia(); } } // Create city improvements if (production == null) { if (!city.HasBuilding <Barracks>()) { production = new Barracks(); } else if (player.HasAdvance <Pottery>() && !city.HasBuilding <Granary>()) { production = new Granary(); } else if (player.HasAdvance <CeremonialBurial>() && !city.HasBuilding <Temple>()) { production = new Temple(); } else if (player.HasAdvance <Masonry>() && !city.HasBuilding <CityWalls>()) { production = new CityWalls(); } } // Create Settlers if (production == null) { if (city.Size > 3 && !city.Units.Any(x => x is Settlers) && player.Cities.Length < 10) { production = new Settlers(); } } // Create some other unit if (production == null) { if (city.Units.Length < 4) { if (player.Government is Republic || player.Government is Democratic) { if (player.HasAdvance <Writing>()) { production = new Diplomat(); } } else { if (player.HasAdvance <Automobile>()) { production = new Armor(); } else if (player.HasAdvance <Metallurgy>()) { production = new Cannon(); } else if (player.HasAdvance <Chivalry>()) { production = new Knights(); } else if (player.HasAdvance <TheWheel>()) { production = new Chariot(); } else if (player.HasAdvance <HorsebackRiding>()) { production = new Cavalry(); } else if (player.HasAdvance <IronWorking>()) { production = new Legion(); } } } else { if (player.HasAdvance <Trade>()) { production = new Caravan(); } } } // Set random production if (production == null) { IProduction[] items = city.AvailableProduction.ToArray(); production = items[Common.Random.Next(items.Length)]; } city.SetProduction(production); }
private static IUnit CreateUnit(UnitType type, int x, int y) { IUnit unit; switch (type) { case UnitType.Settlers: unit = new Settlers(); break; case UnitType.Militia: unit = new Militia(); break; case UnitType.Phalanx: unit = new Phalanx(); break; case UnitType.Legion: unit = new Legion(); break; case UnitType.Musketeers: unit = new Musketeers(); break; case UnitType.Riflemen: unit = new Riflemen(); break; case UnitType.Cavalry: unit = new Cavalry(); break; case UnitType.Knights: unit = new Knights(); break; case UnitType.Catapult: unit = new Catapult(); break; case UnitType.Cannon: unit = new Cannon(); break; case UnitType.Chariot: unit = new Chariot(); break; case UnitType.Armor: unit = new Armor(); break; case UnitType.MechInf: unit = new MechInf(); break; case UnitType.Artillery: unit = new Artillery(); break; case UnitType.Fighter: unit = new Fighter(); break; case UnitType.Bomber: unit = new Bomber(); break; case UnitType.Trireme: unit = new Trireme(); break; case UnitType.Sail: unit = new Sail(); break; case UnitType.Frigate: unit = new Frigate(); break; case UnitType.Ironclad: unit = new Ironclad(); break; case UnitType.Cruiser: unit = new Cruiser(); break; case UnitType.Battleship: unit = new Battleship(); break; case UnitType.Submarine: unit = new Submarine(); break; case UnitType.Carrier: unit = new Carrier(); break; case UnitType.Transport: unit = new Transport(); break; case UnitType.Nuclear: unit = new Nuclear(); break; case UnitType.Diplomat: unit = new Diplomat(); break; case UnitType.Caravan: unit = new Caravan(); break; default: return(null); } unit.X = x; unit.Y = y; unit.MovesLeft = unit.Move; return(unit); }