コード例 #1
0
        /// <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);
        }
コード例 #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);
        }
コード例 #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);
 }
コード例 #4
0
        /// <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);
        }
コード例 #5
0
ファイル: AICity.cs プロジェクト: leemcknight/Similization
        /// <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);
        }