Пример #1
0
        /// <Summary>
        /// Provides a list of objects within a certain distance from a position,
        /// ordered by distance.
        ///
        /// Copied from StarMap.cs (should probably make this a utility)
        /// </Summary>
        /// <param name="position">Starting Point for the search.</param>
        /// <returns>A list of Fleet and Star objects.</returns>
        private List <Mappable> FindNearObjects(NovaPoint position)
        {
            List <Mappable> nearObjects = new List <Mappable>();

            foreach (FleetIntel report in clientData.EmpireState.FleetReports.Values)
            {
                if (!report.IsStarbase)
                {
                    if (PointUtilities.IsNear(report.Position, position))
                    {
                        nearObjects.Add(report);
                    }
                }
            }

            foreach (StarIntel report in clientData.EmpireState.StarReports.Values)
            {
                if (PointUtilities.IsNear(report.Position, position))
                {
                    nearObjects.Add(report);
                }
            }

            // nearObjects.Sort(ItemSorter);
            return(nearObjects);
        }
Пример #2
0
        public void TestIsNearDoesNotChangeParams()
        {
            NovaPoint a = new NovaPoint(1, 2);
            NovaPoint b = new NovaPoint(3, 4);

            bool testNear = PointUtilities.IsNear(a, b);

            Assert.IsTrue(a.X == 1);
            Assert.IsTrue(a.Y == 2);
            Assert.IsTrue(b.X == 3);
            Assert.IsTrue(b.Y == 4);
        }