void Awake() { typeColors = new Dictionary <PathCellMark, Color>(); //TODO: 读档,配置颜色 //TODO: 可以的话,改成遍历 typeColors.Add(PathCellMark.StartPos, types[(int)PathCellMark.StartPos]); typeColors.Add(PathCellMark.EndPos, types[(int)PathCellMark.EndPos]); typeColors.Add(PathCellMark.Normal, types[(int)PathCellMark.Normal]); typeColors.Add(PathCellMark.Block, types[(int)PathCellMark.Block]); ChangeActiveType(PathCellMark.StartPos); bfsBtn.onClick.AddListener( () => { ResetColor(false); MapManager.Instance.PathFinder.FindPath(m_StartCellId, m_EndCellId, PathFindAlg.Bfs, DrawPath); } ); aStarBtn.onClick.AddListener( () => { ResetColor(false); MapManager.Instance.PathFinder.FindPath(m_StartCellId, m_EndCellId, PathFindAlg.Astar, DrawPath); } ); beamSearchBtn.onClick.AddListener( () => { ResetColor(false); int width; if (!int.TryParse(beamWidth.text, out width)) { Debug.LogError("请输入正确数字"); } else { MapManager.Instance.PathFinder.SetBeamWidth(width); MapManager.Instance.PathFinder.FindPath(m_StartCellId, m_EndCellId, PathFindAlg.BeamSearch, DrawPath); } } ); cleanPathBtn.onClick.AddListener( () => ResetColor(false) ); clearBtn.onClick.AddListener( () => gridSystem.ClearBlocks() ); randomBlockBtn.onClick.AddListener( () => gridSystem.GenerateRandomBlocks() ); addChaserBtn.onClick.AddListener( () => SoldierManager.Instance.CreateSoldier() ); }