コード例 #1
0
        private void ComputeRoute(object sender, EventArgs args)
        {
            int jumpsPerLeg = 4;
            int maxJumps    = 6;

            var jumpDistance = FloatHelper.AsFloat(MaxJumpDistance.Text);

            if (Math.Abs(jumpDistance) < 0.0000001f)
            {
                MessageBox.Show("Please enter a valid floating point jump distance.", "F**k!", MessageBoxButtons.OK);
                return;
            }

            var idealSellDistance = FloatHelper.AsFloat(IdealSellDistance.Text);

            if (Math.Abs(idealSellDistance) < 0.0000001f)
            {
                MessageBox.Show("Please enter a valid floating point jump distance.", "F**k!", MessageBoxButtons.OK);
                return;
            }

            try
            {
                jumpsPerLeg = Convert.ToInt32(JumpsPerLeg.Text);
            }
            catch
            {
                MessageBox.Show("Please enter a valid number of legs per jump.", "F**k!", MessageBoxButtons.OK);
                return;
            }
            try
            {
                maxJumps = Convert.ToInt32(MaxJumps.Text);
            }
            catch
            {
                MessageBox.Show("Please enter a valid number of max jumps.", "F**k!", MessageBoxButtons.OK);
                return;
            }
            if (!ValidateComboBox(CurrentSystem))
            {
                return;
            }

            RoutePlanner planner = new RoutePlanner(availableRares.Values.ToList(), jumpDistance);
            StarSystem   start   = galaxy.Systems[CurrentSystem.Text];

            currentRoute = planner.FindRoute(start, idealSellDistance, jumpsPerLeg, maxJumps);
            OnRouteUpdated();
        }
コード例 #2
0
        // Compute a path from the player's current system to the selected destination system
        private void ComputePath(object sender, EventArgs e)
        {
            var jumpDistance = FloatHelper.AsFloat(MaxJumpDistance.Text);

            if (Math.Abs(jumpDistance) < 0.0000001f)
            {
                MessageBox.Show("Please enter a valid floating point jump distance.", "F**k!", MessageBoxButtons.OK);
                return;
            }

            if (!ValidateComboBox(CurrentSystem) || !ValidateComboBox(DestinationSystem))
            {
                return;
            }

            PathPlanner     finder = new PathPlanner(galaxy.Systems.Values.ToList(), jumpDistance);
            List <PathNode> path   = finder.FindPath(CurrentSystem.Text, DestinationSystem.Text);

            if (path == null)
            {
                MessageBox.Show("No route to destination.", "F**K!", MessageBoxButtons.OK);
                return;
            }

            PathResults.Items.Clear();
            float travelled = 0.0f;

            for (int i = 0; i < path.Count; i++)
            {
                PathNode n        = path[i];
                float    distance = n.TraversalCost;
                travelled += distance;
                ListViewItem newItem = new ListViewItem();
                newItem.Text = n.Local.Name;
                newItem.SubItems.Add(i.ToString());
                newItem.SubItems.Add(distance.ToString("0.00"));
                newItem.SubItems.Add(travelled.ToString("0.00"));
                newItem.SubItems.Add(n.HScore.ToString("0.00"));
                PathResults.Items.Add(newItem);
            }
            currentPath = path;
        }