예제 #1
0
        // Executes the end-of-turn processes related to the game,
        // such as resetting the active unit, incrementing the year,
        // and updating shields, gold, and other ResourceType for all
        // the cities in the game.
        private void DoTurn()
        {
            HistoryItem historyItem;

            foreach (Country colony in this.countries)
            {
                colony.DoTurn();
                historyItem               = new HistoryItem();
                historyItem.Country       = colony;
                historyItem.CulturePoints = colony.CulturePoints;
                historyItem.Power         = colony.PowerFactor;
                historyItem.Score         = colony.Score;
                historyItem.Year          = this.year;
                this.history.AddHistoryItem(historyItem);
                colony.NotifyEndOfTurn = false;
            }

            //TODO: correctly increment year based on current year
            this.year++;

            OnTurnFinished();
        }
예제 #2
0
        /// <summary>
        /// Loads the history.
        /// </summary>
        /// <param name="reader"></param>
        public void Load(XmlReader reader)
        {
            if (reader == null)
            {
                throw new ArgumentNullException("reader");
            }

            while (reader.Read())
            {
                if (reader.NodeType == XmlNodeType.EndElement && reader.Name == "History")
                {
                    break;
                }

                if (reader.NodeType == XmlNodeType.Element && reader.Name == "HistoryItem")
                {
                    HistoryItem item = new HistoryItem();
                    item.Load(reader);
                    this.historyQueue.Enqueue(item);
                }
            }
        }
예제 #3
0
 /// <summary>
 /// Adds a history item to the History of the game.
 /// </summary>
 /// <param name="item"></param>
 public void AddHistoryItem(HistoryItem item)
 {
     this.historyQueue.Enqueue(item);
 }