Ejemplo n.º 1
0
 public NavPathController()
 {
     mNavPath        = null;
     mBaseSpeed      = 0;
     mLineSpeedTimes = 1;
     mLineSpeedPlus  = 0;
 }
Ejemplo n.º 2
0
        public static AbstractNavPath Create(NavPathType pathType, NavPathData pathData, Vector3 offset, bool pathFlipOn, IPathTrigger triggerHandler)
        {
            AbstractNavPath navPath = null;

            if (pathData.WayPoints.Count == 2 && pathType != NavPathType.LinePosLineDir)
            {
                pathType = NavPathType.LinePosLineDir;
                DebugUtils.Warning("AbstractNavPath", "Create LineType, Not ", EnumUtils.EnumToString(pathType));
            }
            switch (pathType)
            {
            case NavPathType.CurvePosCurveDir:
                navPath = new NavCurvePosCurveDir(pathData, offset, pathFlipOn, triggerHandler);
                break;

            case NavPathType.LinePosLineDir:
                navPath = new NavCurvePosCurveDir(pathData, offset, pathFlipOn, triggerHandler);
                break;

            case NavPathType.LinePosLineAngle:
                navPath = new NavCurvePosCurveDir(pathData, offset, pathFlipOn, triggerHandler);
                break;

            case NavPathType.LinePosCurveDir:
                navPath = new NavCurvePosCurveDir(pathData, offset, pathFlipOn, triggerHandler);
                break;

            default:
                DebugUtils.Error("AbstractNavPath", "Create Not Supported ", EnumUtils.EnumToString(pathType));
                break;
            }
            return(navPath);
        }
Ejemplo n.º 3
0
 public FixedPathController()
 {
     mNavPath        = null;
     bLocked         = false;
     canMove         = false;
     mLineSpeed      = 0;
     mLineSpeedTimes = 1;
 }
Ejemplo n.º 4
0
 /// <summary>
 /// 开始移动
 /// </summary>
 /// <param name="lineSpeed">线速度设置</param>
 public void StartMove(AbstractNavPath navPath, float lineSpeed)
 {
     mNavPath = navPath;
     if (mNavPath != null)
     {
         mCtlPosition.position = mNavPath.CurInfo.curvePos;
         RotateTo(mNavPath.CurInfo.curveDir);
         SetLineSpeed(lineSpeed);
     }
 }
Ejemplo n.º 5
0
 /// <summary>
 /// 开始移动
 /// </summary>
 /// <param name="lineSpeed">线速度设置</param>
 /// <param name="offset">路径偏移设置。编辑器定义</param>
 /// <param name="pathFlip">路径是否做 中心对称旋转(x, y, z) -> (-x, y, -z)</param>
 public void StartMove(AbstractNavPath navPath, float lineSpeed, Vector3 offset, bool pathFlip)
 {
     mNavPath = navPath;
     if (mNavPath != null)
     {
         mCtlPosition.position = mNavPath.CurInfo.curvePos;
         RotateTo(mNavPath.CurInfo.curveDir);
         SetLineSpeed(lineSpeed);
         EnableMove(true);
     }
 }
Ejemplo n.º 6
0
        public static BehaviourTimeCallback PathTo(this Transform trans, float duration, List <Vector3> waypoints, NavPathType pathType = NavPathType.LinePosLineDir, int subdivisions = 5)
        {
            FixedPathController pathCtrl = new FixedPathController();
            AbstractNavPath     navPath  = NavPathUtils.Create(pathType, Vector3.zero, false, null, waypoints, subdivisions);

            pathCtrl.StartMove(navPath, navPath.PathLength / duration, Vector3.zero, false);
            pathCtrl.mCtlPosition = trans;
            pathCtrl.mCtlRotate   = trans;

            Callback <FixedPathController, BehaviourTimeCallback> callback = new Callback <FixedPathController, BehaviourTimeCallback>();

            callback.Arg1    = pathCtrl;
            callback.Handler = (Action <FixedPathController, BehaviourTimeCallback>)PathTo;
            BehaviourTimeCallback beh = new BehaviourTimeCallback(callback);

            callback.Arg2 = beh;
            return(beh);
        }
Ejemplo n.º 7
0
        public void StartMove()
        {
            // 初始化数据
            string         pointsStr = "-40.8,0.0;0.0,-13.0;20.26,-0.24;0.0,13.0;-20.56,-0.49;30.46,14.27;-24.65,-14.44;-25.59,16.77;40.00,-15.00";
            List <Vector3> wayPoints = new List <Vector3>();

            NavPathUtils.ParseVector3Array(pointsStr, ref wayPoints);
            AbstractNavPath navPath = NavPathUtils.Create(PathType, Offset, FlipOn, this, wayPoints, Subdivisions);

            PathCtl.StartMove(navPath, 20, Vector3.zero, false);
            PathCtl.EnableMove(true);

            Callback <int> testCallback = ObjectPools.Instance.Acquire <Callback <int> >();

            testCallback.Handler = (Action <int>)TriggerCallback;
            testCallback.Arg1    = 20;
            PathCtl.RegisterTrigger(4.0f, testCallback);
        }
Ejemplo n.º 8
0
        public static BehaviourCallback NavPathTo(this Transform trans, float duration, List <Vector3> waypoints, Vector3 offset, IPathTrigger triggerHandler = null, NavPathFlipType flipType = NavPathFlipType.None, NavPathMoveType pathType = NavPathMoveType.LinePosLineDir, int subdivisions = 5, float pathLength = 0.0f)
        {
            NavPathController pathCtrl = new NavPathController();
            AbstractNavPath   navPath  = NavPathUtils.Create(pathType, offset, flipType, triggerHandler, waypoints, subdivisions, pathLength);

            pathCtrl.StartMove(navPath, navPath.PathLength / duration);
            pathCtrl.mCtlPosition = trans;
            pathCtrl.mCtlRotate   = trans;

            Callback2 <NavPathController, BehaviourCallback> callback = new Callback2 <NavPathController, BehaviourCallback>();

            callback.Arg1    = pathCtrl;
            callback.Handler = (Action <NavPathController, BehaviourCallback>)PathTo;
            BehaviourCallback beh = new BehaviourCallback(callback, callback, callback);

            callback.Arg2 = beh;
            return(beh);
        }
Ejemplo n.º 9
0
        public static AbstractNavPath Create(NavPathMoveType pathType, NavPathData pathData, Vector3 offset, NavPathFlipType flipType, IPathTrigger triggerHandler)
        {
            AbstractNavPath navPath = null;

            if (pathData.WayPoints.Count == 1)
            {
                pathType = NavPathMoveType.Fixed;
            }
            else if (pathData.WayPoints.Count == 2)
            {
                pathType = NavPathMoveType.LinePosLineDir;
                // DebugUtils.Log(InfoType.Warning, "AbstractNavPath Create LineType, Not " + EnumUtils.EnumToString(pathType));
            }
            switch (pathType)
            {
            case NavPathMoveType.Fixed:
                navPath = new NavPointFixed(pathData, offset, flipType, triggerHandler);
                break;

            case NavPathMoveType.CurvePosCurveDir:
                navPath = new NavCurvePosCurveDir(pathData, offset, flipType, triggerHandler);
                break;

            case NavPathMoveType.LinePosLineDir:
                navPath = new NavLinePosLineDir(pathData, offset, flipType, triggerHandler);
                break;

            case NavPathMoveType.LinePosLineAngle:
                navPath = new NavLinePosLineAngle(pathData, offset, flipType, triggerHandler, 10);
                break;

            case NavPathMoveType.LinePosCurveDir:
                navPath = new NavLinePosCurveDir(pathData, offset, flipType, triggerHandler);
                break;

            default:
                DebugUtils.Log(InfoType.Error, "AbstractNavPath Create Not Supported " + EnumUtils.EnumToString(pathType));
                break;
            }
            return(navPath);
        }