public override AbstractUnit Train(AbstractUnit unit) { DecoratorUnit upgradedUnit; if (unit.GetType() == typeof(Farmer)) { upgradedUnit = new BowmanUpgrade1(unit as Farmer); } else if (unit.GetType() == typeof(BowmanUpgrade1)) { upgradedUnit = new BowmanUpgrade2(unit as BowmanUpgrade1); } else { // throw new InvalidOperationException(String.Format("Building of type {0} doesn't exist.", building.GetType().Name)); throw new InvalidOperationException(String.Format("Reached maximum upgrade level for unit [{0}] {1}.", unit.Id, unit.GetType().Name)); } upgradedUnit.Id = unit.Id; upgradedUnit.Unit = unit; return(upgradedUnit); }
public void OnMouseEnter() { if (_uiActivated) { return; } _unitNameBox.SetActive(true); AbstractUnit unit = GetComponent <AbstractUnit>(); _icon.sprite = GameSingleton.Instance.entityTypeToSprite.GetEntitySprite(unit.GetEntityType()); var unitType = unit.GetType(); _unitNameText.color = unitType == typeof(AiUnit) ? _red : _green; _unitNameText.SetText(unit.GetEntityType().ToString()); _isTouchingUnit = true; }