Пример #1
0
        private void CheckRange()
        {
            InArcInfo = new Dictionary <GenericArc, bool>();
            List <ArcTypes> WeaponArcRestrictions = (Weapon is GenericSecondaryWeapon) ? (Weapon as GenericSecondaryWeapon).ArcRestrictions : null;

            if (WeaponArcRestrictions != null && WeaponArcRestrictions.Count == 0)
            {
                WeaponArcRestrictions = null;
            }

            WeaponTypes weaponType = (Weapon is GenericSecondaryWeapon) ? (Weapon as GenericSecondaryWeapon).WeaponType : WeaponTypes.PrimaryWeapon;

            foreach (var arc in Ship1.ArcInfo.Arcs)
            {
                ShotInfoArc shotInfoArc = new ShotInfoArc(Ship1, Ship2, arc);
                InArcInfo.Add(arc, shotInfoArc.InArc);

                if (!arc.ShotPermissions.CanShootByWeaponType(weaponType))
                {
                    continue;
                }

                if (WeaponArcRestrictions != null && !WeaponArcRestrictions.Contains(arc.ArcType))
                {
                    continue;
                }

                if (shotInfoArc.IsShotAvailable)
                {
                    if (IsShotAvailable == false)
                    {
                        MinDistance = shotInfoArc.MinDistance;
                    }
                    else
                    {
                        if (shotInfoArc.MinDistance.DistanceReal < MinDistance.DistanceReal)
                        {
                            MinDistance = shotInfoArc.MinDistance;
                        }
                    }

                    IsShotAvailable = true;

                    if (!(arc is ArcBullseye))
                    {
                        ShotAvailableFromArcs.Add(arc);
                    }
                }

                if (NearestFailedDistance == null)
                {
                    NearestFailedDistance = shotInfoArc.MinDistance;
                }
                else if (shotInfoArc.MinDistance.DistanceReal < NearestFailedDistance.DistanceReal)
                {
                    NearestFailedDistance = shotInfoArc.MinDistance;
                }
            }
        }
Пример #2
0
        private void CheckRange()
        {
            InArcInfo = new Dictionary <ArcTypes, bool>();

            foreach (var arc in Ship1.ArcInfo.Arcs)
            {
                ShotInfoArc shotInfoArc = new ShotInfoArc(Ship1, Ship2, arc);
                InArcInfo.Add(arc.ArcType, shotInfoArc.InArc);

                WeaponTypes weaponType = (Weapon is GenericSecondaryWeapon) ? (Weapon as GenericSecondaryWeapon).WeaponType : WeaponTypes.PrimaryWeapon;

                if (arc.ShotPermissions.CanShootByWeaponType(weaponType))
                {
                    if (shotInfoArc.IsShotAvailable)
                    {
                        if (IsShotAvailable == false)
                        {
                            MinDistance = shotInfoArc.MinDistance;
                        }
                        else
                        {
                            if (shotInfoArc.MinDistance.DistanceReal < MinDistance.DistanceReal)
                            {
                                MinDistance = shotInfoArc.MinDistance;
                            }
                        }

                        IsShotAvailable = true;
                    }

                    if (NearestFailedDistance == null)
                    {
                        NearestFailedDistance = shotInfoArc.MinDistance;
                    }
                    else if (shotInfoArc.MinDistance.DistanceReal < NearestFailedDistance.DistanceReal)
                    {
                        NearestFailedDistance = shotInfoArc.MinDistance;
                    }
                }
            }
        }
Пример #3
0
        private void CheckRange()
        {
            InArcInfo    = new Dictionary <GenericArc, bool>();
            InSectorInfo = new Dictionary <GenericArc, bool>();

            List <ArcType> WeaponArcRestrictions = new List <ArcType>(Weapon.WeaponInfo.ArcRestrictions);

            if (WeaponArcRestrictions.Contains(ArcType.DoubleTurret))
            {
                WeaponArcRestrictions.RemoveAll(a => a == ArcType.DoubleTurret);
                WeaponArcRestrictions.Add(ArcType.SingleTurret);
            }

            foreach (var arc in Ship1.ArcsInfo.Arcs)
            {
                ShotInfoArc shotInfoArc = new ShotInfoArc(Ship1, Ship2, arc);
                InArcInfo.Add(arc, shotInfoArc.InArc);
            }

            List <GenericArc> sectorsAndTurrets = new List <GenericArc>();

            sectorsAndTurrets.AddRange(Ship1.SectorsInfo.Arcs);
            sectorsAndTurrets.AddRange(Ship1.ArcsInfo.Arcs.Where(a => a.ArcType == ArcType.SingleTurret));
            foreach (var arc in sectorsAndTurrets)
            {
                ShotInfoArc shotInfoArc = new ShotInfoArc(Ship1, Ship2, arc);
                InSectorInfo.Add(arc, shotInfoArc.InArc);

                if (WeaponArcRestrictions.Count > 0 && !WeaponArcRestrictions.Contains(arc.ArcType))
                {
                    continue;
                }

                if (shotInfoArc.IsShotAvailable)
                {
                    if (IsShotAvailable == false)
                    {
                        MinDistance = shotInfoArc.MinDistance;
                    }
                    else
                    {
                        if (shotInfoArc.MinDistance.DistanceReal < MinDistance.DistanceReal)
                        {
                            MinDistance = shotInfoArc.MinDistance;
                        }
                    }

                    IsShotAvailable = true;

                    if (!(arc is ArcBullseye))
                    {
                        ShotAvailableFromArcs.Add(arc);
                    }
                }

                if (NearestFailedDistance == null)
                {
                    NearestFailedDistance = shotInfoArc.MinDistance;
                }
                else if (shotInfoArc.MinDistance.DistanceReal < NearestFailedDistance.DistanceReal)
                {
                    NearestFailedDistance = shotInfoArc.MinDistance;
                }
            }

            // For 360 arcs
            if (Weapon.WeaponInfo.CanShootOutsideArc)
            {
                DistanceInfo distInfo = new DistanceInfo(Ship1, Ship2);

                if (distInfo.Range < 4)
                {
                    MinDistance     = distInfo.MinDistance;
                    IsShotAvailable = true;
                }
                else
                {
                    NearestFailedDistance = distInfo.MinDistance;
                }
            }
        }
Пример #4
0
        private void CheckRange()
        {
            InArcInfo    = new Dictionary <GenericArc, bool>();
            InSectorInfo = new Dictionary <GenericArc, bool>();

            foreach (var arc in Ship1.ArcsInfo.Arcs)
            {
                ShotInfoArc shotInfoArc = new ShotInfoArc(Ship1, Ship2, arc);
                InArcInfo.Add(arc, shotInfoArc.InArc);
            }

            List <GenericArc> sectorsAndTurrets = new List <GenericArc>();

            sectorsAndTurrets.AddRange(Ship1.SectorsInfo.Arcs);
            sectorsAndTurrets.AddRange(Ship1.ArcsInfo.Arcs.Where(a => a.ArcType == ArcType.SingleTurret));
            foreach (var arc in sectorsAndTurrets)
            {
                ShotInfoArc shotInfoArc = new ShotInfoArc(Ship1, Ship2, arc, Weapon);
                InSectorInfo.Add(arc, shotInfoArc.InArc);

                if (Weapon.WeaponInfo.ArcRestrictions.Count > 0 && !Weapon.WeaponInfo.ArcRestrictions.Contains(arc.ArcType))
                {
                    continue;
                }

                bool result = shotInfoArc.IsShotAvailable;
                if (arc.ArcType == ArcType.Bullseye)
                {
                    Ship1.CallOnBullseyeArcCheck(Ship2, ref result);
                }

                if (result)
                {
                    if (IsShotAvailable == false)
                    {
                        MinDistance             = shotInfoArc.MinDistance;
                        ObstructedByShips       = shotInfoArc.ObstructedByShips;
                        ObstructedByObstacles   = shotInfoArc.ObstructedByObstacles;
                        IsObstructedByBombToken = shotInfoArc.IsObstructedByBombToken;
                    }
                    else
                    {
                        if (shotInfoArc.MinDistance.DistanceReal < MinDistance.DistanceReal)
                        {
                            MinDistance             = shotInfoArc.MinDistance;
                            ObstructedByShips       = shotInfoArc.ObstructedByShips;
                            ObstructedByObstacles   = shotInfoArc.ObstructedByObstacles;
                            IsObstructedByBombToken = shotInfoArc.IsObstructedByBombToken;
                        }
                    }

                    IsShotAvailable = true;

                    if (!(arc is ArcBullseye) ||
                        (Weapon.WeaponInfo.ArcRestrictions.Count > 0 && Weapon.WeaponInfo.ArcRestrictions.Contains(ArcType.Bullseye)))
                    {
                        ShotAvailableFromArcs.Add(arc);
                    }
                }

                if (NearestFailedDistance == null)
                {
                    NearestFailedDistance = shotInfoArc.MinDistance;
                }
                else if (shotInfoArc.MinDistance.DistanceReal < NearestFailedDistance.DistanceReal)
                {
                    NearestFailedDistance = shotInfoArc.MinDistance;
                }
            }

            // For 360 arcs
            if (Weapon.WeaponInfo.CanShootOutsideArc)
            {
                DistanceInfo distInfo = new DistanceInfo(Ship1, Ship2);

                if (distInfo.Range < 4)
                {
                    MinDistance = distInfo.MinDistance;
                    //TODO: Obstructed shots for 360 arcs
                    IsShotAvailable = true;
                }
                else
                {
                    NearestFailedDistance = distInfo.MinDistance;
                }
            }

            /*Debug.Log("Check results:");
             * if (IsShotAvailable)
             * {
             *  foreach (var item in ObstructedByShips)
             *  {
             *      Debug.Log("Obstructed by " + item.PilotInfo.PilotName);
             *  }
             *  foreach (var item in ObstructedByObstacles)
             *  {
             *      Debug.Log("Obstructed by " + item.Name);
             *  }
             * }*/
        }