Exemplo n.º 1
0
 private void UpdateFiringSolution(FiringSolution firingSolution, MissileAccelerationData missileAccelerationData, IShellstarModel shellstar)
 {
     FiringSolution   = firingSolution;
     AccelerationData = missileAccelerationData;
     Shellstar        = shellstar;
     LaunchWindows    = GetAvailableLaunchWindows();
     OnFiringSolutionUpdated();
 }
Exemplo n.º 2
0
 private void LaunchBoardModelOnFiringSolutionUpdated()
 {
     _accelerationData = _launchBoardModel.AccelerationData;
     OnPropertyChanged(Properties.DataAvailable);
     OnPropertyChanged(Properties.TableRow);
     OnPropertyChanged(Properties.TableColumn);
     OnPropertyChanged(Properties.BurnDuration);
 }
 private void LaunchBoardModelOnFiringSolutionUpdated()
 {
     _accelerationData = _launchBoardModel.AccelerationData;
     OnPropertyChanged(Properties.IsDataAvailable);
     OnPropertyChanged(Properties.IsLaunchInvalid);
     OnPropertyChanged(Properties.RoC);
     OnPropertyChanged(Properties.BurnDuration);
     OnPropertyChanged(Properties.TotalAcceleration);
     OnPropertyChanged(Properties.MpatTotal);
     OnPropertyChanged(Properties.BurnDistance);
     OnPropertyChanged(Properties.TargetRange);
     ResetAccelerationTrack();
 }
Exemplo n.º 4
0
        private IShellstarModel BuildShellstar(FiringSolution firingSolution, MissileAccelerationData accelerationData)
        {
            if (firingSolution == null || firingSolution.AimAdjustment == AimAdjustment.NoShot ||
                (accelerationData != null && accelerationData.ValidLaunch == false))
            {
                return(null);
            }

            var shellstar = _shellstarBuilder.BuildShellstarInfo(TargetDistance.Magnitude, LaunchingSegment, firingSolution, accelerationData);
            var result    = new ShellstarModel(shellstar, LaunchingSegment)
            {
                Tag = GetDefaultTag()
            };

            return(result);
        }
        public MissileAccelerationData CalculateMissileAcceleration(int targetRange, int burnDuration, int acceleration, AimAdjustment aimAdjustment, float roc)
        {
            int   tableColumn;
            float totalPositionAdjustment = _missilePositionAdjustmentTable.GetTotalMissileAdjustment(burnDuration, acceleration, aimAdjustment, out tableColumn);

            var result = new MissileAccelerationData
            {
                TotalAcceleration       = roc * burnDuration,
                TotalPositionAdjustment = totalPositionAdjustment,
                TableColumn             = tableColumn,
                TargetRange             = targetRange,
                BurnDuration            = burnDuration,
                ValidLaunch             = true
            };

            result.BurnDistance = result.TotalAcceleration - result.TotalPositionAdjustment;
            float nextRange = targetRange - result.BurnDistance;

            if (nextRange <= 0)
            {
                result.ValidLaunch = false;
                return(result);
            }

            // Filling acceleration data per impulse.
            for (int i = 0; i < burnDuration; i++)
            {
                var currentImpulse = new MissileAccelerationImpulse
                {
                    PositionAdjustment = _missilePositionAdjustmentTable.GetSegmentMissileAdjustment(i + 1, acceleration, aimAdjustment),
                    Range = nextRange
                };

                result.ImpulseData.Add(currentImpulse);

                nextRange = nextRange + roc - currentImpulse.PositionAdjustment;
            }

            if (Math.Abs(nextRange - targetRange) > 0.3f)
            {
                throw new ArithmeticException(string.Format("After computing missile acceleration info, couldn't reach target range at launch ({0}). Final range = {1}",
                                                            targetRange, nextRange));
            }

            return(result);
        }
Exemplo n.º 6
0
        public void CalculateFiringSolution()
        {
            var firingSolution = _firingSolutionCalculator.CalculateSolution(
                CourseOffset,
                CrossingVector.Magnitude,
                WeaponSelection.MuzzleVelocityMultiplyer,
                WeaponSelection.Acceleration);

            MissileAccelerationData missileAccelerationData = null;

            if (WeaponSelection.IsMissile && firingSolution.AimAdjustment != AimAdjustment.NoShot)
            {
                missileAccelerationData = _firingSolutionCalculator.CalculateMissileAcceleration(
                    TargetDistance.Magnitude,
                    WeaponSelection.MuzzleVelocityMultiplyer,
                    WeaponSelection.Acceleration,
                    firingSolution.AimAdjustment,
                    firingSolution.RoC);
            }

            IShellstarModel shellstar = BuildShellstar(firingSolution, missileAccelerationData);

            UpdateFiringSolution(firingSolution, missileAccelerationData, shellstar);
        }
Exemplo n.º 7
0
        private void BuildAccelerationSegments(ShellstarInfo shellstarInfo, int targetDistance, MissileAccelerationData accelData)
        {
            for (int i = 0; i < accelData.BurnDuration; i++)
            {
                int range = i < accelData.BurnDuration - 1 ?
                            (int)(Math.Floor(accelData.ImpulseData[i + 1].Range)) :
                            targetDistance;

                var impulseData = new ImpulseTrackElement
                {
                    Range     = range,
                    IsBurning = true
                };
                shellstarInfo.ImpulseTrack.Add(impulseData);
            }
        }
Exemplo n.º 8
0
        public ShellstarInfo BuildShellstarInfo(int targetDistance, TurnData startingImpulse, FiringSolution firingSolution, MissileAccelerationData missileAcceleration)
        {
            if (firingSolution == null)
            {
                throw new ArgumentNullException("firingSolution", "Firing solution is needed to calculate shellstar data.");
            }

            int dmg50,
                dmg100,
                dmg200;

            _projectileDamageTable.GetDamages(firingSolution.RoC, out dmg50, out dmg100, out dmg200);

            var result = new ShellstarInfo
            {
                RoC    = firingSolution.RoC,
                Dmg50  = dmg50,
                Dmg100 = dmg100,
                Dmg200 = dmg200,
            };

            float inertialFlightDistance = (missileAcceleration != null) ?
                                           // Burnout range rounded down.
                                           (float)Math.Floor(targetDistance - missileAcceleration.BurnDistance) :
                                           targetDistance;

            BuildInertialSegments(result, inertialFlightDistance, firingSolution, missileAcceleration != null);

            if (missileAcceleration != null)
            {
                BuildAccelerationSegments(result, targetDistance, missileAcceleration);
            }

            result.ImpulseTrack.Reverse();
            AssignImpulseInformation(result, startingImpulse);

            return(result);
        }