예제 #1
0
    void DoIt()
    {
        startNode = null;
        endNode   = null;
#if UNITY_EDITOR
        line.ClearLines();
#endif

        Stopwatch watch = new Stopwatch();
        watch.Start();

        fixResult.Clear();
        if (!machine.FindPath(from, to, ref fixResult, TwGame.Team.Neutral))
        {
            UnityEngine.Debug.Log("ms " + watch.ElapsedMilliseconds);
            to = PathFindingMachine.Instance.GetNearestPosition(to);
            bool ret = machine.FindPath(from, to, ref fixResult, TwGame.Team.Neutral);
            if (!ret)
            {
                UnityEngine.Debug.Log("cannot find a path to " + to.ToString());
            }
        }

        if (fixResult.Count > 0)
        {
#if UNITY_EDITOR
            line.ClearLines();
            line.AddLine(fixResult.ToArray(), Color.red);
#endif
        }

        watch.Stop();
        if (fixResult.Count > 0)
        {
            UnityEngine.Debug.Log("ms " + watch.ElapsedMilliseconds);
        }
    }