Beispiel #1
0
        private void Awake()
        {
            Assembly assembly = Assembly.GetAssembly(typeof(AStarEvaluation));
            Type     type     = assembly.GetType(EvaluationType);

            if (type != null)
            {
                _evaluation = Activator.CreateInstance(type) as AStarEvaluation;
                if (_evaluation == null)
                {
                    GlobalTools.LogError("A*:初始化网格失败,丢失了估价算法 " + EvaluationType);
                    return;
                }
            }
            else
            {
                GlobalTools.LogError("A*:初始化网格失败,丢失了估价算法 " + EvaluationType);
                return;
            }

            _nodeDiameter = NodeRadius * 2;
            _nodesWidth   = Mathf.RoundToInt(Size.x / _nodeDiameter);
            _nodesHeight  = Mathf.RoundToInt(Size.y / _nodeDiameter);
            _nodes        = new AStarNode[_nodesWidth, _nodesHeight];

            CreateGrid();
        }
Beispiel #2
0
        private void Awake()
        {
            Assembly assembly = Assembly.GetAssembly(typeof(AStarEvaluation));
            Type     type     = assembly.GetType(EvaluationType);

            if (type != null)
            {
                _evaluation = Activator.CreateInstance(type) as AStarEvaluation;
                if (_evaluation == null)
                {
                    GlobalTools.LogError("A*:初始化网格失败,丢失了估价算法 " + EvaluationType);
                    return;
                }
            }
            else
            {
                GlobalTools.LogError("A*:初始化网格失败,丢失了估价算法 " + EvaluationType);
                return;
            }

            if (IsAutoGenerate)
            {
                GenerateGrid();
            }
        }
Beispiel #3
0
        private void Awake()
        {
            Type type = ReflectionToolkit.GetTypeInRunTimeAssemblies(EvaluationType);

            if (type != null)
            {
                _evaluation = Activator.CreateInstance(type) as AStarEvaluation;
                if (_evaluation == null)
                {
                    Log.Error("A*:初始化网格失败,丢失了估价算法 " + EvaluationType);
                    return;
                }
            }
            else
            {
                Log.Error("A*:初始化网格失败,丢失了估价算法 " + EvaluationType);
                return;
            }

            if (IsAutoGenerate)
            {
                GenerateGrid();
            }
        }