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);
            }));
        }
Пример #2
0
        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);
        }
Пример #3
0
        public UnitModel()
        {
            Position            = new HexGridCoordinate();
            Vectors             = RawHexVector.Zero;
            _attachedShellstars = new List <IShellstarModel>();

            _hexVectorUtility  = ServiceFactory.Library.HexVectorUtility;
            _hexGridCalculator = ServiceFactory.Library.HexGridCalculator;
        }
Пример #4
0
        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));
        }
Пример #5
0
        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);
        }
Пример #6
0
        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);
        }
Пример #7
0
        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);
        }
Пример #8
0
        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);
        }
Пример #9
0
        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));
        }
Пример #10
0
 public void AddUnit()
 {
     _newUnit.Position = HexGridCoordinate.Parse(Position);
     _unitListModel.AddUnit(_newUnit);
 }
Пример #11
0
 public void CheckDistance4()
 {
     CheckDistance(HexGridCoordinate.Parse("2 5:3"), HexGridCoordinate.Parse("2 5:3"),
                   0, AvidRing.Undefined, AvidDirection.Undefined, true);
 }
Пример #12
0
 public void CheckDistance3()
 {
     CheckDistance(HexGridCoordinate.Parse("2 5:6"), HexGridCoordinate.Parse("6 3:2"),
                   5, AvidRing.Blue, AvidDirection.B, false);
 }
Пример #13
0
 public void CheckDistance2()
 {
     CheckDistance(HexGridCoordinate.Parse("2 5:7"), HexGridCoordinate.Parse("2 5:-3"),
                   10, AvidRing.Magenta, AvidDirection.Undefined, false);
 }
Пример #14
0
 public void CheckDistance1()
 {
     CheckDistance(HexGridCoordinate.Parse("3 3"), HexGridCoordinate.Parse("1 3"),
                   2, AvidRing.Ember, AvidDirection.EF, true);
 }
Пример #15
0
 public void CheckCoordinateParsing4()
 {
     CheckCoord(HexGridCoordinate.Parse("0 4:3"), 0, 4, 3, 4);
 }
Пример #16
0
 public void CheckCoordinateParsing3()
 {
     CheckCoord(HexGridCoordinate.Parse("1 3:-3"), 1, 3, -3, 2);
 }
Пример #17
0
 public void Move(HexGridCoordinate position, HexAxis direction, uint distance)
 {
     position.AddComponent(new HexVectorComponent(direction, (int)distance));
     _hexVectorUtility.ConsolidateVector(position);
     EliminateBeComponent(position);
 }
Пример #18
0
 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));
 }
Пример #19
0
 public void CheckCoordinateParsing1()
 {
     CheckCoord(HexGridCoordinate.Parse("-2 1:0"), -2, 1, 0, 2);
 }
Пример #20
0
 public void CheckDistance5()
 {
     CheckDistance(HexGridCoordinate.Parse("-2 5:1"), HexGridCoordinate.Parse("3 4:11"),
                   11, AvidRing.Green, AvidDirection.B, true);
 }
Пример #21
0
 public HexGridCoordinate GetMapPosition(HexGridCoordinate targetPosition, TurnData turnData)
 {
     throw new NotImplementedException();
 }
Пример #22
0
 public void CheckCoordinateParsing2()
 {
     CheckCoord(HexGridCoordinate.Parse("3 1:0"), 3, 1, 0, -1);
 }