예제 #1
0
        public static MoveToAction GetAction(GameObject gameObject, IActionCallback callback, Vector3 target, float speed, int area)
        {
            MoveToAction action = CreateInstance <MoveToAction>();

            action.gameObject = gameObject;
            action.transform  = gameObject.transform;
            action.callback   = callback;
            action.target     = target;
            action.speed      = speed;
            action.area       = area;
            return(action);
        }
예제 #2
0
        // 巡逻兵自主巡逻。
        public void GoAround(GameObject patrol)
        {
            var area = patrol.GetComponent <Soldier>().area;

            // 防止重入。
            if (moveToActions.ContainsKey(area))
            {
                return;
            }
            // 计算下一巡逻目的地。
            var          target = GetGoAroundTarget(patrol);
            MoveToAction action = MoveToAction.GetAction(patrol, this, target, 1.5f, area);

            moveToActions.Add(area, action);
            AddAction(action);
        }