/// <summary>
        /// Gets the correct subclass of a <see cref="Country"/> object.
        /// </summary>
        /// <param name="reader"></param>
        /// <returns></returns>
        public static Country CreateCountry(XmlReader reader)
        {
            if (reader == null)
            {
                throw new ArgumentNullException("reader");
            }

            Country c  = null;
            bool    ai = false;

            while (reader.Read())
            {
                if (reader.Name == "AI")
                {
                    ai = Convert.ToBoolean(reader.ReadString(), CultureInfo.InvariantCulture);
                    break;
                }
            }
            if (ai)
            {
                c = new AICountry();
            }
            else
            {
                c = new Country();
            }
            c.Load(reader);
            return(c);
        }
Exemple #2
0
        /// <summary>
        /// Gets an appropriate strategy for the opponent.
        /// </summary>
        /// <param name="opponent"></param>
        /// <returns></returns>
        internal static AIStrategy GetStrategy(AICountry opponent)
        {
            //TODO: implement
            AIStrategy strategy = new ExpansionStrategy(opponent);

            return(strategy);
        }
Exemple #3
0
 /// <summary>
 /// Initializes a new instance of the <see cref="ExpansionStrategy"/> class.
 /// </summary>
 internal ExpansionStrategy(AICountry foreignCountry)
 {
     if (foreignCountry == null)
     {
         throw new ArgumentNullException("foreignCountry");
     }
     foreignCountry.TradeProposed += new EventHandler <TradeProposedEventArgs>(OnTradeProposed);
 }
        /// <summary>
        /// Creates a <see cref="Country"/> with the specified parameters.
        /// </summary>
        /// <param name="civilization"></param>
        /// <param name="leaderName"></param>
        /// <param name="isAIPlayer"></param>
        /// <param name="playerColor"></param>
        /// <returns></returns>
        public static Country CreateCountry(Civilization civilization, string leaderName, bool isAIPlayer, Color playerColor)
        {
            if (civilization == null)
            {
                throw new ArgumentNullException("civilization");
            }

            GameRoot root        = GameRoot.Instance;
            Country  newCountry  = null;
            GridCell randomCell  = root.Grid.FindRandomDryCell();
            Point    coordinates = randomCell.Coordinates;

            if (isAIPlayer)
            {
                newCountry = new AICountry(civilization, leaderName, coordinates);
            }
            else
            {
                newCountry = new Country(civilization, leaderName, coordinates);
            }
            newCountry.Color = playerColor;

            return(newCountry);
        }
Exemple #5
0
        /// <summary>
        /// Initializes a new instance of the <see cref="AICity"/> class.
        /// </summary>
        /// <param name="coordinates"></param>
        /// <param name="parentCountry"></param>
        public AICity(Point coordinates, Country parentCountry) : base(coordinates, parentCountry)
        {
            AICountry parent = parentCountry as AICountry;

            parent.Strategy.Invoke(this);
        }