Map2AStar.cs

(开头部分) 3KB

这里只显示每个文件的开头 60 行。登录后可以解锁完整代码。

using System;
using System.Drawing;
using System.Threading;

namespace GemTD {
    class Map2AStar {
        static int rowSize = 37;
        static int colSize = 37;

        bool[,] map = new bool[rowSize, colSize];   // 是否可通过
        bool passable = true;                       // 计算过程中是否出现路被堵死的情况
        int totalDistance = 0;                      // 6条路的总距离
        int finishNum = 0;                          // 完成的线程数

        Point p0 = new Point(1, 4);
        Point p1 = new Point(18, 4);
        Point p2 = new Point(18, 32);
        Point p3 = new Point(4, 32);
        Point p4 = new Point(4, 18);
        Point p5 = new Point(32, 18);
        Point p6 = new Point(32, 32);

        public Map2AStar(Map.MapInfo[,] mapInfos)
        {
            for (int i = 0; i < rowSize; i++) {
                for (int j = 0; j < colSize; j++) {
                    map[i, j] = mapInfos[i, j].realTimeGem.passable;
                }
            }
        }

        private void AStarThread(bool[,] map, int rowSize, int colSize, Point start, Point end)
        {
            AStarInfo info = new AStarInfo(map, rowSize, colSize, start, end);
            Thread thread = new Thread(AStarExec);
            thread.Start(info);
        }

        private int AStarWait()
        {
            int distance;

            while (true) {
                if (!passable) {
                    distance = int.MaxValue;
                    break;
                }

                if (finishNum == 6) {
                    distance = totalDistance;
                    break;
                }
            }

            return distance;
        }

        // 起6个线程分别计算0-1 1-2 2-3 3-4 4-5 5-6的距离
        public int AStarStart()
        {
后面还有 44 行代码,解锁后查看完整代码

24 小时内免费解锁 3 个项目,之后 1 积分/个。 规则说明

AI 解读

登录后可用,每次 10 积分,解读结果公开显示在下面。

还没有人解读过这个文件。