/// <summary> /// Creates and returns a new century. /// Instantiates a new game object. /// If successful, removes the troops from the city's units /// and adds the century. /// </summary> public Century FormCentury(List <Troop> troops) { if (troops.Count >= CombinedUnitConstants.CENTURY_SIZE_LOWER_BOUND && troops.Count <= CombinedUnitConstants.CENTURY_SIZE_UPPER_BOUND) { centuryCount++; Century century = Instantiate(emptyUnitPrefab).AddComponent <Century>(); century.unitName = Utilities.instance.CountToOrdinal(centuryCount) + " Century"; century.units = troops; foreach (Troop troop in troops) { currentCity.occupyingUnits.Remove(troop); } currentCity.AddOccupyingUnits(new List <Unit>() { century }); return(century); } else { return(null); } }
public IActionResult AddCentury(CenturyViewModel model) { bool status = false; if (ModelState.IsValid) { var century = new Century(); century.Centuries = model.Centuries; using (var memoryStream = new MemoryStream()) { model.Data.CopyTo(memoryStream); century.Data = memoryStream.ToArray(); } _db.Century.Add(century); _db.SaveChanges(); status = true; } return(Json(status)); }
protected virtual void FormatYear(StringBuilder sb, PersonIdentifierFormatOption option) { if (option == null) { throw new ArgumentNullException(nameof(option)); } var withCentury = (option.WithCentury.HasValue && option.WithCentury.Value) || CenturySpecified; if (withCentury) { sb.Append(Century.ToString("00")); if (option.CenturySeparated) { sb.Append(option.CenturySeparationChar); } } sb.Append(TwoDigitYear.ToString("00")); }
/// <summary> /// Get all the key=value pairs (pins) exposed by the implementor. /// </summary> /// <param name="item">The optional item. The item with its parts /// can optionally be passed to this method for those parts requiring /// to access further data.</param> /// <returns>The pins: <c>century</c>, <c>cover-mat</c> (filtered, /// with digits), <c>support-mat</c> (filtered, with digits), /// <c>w</c>, <c>h</c> (both with format 00.00).</returns> public override IEnumerable <DataPin> GetDataPins(IItem item) { List <DataPin> pins = new List <DataPin>(); if (Century != 0) { pins.Add(CreateDataPin("century", Century.ToString(CultureInfo.InvariantCulture))); } if (!string.IsNullOrEmpty(CoverMaterial)) { pins.Add(CreateDataPin("cover-mat", DataPinHelper.DefaultFilter.Apply(CoverMaterial, true))); } if (!string.IsNullOrEmpty(SupportMaterial)) { pins.Add(CreateDataPin("support-mat", DataPinHelper.DefaultFilter.Apply(SupportMaterial, true))); } if (Size?.W != null) { pins.Add(CreateDataPin("w", Size.W.Value.ToString("00.00", CultureInfo.InvariantCulture))); } if (Size?.H != null) { pins.Add(CreateDataPin("h", Size.H.Value.ToString("00.00", CultureInfo.InvariantCulture))); } return(pins); }
public HistoricalBook(string mainHistCharacter, Century century, string author, string title, int pageNumber, int price) : base(author, title, pageNumber, price) { this.MainHistCharacter = mainHistCharacter; this.Century = century; }
private void InitializeButtons() { cancelCombineButton.onClick.AddListener(() => { EventManager.instance.fireDefaultSelectedEvent(); }); confirmCombineButton.onClick.AddListener(() => { if (UnitListIsValid()) { switch (selectedUnits[0]) { case Troop t: Century century = UnitCombiner.instance.FormCentury(new SelectedUnits <Troop>(selectedUnits).units); if (century != null) { selectedUnits.Clear(); } else { this.DeselectAllUnits(); } break; case Century c: Cohort cohort = UnitCombiner.instance.FormCohort(new SelectedUnits <Century>(selectedUnits).units); if (cohort != null) { selectedUnits.Clear(); } else { this.DeselectAllUnits(); } break; case Cohort c: Legion legion = UnitCombiner.instance.FormLegion(new SelectedUnits <Cohort>(selectedUnits).units); if (legion != null) { selectedUnits.Clear(); } else { this.DeselectAllUnits(); } break; default: break; } InitializeAvailableTroopsScrollview(); InitializeSelectedTroopsScrollview(); } else { this.DeselectAllUnits(); InitializeAvailableTroopsScrollview(); InitializeSelectedTroopsScrollview(); }; }); }
public static string GetCenturyName(this Century enumValue) { var attribute = GetFirstOrDefaultAttribute <CenturyDataAttribute>(enumValue); return(attribute != null ? attribute.DisplayName : string.Empty); }
public static int GetEndYear(this Century enumValue) { var attribute = GetFirstOrDefaultAttribute <CenturyDataAttribute>(enumValue); return(attribute != null ? attribute.EndYear : 0); }
public void fireCenturyDisbandedEvent(Century century) { Utilities.instance.Debug(century.unitName + " disbanded"); OnCenturyDisbanded?.Invoke(century); }