protected override void CalculateFields()
        {
            float PRECISION = 0.000008f;

            Distance = float.MaxValue;
            Vector3 vectorFacing = ThisShip.GetFrontFacing();

            InArc = false;

            parallelPointsList = new List <List <Vector3> >();

            foreach (var objThis in ThisShip.GetStandFrontPoins())
            {
                foreach (var objAnother in AnotherShip.GetStandPoints())
                {
                    Vector3 vectorToTarget = objAnother.Value - objThis.Value;
                    float   angle          = Mathf.Abs(Vector3.Angle(vectorToTarget, vectorFacing));

                    if (angle <= 40f)
                    {
                        InArc = true;

                        float distance = Vector3.Distance(objThis.Value, objAnother.Value);
                        if (distance < Distance - PRECISION)
                        {
                            parallelPointsList = new List <List <Vector3> >();

                            Distance = distance;

                            ThisShipNearestPoint    = objThis.Value;
                            AnotherShipNearestPoint = objAnother.Value;

                            parallelPointsList.Add(new List <Vector3>()
                            {
                                objThis.Value, objAnother.Value
                            });
                        }
                        else if (Mathf.Abs(Distance - distance) < PRECISION)
                        {
                            parallelPointsList.Add(new List <Vector3>()
                            {
                                objThis.Value, objAnother.Value
                            });
                        }
                    }
                }
            }
        }
Esempio n. 2
0
        protected override void CalculateFields()
        {
            float PRECISION = 0.000008f;

            Distance = float.MaxValue;
            Vector3 vectorFacing = ThisShip.GetFrontFacing();

            InArc = false;

            parallelPointsList = new List <List <Vector3> >();

            // TODO: another types of primaty arcs
            Dictionary <string, Vector3> shootingPoints = (ThisShip.GetAllWeapons().Count(n => n.CanShootOutsideArc) == 0) ? ThisShip.ArcInfo.GetArcsPoints() : ThisShip.ShipBase.GetStandPoints();

            // TODO: change to use geometry instead of dots

            float distance = float.MaxValue;

            foreach (var pointThis in shootingPoints)
            {
                foreach (var pointAnother in AnotherShip.ShipBase.GetStandPoints())
                {
                    // TODO: check this part
                    Vector3 vectorToTarget = pointAnother.Value - pointThis.Value;
                    float   angle          = Vector3.SignedAngle(vectorToTarget, vectorFacing, Vector3.up);

                    // TODO: Different checks for primary arc and 360 arc

                    if (ChosenWeapon.CanShootOutsideArc || ChosenWeapon.Host.ArcInfo.InAttackAngle(pointThis.Key, angle))
                    {
                        InShotAngle = true;

                        if (ChosenWeapon.Host.ArcInfo.InArc(pointThis.Key, angle))
                        {
                            InArc = true;
                        }

                        if (ChosenWeapon.Host.ArcInfo.InPrimaryArc(pointThis.Key, angle))
                        {
                            InPrimaryArc = true;
                        }

                        if (ChosenWeapon.Host.ArcInfo.InBullseyeArc(pointThis.Key, angle))
                        {
                            InBullseyeArc = true;
                        }

                        if (ChosenWeapon.Host.ArcInfo.InMobileArc(pointThis.Key, angle))
                        {
                            InMobileArc = true;
                        }

                        if (ChosenWeapon.Host.ArcInfo.InRearAuxArc(pointThis.Key, angle))
                        {
                            InRearAuxArc = true;
                        }

                        if (ChosenWeapon.Host.ArcInfo.CanShootPrimaryWeapon(pointThis.Key, angle))
                        {
                            CanShootPrimaryWeapon = true;
                        }

                        if (ChosenWeapon.Host.ArcInfo.CanShootTorpedoes(pointThis.Key, angle))
                        {
                            CanShootTorpedoes = true;
                        }

                        if (ChosenWeapon.Host.ArcInfo.CanShootMissiles(pointThis.Key, angle))
                        {
                            CanShootMissiles = true;
                        }

                        if (ChosenWeapon.Host.ArcInfo.CanShootCannon(pointThis.Key, angle))
                        {
                            CanShootCannon = true;
                        }

                        if (ChosenWeapon.Host.ArcInfo.CanShootTurret(pointThis.Key, angle))
                        {
                            CanShootTurret = true;
                        }

                        distance = Vector3.Distance(pointThis.Value, pointAnother.Value);
                        if (distance < Distance - PRECISION)
                        {
                            parallelPointsList = new List <List <Vector3> >();

                            Distance = distance;

                            ThisShipNearestPoint    = pointThis.Value;
                            AnotherShipNearestPoint = pointAnother.Value;

                            parallelPointsList.Add(new List <Vector3>()
                            {
                                pointThis.Value, pointAnother.Value
                            });
                        }
                        else if (Mathf.Abs(Distance - distance) < PRECISION)
                        {
                            parallelPointsList.Add(new List <Vector3>()
                            {
                                pointThis.Value, pointAnother.Value
                            });
                        }
                    }
                }
            }
        }
Esempio n. 3
0
 protected virtual void CalculateFields()
 {
     CalculateFieldUsingPoints(ThisShip.GetStandPoints(), AnotherShip.GetStandPoints());
 }
Esempio n. 4
0
 protected override void CalculateFields()
 {
     CalculateFieldUsingPoints(ThisShip.GetStandFrontEdgePoins(), AnotherShip.GetStandPoints());
 }
        protected override void CalculateFields()
        {
            float PRECISION = 0.000008f;

            Distance = float.MaxValue;
            Vector3 vectorFacing = ThisShip.GetFrontFacing();

            InArc = false;

            parallelPointsList = new List <List <Vector3> >();

            // TODO: another types of primaty arcs
            Dictionary <string, Vector3> shootingPoints = (!ChosenWeapon.CanShootOutsideArc) ? ThisShip.GetStandFrontPoints() : ThisShip.GetStandPoints();

            // TODO: change to use geometry insted of dots
            foreach (var objThis in shootingPoints)
            {
                foreach (var objAnother in AnotherShip.GetStandPoints())
                {
                    // TODO: check this part
                    Vector3 vectorToTarget = objAnother.Value - objThis.Value;
                    float   angle          = Mathf.Abs(Vector3.SignedAngle(vectorToTarget, vectorFacing, Vector3.up));

                    if (ChosenWeapon.CanShootOutsideArc || ChosenWeapon.Host.ArcInfo.InAttackAngle(angle))
                    {
                        InShotAngle = true;

                        if (ChosenWeapon.Host.ArcInfo.InArc(angle))
                        {
                            InArc = true;
                        }

                        if (ChosenWeapon.Host.ArcInfo.InPrimaryArc(angle))
                        {
                            InPrimaryArc = true;
                        }

                        float distance = Vector3.Distance(objThis.Value, objAnother.Value);
                        if (distance < Distance - PRECISION)
                        {
                            parallelPointsList = new List <List <Vector3> >();

                            Distance = distance;

                            ThisShipNearestPoint    = objThis.Value;
                            AnotherShipNearestPoint = objAnother.Value;

                            parallelPointsList.Add(new List <Vector3>()
                            {
                                objThis.Value, objAnother.Value
                            });
                        }
                        else if (Mathf.Abs(Distance - distance) < PRECISION)
                        {
                            parallelPointsList.Add(new List <Vector3>()
                            {
                                objThis.Value, objAnother.Value
                            });
                        }
                    }
                }
            }

            if (DebugManager.DebugArcsAndDistance)
            {
                Debug.Log("InShotAngle: " + InShotAngle);
                Debug.Log("InArc: " + InArc);
                Debug.Log("InPrimaryArc: " + InPrimaryArc);
                Debug.Log("Range: " + Range);
            }
        }