private static void CreateLoadSitRepMappings() { Mapper.CreateMap <HexVectorComponentSto, HexVectorComponent>() .ForMember(hvc => hvc.Direction, ac => ac.MapFrom(vcs => Enum.Parse(typeof(HexAxis), vcs.Direction))) .ForMember(hvc => hvc.Magnitude, ac => ac.MapFrom(vcs => vcs.Value)); Mapper.CreateMap <HexVectorSto, RawHexVector>() .ForMember(hvc => hvc.Components, ac => ac.Ignore()) .AfterMap((hvs, rhv) => rhv.AddComponents(Mapper.Map <IEnumerable <HexVectorComponentSto>, IEnumerable <HexVectorComponent> >(hvs.Components))); Mapper.CreateMap <ImpulseRecordSto, ImpulseTrackElement>() .ForMember(ite => ite.Impulse, ac => ac.MapFrom(irs => TurnData.Parse(irs.Impulse))); Mapper.CreateMap <ShellstarSto, ShellstarInfo>(); Mapper.CreateMap <UnitSto, UnitModel>() .ForMember(um => um.Position, ac => ac.MapFrom(uns => HexGridCoordinate.Parse(uns.Position))) .ForMember(um => um.Vectors, ac => ac.MapFrom(uns => uns.Velocity)) .AfterMap((uns, um) => uns.IncomingProjectiles.ForEach(st => { var evasionInfo = new EvasionInfoModel(AvidWindow.Parse(st.EvasionInfo.ImpactWindow), AvidWindow.Parse(st.EvasionInfo.EvasionUp).Direction); var shellstarModel = new ShellstarModel(Mapper.Map <ShellstarSto, ShellstarInfo>(st), TurnData.Parse(st.SegmentOfLaunch), evasionInfo); shellstarModel.Tag = st.Tag; um.AttachShellstar(shellstarModel); })); }
private void CheckDistance(HexGridCoordinate posA, HexGridCoordinate posB, int distance, AvidRing ring, AvidDirection direction, bool isAbovePlane) { var result = _calculator.GetDistance(posA, posB); result.Magnitude.Should().Be(distance); result.Ring.Should().Be(ring); result.Direction.Should().Be(direction); result.AbovePlane.Should().Be(isAbovePlane); }
public UnitModel() { Position = new HexGridCoordinate(); Vectors = RawHexVector.Zero; _attachedShellstars = new List <IShellstarModel>(); _hexVectorUtility = ServiceFactory.Library.HexVectorUtility; _hexGridCalculator = ServiceFactory.Library.HexGridCalculator; }
private void CheckVectorComponent(HexGridCoordinate testCoordinate, int expectedMagnitude, HexAxis positiveAxis, HexAxis negativeAxis) { if (expectedMagnitude == 0) { return; } testCoordinate.Components.Should().ContainSingle(hvc => hvc.Magnitude == Math.Abs(expectedMagnitude) && hvc.Direction == (expectedMagnitude < 0 ? negativeAxis : positiveAxis)); }
private void CheckCoord(HexGridCoordinate testCoordinate, int cfCoord, int daCoord, int altitude, int daVectorMagnitude) { testCoordinate.CfCoordinate.Should().Be(cfCoord); testCoordinate.DaCoordinate.Should().Be(daCoord); testCoordinate.Altitude.Should().Be(altitude); //Checking vector components CheckVectorComponent(testCoordinate, cfCoord, HexAxis.C, HexAxis.F); CheckVectorComponent(testCoordinate, daVectorMagnitude, HexAxis.D, HexAxis.A); CheckVectorComponent(testCoordinate, altitude, HexAxis.Up, HexAxis.Down); }
private void CheckMovement(int initialCf, int initialDa, int initialAlt, HexAxis moveAxis, uint moveMagnitude, int finalCf, int finalDa, int finalAlt, int finalDaValue) { var coordinate = new HexGridCoordinate { CfCoordinate = initialCf, DaCoordinate = initialDa, Altitude = initialAlt }; _calculator.Move(coordinate, moveAxis, moveMagnitude); CheckCoord(coordinate, finalCf, finalDa, finalAlt, finalDaValue); }
private void EliminateBeComponent(HexGridCoordinate position) { int beMagnitude = _hexVectorUtility.GetMagnitudeAlongCardinalDirection(position, HexAxis.B); if (beMagnitude == 0) { return; } position.CfCoordinate = position.CfCoordinate + beMagnitude; position.DaCoordinate = position.DaCoordinate - beMagnitude; _hexVectorUtility.EliminateComponentsAlongCardinalDirection(position, HexAxis.B); }
public void Initialize(object dataContext) { _newUnit = new UnitModel(); if (!string.IsNullOrEmpty(_configurationController.StartingUnitPosition)) { _newUnit.Position = HexGridCoordinate.Parse(_configurationController.StartingUnitPosition); } Position = _newUnit.Position.ToString(); OnPropertyChanged(Properties.UnitName); OnPropertyChanged(Properties.Position); OnPropertyChanged(Properties.NoErrors); OnPropertyChanged(Properties.Configured); }
public override ValidationResult Validate(object value, CultureInfo cultureInfo) { var coordinateString = value as string; if (string.IsNullOrEmpty(coordinateString)) { return(new ValidationResult(false, "Coordinates cannot be empty.")); } try { HexGridCoordinate.Parse(coordinateString); } catch (Exception) { return(new ValidationResult(false, "Coordinates must follow <CF> <DA>:<Altitude> format.")); } return(new ValidationResult(true, null)); }
public void AddUnit() { _newUnit.Position = HexGridCoordinate.Parse(Position); _unitListModel.AddUnit(_newUnit); }
public void CheckDistance4() { CheckDistance(HexGridCoordinate.Parse("2 5:3"), HexGridCoordinate.Parse("2 5:3"), 0, AvidRing.Undefined, AvidDirection.Undefined, true); }
public void CheckDistance3() { CheckDistance(HexGridCoordinate.Parse("2 5:6"), HexGridCoordinate.Parse("6 3:2"), 5, AvidRing.Blue, AvidDirection.B, false); }
public void CheckDistance2() { CheckDistance(HexGridCoordinate.Parse("2 5:7"), HexGridCoordinate.Parse("2 5:-3"), 10, AvidRing.Magenta, AvidDirection.Undefined, false); }
public void CheckDistance1() { CheckDistance(HexGridCoordinate.Parse("3 3"), HexGridCoordinate.Parse("1 3"), 2, AvidRing.Ember, AvidDirection.EF, true); }
public void CheckCoordinateParsing4() { CheckCoord(HexGridCoordinate.Parse("0 4:3"), 0, 4, 3, 4); }
public void CheckCoordinateParsing3() { CheckCoord(HexGridCoordinate.Parse("1 3:-3"), 1, 3, -3, 2); }
public void Move(HexGridCoordinate position, HexAxis direction, uint distance) { position.AddComponent(new HexVectorComponent(direction, (int)distance)); _hexVectorUtility.ConsolidateVector(position); EliminateBeComponent(position); }
public AvidVector GetDistance(HexGridCoordinate from, HexGridCoordinate to) { // Distance between objects on hex grid is the projection of relative positions // when these positions are expressed as hex grid vectors. return(GetRelativeVectorProjection(from, to)); }
public void CheckCoordinateParsing1() { CheckCoord(HexGridCoordinate.Parse("-2 1:0"), -2, 1, 0, 2); }
public void CheckDistance5() { CheckDistance(HexGridCoordinate.Parse("-2 5:1"), HexGridCoordinate.Parse("3 4:11"), 11, AvidRing.Green, AvidDirection.B, true); }
public HexGridCoordinate GetMapPosition(HexGridCoordinate targetPosition, TurnData turnData) { throw new NotImplementedException(); }
public void CheckCoordinateParsing2() { CheckCoord(HexGridCoordinate.Parse("3 1:0"), 3, 1, 0, -1); }