private IUnit BuildUnit(IPromotionTree promotionTree) { var mockUnit = new Mock <IUnit>(); mockUnit.Setup(unit => unit.PromotionTree).Returns(promotionTree); return(mockUnit.Object); }
private IUnit BuildUnit( IHexCell location, ICivilization owner, IUnitTemplate template, IPromotionTree promotionTree = null ) { Mock <IUnit> mock; return(BuildUnit(location, owner, template, out mock, promotionTree)); }
public SerializablePromotionTreeData ComposePromotionTree(IPromotionTree promotionTree) { var newTreeData = new SerializablePromotionTreeData(); newTreeData.Template = promotionTree.Template.name; newTreeData.ChosenPromotions = new List <string>( promotionTree.GetChosenPromotions().Select(promotion => promotion.name) ); return(newTreeData); }
private IUnit BuildUnit(IUnitTemplate template, IPromotionTree promotionTree, ICivilization owner) { var mockUnit = new Mock <IUnit>(); mockUnit.Setup(unit => unit.Template).Returns(template); mockUnit.Setup(unit => unit.PromotionTree).Returns(promotionTree); var newUnit = mockUnit.Object; MockUnitPossessionCanon.Setup(canon => canon.GetOwnerOfPossession(newUnit)).Returns(owner); return(newUnit); }
private IUnit BuildUnit( IHexCell location, ICivilization owner, IUnitTemplate template, out Mock <IUnit> mock, IPromotionTree promotionTree = null ) { mock = new Mock <IUnit>(); mock.SetupAllProperties(); mock.Setup(unit => unit.Template).Returns(template); mock.Setup(unit => unit.PromotionTree).Returns(promotionTree); var newUnit = mock.Object; MockUnitPositionCanon.Setup(canon => canon.GetOwnerOfPossession(newUnit)).Returns(location); MockUnitPossessionCanon.Setup(canon => canon.GetOwnerOfPossession(newUnit)).Returns(owner); AllUnits.Add(newUnit); return(newUnit); }
public IUnit BuildUnit(IHexCell location, IUnitTemplate template, ICivilization owner, IPromotionTree promotionTree) { if (location == null) { throw new ArgumentNullException("location"); } else if (template == null) { throw new ArgumentNullException("template"); } else if (owner == null) { throw new ArgumentNullException("owner"); } var newUnitObject = GameObject.Instantiate(UnitConfig.UnitPrefab); var newUnitDisplay = GameObject.Instantiate(template.DisplayPrefab); newUnitDisplay.transform.SetParent(newUnitObject.transform); Container.InjectGameObject(newUnitObject); var newUnit = newUnitObject.GetComponent <GameUnit>(); newUnit.transform.SetParent(UnitContainer, false); newUnit.Template = template; newUnit.CurrentMovement = template.MaxMovement; newUnit.CurrentHitpoints = newUnit.MaxHitpoints; newUnit.CanAttack = true; newUnit.Level = 1; newUnit.PromotionTree = promotionTree; allUnits.Add(newUnit); if (UnitPossessionCanon.CanChangeOwnerOfPossession(newUnit, owner)) { UnitPossessionCanon.ChangeOwnerOfPossession(newUnit, owner); } else { throw new UnitCreationException("The newly created unit cannot be assigned to its owner"); } if (newUnit.CanRelocate(location)) { newUnit.Relocate(location); } else { throw new UnitCreationException("The newly created unit cannot be placed at its location"); } UnitSignals.NewUnitCreated.OnNext(newUnit); return(newUnit); }