private void SetupUnits(SquareArea area) { while (_unitsCountNotifier.UnitsCount < ACTIVE_UNITS_COUNT) { CreateAndInitializeUnit(area); } }
public static void CheckSelect2() { if (Choice == 1) { Console.Clear(); CircleArea.CircleAreaShape(); } else if (Choice == 2) { Console.Clear(); SquareArea.SquareAreaShape(); } else if (Choice == 3) { Console.Clear(); TrapeziumArea.Trapezium(); } else if (Choice == 8) { Console.Clear(); SelectRUS.ChangeShapeOperation(); } else { ExeptionFilter.ExeptionOutput(); SelectShapes(); } }
public void CreateSafetyAreaTest() { Coordinate landingRequest = new Coordinate(5, 5); SquareArea sa = AreasService.CreateSafetyArea(landingRequest); Assert.AreEqual(sa.Size, 3); Assert.AreEqual(sa.TopLeftCorner, new Coordinate(4, 4)); }
public void IsCoordinateInsideTest() { Coordinate landingRequest = new Coordinate(5, 5); SquareArea sa = AreasService.CreateSafetyArea(landingRequest); Assert.IsTrue(AreasService.IsCoordinateInside(sa, new Coordinate(4, 4))); Assert.IsFalse(AreasService.IsCoordinateInside(sa, new Coordinate(11, 11))); }
private EnemyController CreateUnitOnRandomPosition(SquareArea area) { var enemy = _enemyFactory.Invoke(); var position = GetFreePosition(area); enemy.SetOnPosition(position); return(enemy); }
/// <summary> /// Check if a given coordinate belong to the square are /// </summary> /// <param name="coordinate">Pair of x,y to check</param> /// <returns>true if the coordinate belongs and false otherwise</returns> public static bool IsCoordinateInside(SquareArea area, Coordinate coordinate) { Coordinate topLeftCorner = area.TopLeftCorner; int size = area.Size; return(coordinate.X >= topLeftCorner.X && coordinate.X <= topLeftCorner.X + size - 1 && coordinate.Y >= topLeftCorner.Y && coordinate.Y <= topLeftCorner.Y + size - 1); }
/// <summary> /// Overload of the constructor to allow modify the landing platform size /// Initial positions and landing area size are fixed /// </summary> /// <param name="sizeForLandingPlatform"></param> public LandingControl(int sizeForLandingPlatform) { if (sizeForLandingPlatform + LandingPlatformTopLeft > DefaultLandingAreaSize) { throw new System.Exception("[ERROR]: Landing platform must be within landing area"); } else { LandingArea = new SquareArea(new Coordinate(LandingAreaTopLeft, LandingAreaTopLeft), DefaultLandingAreaSize); LandingPlatform = new SquareArea(new Coordinate(LandingPlatformTopLeft, LandingPlatformTopLeft), sizeForLandingPlatform); } }
private IntVector2 GetFreePosition(SquareArea area) { var freePositions = _occupatedPossitionsMap.GetFreePositionsInRegion(area.TopLeft, area.BottomRight); if (freePositions.Count == 0) { ApplicationDebugger.ThrowException("ChaosBattlefield: no free positions"); } var rand = _random.Next(freePositions.Count); return(freePositions[rand]); }
void drawArea() { IArea area = gs.area; switch (area.type) { case GameArea.AreaType.circle: CircleArea cr = area as CircleArea; rectMat.SetFloat("_HalfWidth", cr.R); rectMat.SetFloat("_Ang", 360f); rectMesh.get(2 * area.R, 2 * area.R, new Vector3(0, 0.02f, 0)); rectMesh.draw(sticker.localToWorldMatrix * mLocalMX, rectMat); break; case GameArea.AreaType.Fan: FanArea fr = area as FanArea; rectMat.SetFloat("_HalfWidth", fr.R); rectMat.SetFloat("_Ang", fr.ang); rectMesh.get(2 * area.R, 2 * area.R, new Vector3(0, 0.02f, 0)); rectMesh.draw(sticker.localToWorldMatrix * mLocalMX, rectMat); break; case GameArea.AreaType.Rectangle: RectangleArea rar = area as RectangleArea; rectMat.SetFloat("_HalfWidth", rar.w / 2); rectMat.SetFloat("_HalfHeight", rar.R / 2); rectMat.SetFloat("_Ang", 0); rectMesh.get(area.R, area.R, new Vector3(0, 0.02f, rar.R / 2)); rectMesh.draw(sticker.localToWorldMatrix * mLocalMX, rectMat); break; case GameArea.AreaType.Square: SquareArea sr = area as SquareArea; rectMat.SetFloat("_HalfWidth", sr.R / 2); rectMat.SetFloat("_HalfHeight", sr.R / 2); rectMat.SetFloat("_Ang", 0); rectMesh.get(area.R, area.R, new Vector3(0, 0.02f, sr.R / 2)); rectMesh.draw(sticker.localToWorldMatrix * mLocalMX, rectMat); break; } }
/// <summary> /// Method to control the requests of landing from the rockets /// </summary> /// <param name="rocketLandingPosition">x,y pair to check</param> /// <returns type=string>ok for landing - when there is no problem to land /// out of the platform - request is outside of landing platform /// clash - the previous rocket check for the same position or the /// checked position is within the safety area of the previous /// rocket ///</returns> public string LandingRequest(Coordinate rocketLandingPosition) { string response = string.Empty; if (PreviousRocketLandingPosition != null && AreasService.IsCoordinateInside(PreviousRocketLandingPosition, rocketLandingPosition)) { response = Response.CLASH; } else if (AreasService.IsCoordinateInside(LandingPlatform, rocketLandingPosition)) { response = Response.OK_FOR_LANDING; } else { response = Response.OUT_OF_PLATFORM; } // we save the request of landing PreviousRocketLandingPosition = AreasService.CreateSafetyArea(rocketLandingPosition); return(response); }
/// <summary> /// A landing control consists on a landing area and a landing platform. /// Initial positions and sizes are fixed here /// </summary> public LandingControl() { LandingArea = new SquareArea(new Coordinate(LandingAreaTopLeft, LandingAreaTopLeft), DefaultLandingAreaSize); LandingPlatform = new SquareArea(new Coordinate(LandingPlatformTopLeft, LandingPlatformTopLeft), DefaultLandingPlatformSize); }
public void Activate() { _area = new SquareArea(TOP_LEFT, BOTTOM_RIGHT); SetupUnits(_area); }
private void InitializeUnit(EnemyController unit, SquareArea area) { var chaosUnitController = new ChaosUnitController(unit, _unitsCountNotifier, _occupatedPossitionsMap, _unitNameResolver, area); }
private void CreateAndInitializeUnit(SquareArea area) { var unit = CreateUnitOnRandomPosition(area); InitializeUnit(unit, area); }