public void ShootAt_ShouldReturnHitWhenAShipIsHit() { //Arrange var playerBuilder = new PlayerBuilder(); playerBuilder.GridMock.Setup(g => g.Shoot(It.IsAny <GridCoordinate>())).Returns((GridCoordinate c) => new GridSquare(c) { Status = GridSquareStatus.Hit }); var kind = ShipKind.All.NextRandomElement(); IShip hitShip = new ShipBuilder(kind).Build(); playerBuilder.FleetMock.Setup(f => f.FindShipAtCoordinate(It.IsAny <GridCoordinate>())).Returns(hitShip); IPlayer opponent = playerBuilder.Build(); GridCoordinate coordinate = new GridCoordinateBuilder().Build(); _humanPlayer.ReloadBombs(); //Act var result = _humanPlayer.ShootAt(opponent, coordinate); //Assert playerBuilder.GridMock.Verify(g => g.Shoot(coordinate), Times.Once, "The Shoot method of the opponent grid should have been called."); Assert.That(result.ShotFired, Is.True, "The result should indicate that the shot was fired."); Assert.That(result.Hit, Is.True, "The result should indicate that it was a hit."); playerBuilder.FleetMock.Verify(f => f.FindShipAtCoordinate(coordinate), Times.Once, "Use the FindShipAtCoordinate of the opponent fleet to determine which kind of ship was hit."); }
public void OnPointerClick(PointerEventData eventData) { if (Input.GetKey(KeyCode.LeftShift)) { ClearPreset(); return; } if (!valid) { return; // allow user to left shift out blueprint so return after that } // TODO: check if adding a part back into your inventory validates the preset if (!blueprint && (builder.reconstructStatus == ShipBuilder.ReconstructButtonStatus.Valid)) { blueprint = ScriptableObject.CreateInstance <EntityBlueprint>(); blueprint.coreShellSpriteID = player.blueprint.coreShellSpriteID; blueprint.coreSpriteID = player.blueprint.coreSpriteID; blueprint.parts = new List <EntityBlueprint.PartInfo>(); foreach (ShipBuilderPart part in cursorScript.parts) { if (!part.isInChain || !part.validPos) { blueprint = null; return; } blueprint.parts.Add(part.info); } if (player.cursave.presetBlueprints == null || (player.cursave.presetBlueprints != null && player.cursave.presetBlueprints.Length < 5)) { player.cursave.presetBlueprints = new string[5]; } player.cursave.presetBlueprints[number - 1] = JsonUtility.ToJson(blueprint); } else if (blueprint) { cursorScript.ClearAllParts(); foreach (EntityBlueprint.PartInfo info in blueprint.parts) { if (!builder.DecrementPartButton(ShipBuilder.CullSpatialValues(info))) { // cursorScript.ClearAllParts(); builder.CloseUI(false); return; } } var x = new EntityBlueprint.PartInfo[blueprint.parts.Count]; blueprint.parts.CopyTo(x); player.blueprint.parts = new List <EntityBlueprint.PartInfo>(x); builder.CloseUI(true); OnPointerExit(null); player.Rebuild(); } }
public void Should_BuildShip_WithDefaultCriteria(ShipType shipType) { // Arrange var expectedShipSize = GetExpectedShipSize(shipType); var expectedLastField = GetExpectedLastField(OrientationType.Horizontal, 1, 1, expectedShipSize); // Act var ship = new ShipBuilder(shipType).Build(); // Assert ship.Should().NotBeNull(); ship.Should().BeOfType(GetExpectedType(shipType)); ship.ShipType.Should().Be(shipType); ship.Size.Should().Be(expectedShipSize); ship.StartField.X.Should().Be(1); ship.StartField.Y.Should().Be(1); ship.Orientation.Should().Be(OrientationType.Horizontal); ship.Fields.Should().HaveCount(expectedShipSize); ship.Fields.First().Should().Be(ship.StartField); ship.Fields.First().X.Should().Be(1); ship.Fields.First().Y.Should().Be(1); ship.Fields.Last().Should().Be(expectedLastField); }
void Update() { if (!shipbuilder) { shipbuilder = ShipBuilder.instance; } }
public void Context() { _unitOfWork = new NhibernateUnitOfWork(new CoreDddSharedNhibernateConfigurator()); _unitOfWork.BeginTransaction(); var ship = new ShipBuilder().Build(); _unitOfWork.Save(ship); var updateShipCommand = new UpdateShipCommand { ShipId = ship.Id, ShipName = "updated ship name", Tonnage = 34.5m }; var updateShipCommandHandler = new UpdateShipCommandHandler(new NhibernateRepository <Ship>(_unitOfWork)); #if NET40 updateShipCommandHandler.Execute(updateShipCommand); #endif #if NETCOREAPP updateShipCommandHandler.ExecuteAsync(updateShipCommand).Wait(); #endif _unitOfWork.Flush(); _unitOfWork.Clear(); _updatedShip = _unitOfWork.Get <Ship>(ship.Id); }
public void DetermineTargetCoordinate_ShouldShootANeighborOfAHitSquare() { for (int numberOfChecks = 0; numberOfChecks < 5; numberOfChecks++) { //Arrange GridCoordinate hitCoordinate = new GridCoordinateBuilder(_grid.Size).Build(); _gridBuilder.WithSquareStatus(hitCoordinate, GridSquareStatus.Hit); var ship = new ShipBuilder(ShipKind.Carrier).Build(); _strategy.RegisterShotResult(hitCoordinate, ShotResult.CreateHit(ship, true)); IList <GridCoordinate> expectedCoordinates = new List <GridCoordinate>(); foreach (Direction direction in Direction.BasicDirections) { GridCoordinate neighbor = hitCoordinate.GetNeighbor(direction); if (!neighbor.IsOutOfBounds(_grid.Size)) { expectedCoordinates.Add(neighbor); } } //Act GridCoordinate result = _strategy.DetermineTargetCoordinate(); Assert.That(expectedCoordinates.Contains(result), Is.True, $"Bij een leeg grid met een raak shot op {hitCoordinate} " + $"moet er geschoten worden op ייn van de volgende coordinaten: {expectedCoordinates.ToArray().Print()}. " + $"De strategie kiest soms echter {result}"); Setup(); } }
public static void TakePart(Entity entity, TractorBeam tractor) { if (entity as Yard) { // Waits to see if it will get more parts Yard.lastPartTakenTime = Time.time; Yard.partsTakenCombo++; } else { PassiveDialogueSystem.Instance.PushPassiveDialogue(entity.ID, "<color=lime>Your part has been added into your inventory.</color>", 4); } var shellPart = tractor.GetTractorTarget().GetComponent <ShellPart>(); var info = shellPart.info; info = ShipBuilder.CullSpatialValues(info); ShipBuilder.AddOriginToDictionary(shellPart); PlayerCore.Instance.cursave.partInventory.Add(info); PartIndexScript.AttemptAddToPartsObtained(info); PartIndexScript.AttemptAddToPartsSeen(info); if (NodeEditorFramework.Standard.YardCollectCondition.OnYardCollect != null) { NodeEditorFramework.Standard.YardCollectCondition.OnYardCollect.Invoke(info.partID, info.abilityID, shellPart.droppedSectorName); } Destroy(shellPart.gameObject); }
public void UpdateChain() { SetReconstructButton(cursorScript.parts.Count > DroneUtilities.GetPartLimit(currentData.type) ? ReconstructButtonStatus.PastPartLimit : ReconstructButtonStatus.Valid); var shellRect = ShipBuilder.GetRect(shellImage.rectTransform); shellRect.Expand(10); foreach (ShipBuilderPart shipPart in cursorScript.parts) { shipPart.isInChain = false; var partBounds = ShipBuilder.GetRect(shipPart.rectTransform); shipPart.isInChain = partBounds.Intersects(shellRect); } foreach (ShipBuilderPart shipPart in cursorScript.parts) { if (shipPart.isInChain) { UpdateChainHelper(shipPart); } } foreach (ShipBuilderPart shipPart in cursorScript.parts) { if (!shipPart.isInChain || !shipPart.validPos) { SetReconstructButton(ReconstructButtonStatus.PartInvalidPosition); return; } } }
private void Export() { var data = ParseDronePart(currentPart); var blueprint = ScriptableObject.CreateInstance <EntityBlueprint>(); JsonUtility.FromJsonOverwrite(DroneWorkshop.ParseDronePart(currentPart).drone, blueprint); blueprint.parts = new List <EntityBlueprint.PartInfo>(); foreach (ShipBuilderPart part in cursorScript.parts) { blueprint.parts.Add(part.info); } data.drone = JsonUtility.ToJson(blueprint); var list = player.GetInventory(); var index = list.FindIndex(x => x.Equals(currentPart)); if (index == -1) { list = player.blueprint.parts; index = list.FindIndex(x => x.Equals(currentPart)); } currentPart.secondaryData = JsonUtility.ToJson(data); list[index] = currentPart; CloseUI(true); #if UNITY_EDITOR if (Input.GetKey(KeyCode.LeftShift)) { ShipBuilder.SaveBlueprint(blueprint); } #endif }
public void Should_BuildShip_WithGivenCriteria(ShipType shipType, OrientationType orientation, int x, int y) { // Arrange var expectedShipSize = GetExpectedShipSize(shipType); var expectedLastField = GetExpectedLastField(orientation, x, y, expectedShipSize); // Act var ship = new ShipBuilder(shipType) .OnPosition(x, y) .WithOrientation(orientation) .Build(); // Assert ship.Should().NotBeNull(); ship.Should().BeOfType(GetExpectedType(shipType)); ship.ShipType.Should().Be(shipType); ship.Size.Should().Be(expectedShipSize); ship.StartField.X.Should().Be(x); ship.StartField.Y.Should().Be(y); ship.Orientation.Should().Be(orientation); ship.Fields.Should().HaveCount(expectedShipSize); ship.Fields.First().Should().Be(ship.StartField); ship.Fields.First().X.Should().Be(x); ship.Fields.First().Y.Should().Be(y); ship.Fields.Last().Should().Be(expectedLastField); }
public Ship GetShip() { //var builder = new ShipBuilder(Owner, Battle, x, endx, y, endy, isHorizontal); IShipBuilder shipabstractbuilder = new ShipBuilder(Owner, Battle, x, endx, y, endy, isHorizontal); AbstractShipBuilder builder = new AbstractShipBuilder(shipabstractbuilder); ShipChain buildReset = new BuildReset(builder); ShipChain buildBase = new BuildBase(builder); ShipChain buildCoordinates = new BuildCoordinates(builder); ShipChain buildSize = new BuildSize(builder); buildReset.SetNextChain(buildBase); buildBase.SetNextChain(buildCoordinates); buildCoordinates.SetNextChain(buildSize); buildSize.SetNextChain(null); ShipChain mainBuild = buildReset; mainBuild.Build(); System.Diagnostics.Debug.WriteLine("Chain of responsibility: shipbuilding chain executed"); //builder.BuildBase(); //builder.BuildCoordinates(); //builder.BuildSize(); return(builder.GetShip()); }
public void Build_InputShip_ReturnsShipRelativeCells(Ship ship, List <Cell> expectedResult) { var shipBuilder = new ShipBuilder(); var result = shipBuilder.Build(ship); Assert.That(result, Is.EqualTo(expectedResult)); }
public void CreateShouldReturnInstanceOfBuilder() { //act var builder = ShipBuilder.Create(_shipFactoryMock.Object); //assert Assert.IsNotNull(builder, $"Method {nameof(ShipBuilder.Create)} of class {nameof(ShipBuilder)} should return instance of {nameof(IShipBuilder)}"); }
bool IsTooClose(ShipBuilderPart otherPart) { var closeConstant = mode == BuilderMode.Workshop ? -1.2F : -1F; var rect1 = ShipBuilder.GetRect(rectTransform); var rect2 = ShipBuilder.GetRect(otherPart.rectTransform); rect1.Expand(closeConstant * rect1.extents); rect2.Expand(closeConstant * rect2.extents); return(rect1.Intersects(rect2)); }
// Constructor public JobsManager() : base() { myHuntingBuilding = new Hunting(); myFishingBuilding = new Fishing(); myShipBuilderBuilding = new ShipBuilder(); myMineralBuilding = new MineralGathering(); myWoodBuilding = new WoodGathering(); myBarrack = new Barrack(); nameJob = ""; }
public void BuildShip_UnknownDirection_ShouldThrow() { var map = BoardBuilder.buildBoard(Constants.BOARD_SIZE).Map; TestDelegate buildShipDelegate = () => ShipBuilder.buildShip(map, "A1", 200, '8'); var exception = Assert.Throws <Exception>(buildShipDelegate); Assert.AreEqual(exception.Message, "Unknown direction was provided, can not construct ship"); }
public void BuildShip_Horizontal_DoesntCreateShipLargerThanBoard() { var map = BoardBuilder.buildBoard(Constants.BOARD_SIZE).Map; TestDelegate buildShipDelegate = () => ShipBuilder.buildShip(map, "A1", 200, Constants.DIRECTION_HORIZONTAL); var exception = Assert.Throws <Exception>(buildShipDelegate); Assert.AreEqual(exception.Message, "Ship will go out of bounds of the board."); }
public void BuildShip_Vertical_DoesntGoOutOfBounds() { var map = BoardBuilder.buildBoard(Constants.BOARD_SIZE).Map; TestDelegate buildShipDelegate = () => ShipBuilder.buildShip(map, "A9", 5, Constants.DIRECTION_VERTICAL); var exception = Assert.Throws <Exception>(buildShipDelegate); Assert.AreEqual(exception.Message, "Ship will go out of bounds of the board."); }
public void BuildShip_Horizontal_Correctly() { var map = BoardBuilder.buildBoard(Constants.BOARD_SIZE).Map; var ship = ShipBuilder.buildShip(map, "A1", 2, Constants.DIRECTION_HORIZONTAL); Assert.AreEqual(map['A'][0].Ship, ship); Assert.AreEqual(map['B'][0].Ship, ship); Assert.IsNull(map['C'][0].Ship); }
public void Initialize() { this._builder = new ShipBuilder(this.App); this._crits = new GameObjectSet(this.App); this._camera = new OrbitCameraController(this.App); this._camera.DesiredDistance = 10000f; this._crits.Add((IGameObject)this._camera); this._shipHoloView = new ShipHoloView(this.App, this._camera); this._shipID = 0; }
public void BuildShip_Vertical_Correctly() { var map = BoardBuilder.buildBoard(Constants.BOARD_SIZE).Map; var ship = ShipBuilder.buildShip(map, "A1", 2, Constants.DIRECTION_VERTICAL); Assert.AreEqual(map['A'][0].Ship, ship); Assert.AreEqual(map['A'][1].Ship, ship); Assert.IsNull(map['A'][2].Ship); }
void Start() { topUI = Default; shipbuilder = ShipBuilder.instance; iconActive = skin.GetStyle("Icon Active"); iconDisabled = skin.GetStyle ("Icon Disabled"); iconNormal = skin.GetStyle ("Icon Button"); buttonActive = skin.GetStyle("ActiveButton"); colorIndicator = skin.GetStyle ("ColorIndicator"); emptyStyle = skin.GetStyle ("Empty"); }
void Start() { topUI = Default; shipbuilder = ShipBuilder.instance; iconActive = skin.GetStyle("Icon Active"); iconDisabled = skin.GetStyle("Icon Disabled"); iconNormal = skin.GetStyle("Icon Button"); buttonActive = skin.GetStyle("ActiveButton"); colorIndicator = skin.GetStyle("ColorIndicator"); emptyStyle = skin.GetStyle("Empty"); }
public void BuildShip_ShipsShouldNotOverlap() { var map = BoardBuilder.buildBoard(Constants.BOARD_SIZE).Map; ShipBuilder.buildShip(map, "A1", 2, Constants.DIRECTION_VERTICAL); TestDelegate buildShipDelegate = () => ShipBuilder.buildShip(map, "A2", 2, Constants.DIRECTION_HORIZONTAL);; var exception = Assert.Throws <Exception>(buildShipDelegate); Assert.AreEqual(exception.Message, "2 ships can not be placed on the same cell"); }
bool PartIsTooClose(ShipBuilderPart part, ShipBuilderPart otherPart) { var closeConstant = mode == BuilderMode.Workshop ? -1.2F : -1F; var rect1 = ShipBuilder.GetRect(part.rectTransform); var rect2 = ShipBuilder.GetRect(otherPart.rectTransform); // add small number (0.005) to deal with floating point issues rect1.Expand((closeConstant - 0.005F) * rect1.extents); rect2.Expand((closeConstant - 0.005F) * rect2.extents); return(rect1.Intersects(rect2)); }
public static bool TryBuild(this Enemy me) { ShipBuilder builder = me.GetComponent <ShipBuilder> (); if (!builder) { return(false); } builder.Build(); return(true); }
protected override void Update() { if (!isDead) { foreach (WeaponAbility weapon in GetComponentsInChildren <WeaponAbility>()) { weapon.Tick(); } } base.Update(); TargetManager.Enqueue(targeter); if (FactionManager.IsAllied(faction, 0)) { if ((transform.position - PlayerCore.Instance.transform.position).sqrMagnitude <= 75) { var player = PlayerCore.Instance; if (player.GetTractorTarget() && (player.GetTractorTarget().GetComponent <ShellPart>() || player.GetTractorTarget().GetComponent <Shard>()) && !tractor.GetTractorTarget()) { tractor.SetTractorTarget(player.GetTractorTarget()); player.SetTractorTarget(null); } } if (tractor.GetTractorTarget() && (transform.position - tractor.GetTractorTarget().transform.position).sqrMagnitude <= 10) { if (tractor.GetTractorTarget().GetComponent <ShellPart>()) { PassiveDialogueSystem.Instance.PushPassiveDialogue(ID, "<color=lime>Your part has been added into your inventory.</color>"); var shellPart = tractor.GetTractorTarget().GetComponent <ShellPart>(); var info = shellPart.info; info = ShipBuilder.CullSpatialValues(info); ShipBuilder.AddOriginToDictionary(shellPart); PlayerCore.Instance.cursave.partInventory.Add(info); PartIndexScript.AttemptAddToPartsObtained(info); PartIndexScript.AttemptAddToPartsSeen(info); if (NodeEditorFramework.Standard.YardCollectCondition.OnYardCollect != null) { NodeEditorFramework.Standard.YardCollectCondition.OnYardCollect.Invoke(info.partID, info.abilityID, shellPart.droppedSectorName); } Destroy(shellPart.gameObject); } else if (tractor.GetTractorTarget().GetComponent <Shard>()) { PassiveDialogueSystem.Instance.PushPassiveDialogue(ID, "<color=lime>Your shard has been added into your stash.</color>"); var shard = tractor.GetTractorTarget().GetComponent <Shard>(); var tiers = new int[] { 1, 5, 20 }; PlayerCore.Instance.shards += tiers[shard.tier]; ShardCountScript.DisplayCount(PlayerCore.Instance.shards); Destroy(shard.gameObject); } } } }
// Use this for initialization void Start() { myHuntingBuilding = new Hunting(); myFishingBuilding = new Fishing(); myShipBuilderBuilding = new ShipBuilder(); myMineralBuilding = new MineralGathering(); myWoodBuilding = new WoodGathering(); textDisplay(); setAllJobPanelInactive(); }
static void Main(string[] args) { Builder builder = new CarBuilder(); Vehisle vehisle = builder.VehisleCreate(); vehisle.Info(); Builder buider1 = new ShipBuilder(); Vehisle vehisle1 = buider1.VehisleCreate(); vehisle1.Info(); }
protected void Awake() { ShipBuilder builder = GetComponent <ShipBuilder> (); if (builder) { builder.Build(); } m_Animator = GetComponentInChildren <Animator> (); m_Health = GetComponent <Health> (); m_Sprite = GetComponentInChildren <SpriteRenderer> (); m_InitialColor = m_Sprite.color; }
private Mock <IShip>[] ReplaceShipsWithMocks() { var shipMocks = new Mock <IShip> [_internalDictionary.Count]; for (var index = 0; index < ShipKind.All.Length; index++) { ShipKind shipKind = ShipKind.All[index]; shipMocks[index] = new ShipBuilder(shipKind).WithSquares().BuildMock(); _internalDictionary[shipKind] = shipMocks[index].Object; } return(shipMocks); }
void Start () { if (instance!=null) { Destroy (gameObject, 0f); return; } instance = this; DontDestroyOnLoad(transform.gameObject); print("Test"); int i=0; foreach (Upgrade u in upgrades) { u.uniqueID = i++; u.UpdateTooltip(); } unlockedParts = new List<int>(); i=0; foreach (ShipComponent s in wings){ s.uniqueID = i++; unlockedParts.Add (i); } foreach (ShipComponent s in engines){ s.uniqueID = i++; unlockedParts.Add (i); } foreach (ShipComponent s in weapons){ s.uniqueID = i++; unlockedParts.Add (i); } foreach (ShipComponent s in hulls){ s.uniqueID = i++; unlockedParts.Add (i); } foreach (ShipComponent s in cockpits){ s.uniqueID = i++; unlockedParts.Add (i); } boughtParts = new List<int>(); }
// Use this for initialization public virtual void Start () { builder = Camera.main.GetComponent<ShipBuilder>(); myCollider = transform.GetComponent<Collider2D>(); }
void Update() { if(!shipbuilder) shipbuilder = ShipBuilder.instance; }
// Use this for initialization void Start () { builder = Camera.main.GetComponent<ShipBuilder>(); }
// Use this for initialization void Start () { builder = Camera.main.GetComponent<ShipBuilder>(); part = transform.parent.GetComponent<ShipPart>(); connected = false; }