/// <summary> /// Asserts state expectations against a ship segment model. /// </summary> /// <param name="segment">The actual segment.</param> /// <param name="ship">The expected ship.</param> /// <param name="isHit">The expected hit state flag.</param> /// <param name="xIndex">The expected X-index.</param> /// <param name="yIndex">The expected Y-index.</param> private static void AssertShipSegment(ShipSegment segment, Ship ship, bool isHit, int xIndex, int yIndex) { segment.Should().NotBeNull(); segment.Ship.Should().Be(ship); segment.IsHit.Should().Be(isHit); segment.XIndex.Should().Be(xIndex); segment.YIndex.Should().Be(yIndex); }
private void OnTriggerExit2D(Collider2D collision) { ShipSegment seg = collision.GetComponent <ShipSegment>(); if (seg != null) { segments.Remove(seg); seg.Ship.Movement.EndSlowEffect(data.MoveSlowAmount, data.TurningSlowAmount); if (data.PlayDamageSound) { seg.StopTerrainDamage(); } } }
void DetermineShooting() { if (shoot) { LayerMask mask = LayerMask.GetMask("ShipSegments", "Land"); RaycastHit2D hit = Physics2D.Raycast(new Vector2(shooter.ShotLocations[0].position.x, shooter.ShotLocations[0].position.y), transform.up, shotCheckRange, mask); if (hit) { ShipSegment segment = hit.collider.GetComponent <ShipSegment>(); if (segment != null && segment.tag != tag) { shooter.ShotInput(true); } } } }