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 }); } } } } }
protected virtual void CalculateFields() { CalculateFieldUsingPoints(ThisShip.GetStandPoints(), AnotherShip.GetStandPoints()); }
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); } }