コード例 #1
0
        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
        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);
        }
コード例 #3
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));
        }
コード例 #4
0
 public void AddUnit()
 {
     _newUnit.Position = HexGridCoordinate.Parse(Position);
     _unitListModel.AddUnit(_newUnit);
 }
コード例 #5
0
 public void CheckDistance4()
 {
     CheckDistance(HexGridCoordinate.Parse("2 5:3"), HexGridCoordinate.Parse("2 5:3"),
                   0, AvidRing.Undefined, AvidDirection.Undefined, true);
 }
コード例 #6
0
 public void CheckDistance3()
 {
     CheckDistance(HexGridCoordinate.Parse("2 5:6"), HexGridCoordinate.Parse("6 3:2"),
                   5, AvidRing.Blue, AvidDirection.B, false);
 }
コード例 #7
0
 public void CheckDistance2()
 {
     CheckDistance(HexGridCoordinate.Parse("2 5:7"), HexGridCoordinate.Parse("2 5:-3"),
                   10, AvidRing.Magenta, AvidDirection.Undefined, false);
 }
コード例 #8
0
 public void CheckDistance1()
 {
     CheckDistance(HexGridCoordinate.Parse("3 3"), HexGridCoordinate.Parse("1 3"),
                   2, AvidRing.Ember, AvidDirection.EF, true);
 }
コード例 #9
0
 public void CheckCoordinateParsing4()
 {
     CheckCoord(HexGridCoordinate.Parse("0 4:3"), 0, 4, 3, 4);
 }
コード例 #10
0
 public void CheckCoordinateParsing3()
 {
     CheckCoord(HexGridCoordinate.Parse("1 3:-3"), 1, 3, -3, 2);
 }
コード例 #11
0
 public void CheckCoordinateParsing2()
 {
     CheckCoord(HexGridCoordinate.Parse("3 1:0"), 3, 1, 0, -1);
 }
コード例 #12
0
 public void CheckCoordinateParsing1()
 {
     CheckCoord(HexGridCoordinate.Parse("-2 1:0"), -2, 1, 0, 2);
 }
コード例 #13
0
 public void CheckDistance5()
 {
     CheckDistance(HexGridCoordinate.Parse("-2 5:1"), HexGridCoordinate.Parse("3 4:11"),
                   11, AvidRing.Green, AvidDirection.B, true);
 }