Beispiel #1
0
        public static void ExecPlayerSelfMoveCommand(float x, float y, float z)
        {
            Vector3 pos = new Vector3();

            pos.x = x;
            pos.y = y;
            pos.z = z;
            UserInfo user = WorldSystem.Instance.GetPlayerSelf();

            if (null != user)
            {
                if (!user.UnityPathFinding)
                {
                    List <Vector3> waypoints = user.SpatialSystem.FindPath(user.GetMovementStateInfo().GetPosition3D(), pos, 1);
                    waypoints.Add(pos);
                    UserAiStateInfo       aiInfo = user.GetAiStateInfo();
                    AiData_ForMoveCommand data   = aiInfo.AiDatas.GetData <AiData_ForMoveCommand>();
                    if (null == data)
                    {
                        data = new AiData_ForMoveCommand(waypoints);
                        aiInfo.AiDatas.AddData(data);
                    }

                    data.WayPoints          = waypoints;
                    data.Index              = 0;
                    data.EstimateFinishTime = 0;
                    data.IsFinish           = false;
                    aiInfo.ChangeToState((int)AiStateId.MoveCommand);
                }
                else
                {
                    UserAiStateInfo       aiInfo = user.GetAiStateInfo();
                    AiData_ForMoveCommand data   = aiInfo.AiDatas.GetData <AiData_ForMoveCommand>();
                    if (null == data)
                    {
                        data = new AiData_ForMoveCommand(null);
                        aiInfo.AiDatas.AddData(data);
                    }

                    user.PathFindingFinished = false;
                    user.GetAiStateInfo().ChangeToState((int)AiStateId.PathFinding);
                    user.GetAiStateInfo().PreviousState = (int)AiStateId.MoveCommand;
                    GfxSystem.ForMoveCommandPathToTarget(user, pos);
                }
            }
        }
Beispiel #2
0
        public static void ExecObjMoveCommand(int objId, float x, float y, float z)
        {
            Vector3       pos  = new Vector3(x, y, z);
            CharacterInfo obj  = WorldSystem.Instance.GetCharacterById(objId);
            UserInfo      user = obj as UserInfo;

            if (null != user)
            {
                if (!user.UnityPathFinding)
                {
                    List <Vector3> waypoints = user.SpatialSystem.FindPath(user.GetMovementStateInfo().GetPosition3D(), pos, 1);
                    waypoints.Add(pos);
                    UserAiStateInfo       aiInfo = user.GetAiStateInfo();
                    AiData_ForMoveCommand data   = aiInfo.AiDatas.GetData <AiData_ForMoveCommand>();
                    if (null == data)
                    {
                        data = new AiData_ForMoveCommand(waypoints);
                        aiInfo.AiDatas.AddData(data);
                    }
                    data.WayPoints          = waypoints;
                    data.Index              = 0;
                    data.EstimateFinishTime = 0;
                    data.IsFinish           = false;
                    aiInfo.ChangeToState((int)AiStateId.MoveCommand);
                }
                else
                {
                    UserAiStateInfo       aiInfo = user.GetAiStateInfo();
                    AiData_ForMoveCommand data   = aiInfo.AiDatas.GetData <AiData_ForMoveCommand>();
                    if (null == data)
                    {
                        data = new AiData_ForMoveCommand(null);
                        aiInfo.AiDatas.AddData(data);
                    }

                    user.PathFindingFinished = false;
                    user.GetAiStateInfo().ChangeToState((int)AiStateId.PathFinding);
                    user.GetAiStateInfo().PreviousState = (int)AiStateId.MoveCommand;
                    GfxSystem.ForMoveCommandPathToTarget(user, pos);
                }
            }
            else
            {
                NpcInfo npc = obj as NpcInfo;
                if (null != npc)
                {
                    if (!npc.UnityPathFinding)
                    {
                        List <Vector3> waypoints = npc.SpatialSystem.FindPath(npc.GetMovementStateInfo().GetPosition3D(), pos, 1);
                        waypoints.Add(pos);
                        NpcAiStateInfo        aiInfo = npc.GetAiStateInfo();
                        AiData_ForMoveCommand data   = aiInfo.AiDatas.GetData <AiData_ForMoveCommand>();
                        if (null == data)
                        {
                            data = new AiData_ForMoveCommand(waypoints);
                            aiInfo.AiDatas.AddData(data);
                        }
                        data.WayPoints          = waypoints;
                        data.Index              = 0;
                        data.EstimateFinishTime = 0;
                        data.IsFinish           = false;
                        aiInfo.ChangeToState((int)AiStateId.MoveCommand);
                    }
                    else
                    {
                        NpcAiStateInfo        aiInfo = npc.GetAiStateInfo();
                        AiData_ForMoveCommand data   = aiInfo.AiDatas.GetData <AiData_ForMoveCommand>();
                        if (null == data)
                        {
                            data = new AiData_ForMoveCommand(null);
                            aiInfo.AiDatas.AddData(data);
                        }

                        npc.PathFindingFinished = false;
                        npc.GetAiStateInfo().ChangeToState((int)AiStateId.PathFinding);
                        npc.GetAiStateInfo().PreviousState = (int)AiStateId.MoveCommand;
                        GfxSystem.ForMoveCommandPathToTarget(npc, pos);
                    }
                }
            }
        }