public ColoredTextList_Intel(IGameDate exploredDate, IntelLevel intelLevel) { GameTimePeriod intelAge = new GameTimePeriod(exploredDate, GameTime.Date); string intelText_formatted = ConstructIntelText(intelLevel, intelAge); _list.Add(new ColoredText(intelText_formatted)); }
/// <summary> /// Updates the period to a value reflective of the supplied date. Useful /// when the period was created using IGameDates. Does nothing except issuing /// a warning if the period was created using days and years. /// </summary> /// <param name="currentDate">The current date.</param> public void UpdatePeriod(IGameDate currentDate) { if (_startDate != null) { SetPeriodValues(_startDate, currentDate); } }
private void GenerateArtificialStartDate(int days, int years) { IGameDate currentDate = GameTime.Date; // issue when called before the game starts int startYear = currentDate.Year - years; int startDay = currentDate.DayOfYear - days; if (startDay < 0) { startYear--; startDay = _daysPerYear + startDay; } _startDate = new GameDate(startDay, startYear); }
/// <summary> /// Initializes a new instance of the <see cref="GameTimePeriod"/> class. /// </summary> /// <param name="startDate">The start date.</param> /// <param name="endDate">The end date.</param> public GameTimePeriod(IGameDate startDate, IGameDate endDate) { _startDate = startDate; SetPeriodValues(startDate, endDate); }
private void SetPeriodValues(IGameDate startDate, IGameDate endDate) { int years = endDate.Year - startDate.Year; int days = endDate.DayOfYear - startDate.DayOfYear; if (days < 0) { years--; days = _daysPerYear + days; } Years = years; Days = days; PeriodInDays = years * _daysPerYear + days; }