private void MoveNpc(EntityInfo obj, long deltaTime)
        {
            if (obj.HaveState(CharacterPropertyEnum.x3002_昏睡) ||
                obj.HaveState(CharacterPropertyEnum.x3001_眩晕))
            {
                return;
            }
            MovementStateInfo msi = obj.GetMovementStateInfo();

            //npc执行移动时忽略阻挡与避让,这些行为由ai模块在规划其路径时执行。
            if (!obj.IsDead() && obj.CanMove && msi.IsMoving)
            {
                ScriptRuntime.Vector3 pos = msi.GetPosition3D();
                float speed               = (float)obj.ActualProperty.GetFloat(CharacterPropertyEnum.x2011_最终速度);
                float distance            = (speed * (float)(int)deltaTime) / 1000.0f;
                ScriptRuntime.Vector3 dir = msi.TargetDir;

                //LogSystem.Debug("MovementSystem npc:{0} speed:{1} deltaTime:{2} distance:{3}", obj.GetId(), speed, deltaTime, distance);

                float x = 0, y = 0;
                if (msi.CalcDistancSquareToTarget() < distance * distance)
                {
                    x = msi.TargetPosition.X;
                    y = msi.TargetPosition.Z;
                    ScriptRuntime.Vector2 newPos = new ScriptRuntime.Vector2(x, y);
                    msi.SetPosition2D(newPos);
                    msi.IsMoving = false;
                }
                else
                {
                    ScriptRuntime.Vector3 tpos = pos + dir * distance;
                    msi.SetPosition(tpos);
                }
            }
        }
示例#2
0
 public void Init(int skillId, int targetId, ScriptRuntime.Vector3 targetPos, float targetAngle)
 {
     m_SkillId     = skillId;
     m_TargetId    = targetId;
     m_TargetPos   = targetPos;
     m_TargetAngle = targetAngle;
 }
        public static Msg_RC_CreateNpc BuildCreateNpcMessage(EntityInfo npc, int rate = -1)
        {
            Msg_RC_CreateNpc bder = new Msg_RC_CreateNpc();

            bder.npc_id  = npc.GetId();
            bder.unit_id = npc.GetUnitId();
            ScriptRuntime.Vector3         pos    = npc.GetMovementStateInfo().GetPosition3D();
            GameFrameworkMessage.Position pos_bd = new GameFrameworkMessage.Position();
            pos_bd.x            = (float)pos.X;
            pos_bd.z            = (float)pos.Z;
            bder.cur_pos        = pos_bd;
            bder.face_direction = (float)npc.GetMovementStateInfo().GetFaceDir();
            bder.link_id        = npc.GetTableId();
            bder.camp_id        = npc.GetCampId();
            if (npc.OwnerId > 0)
            {
                bder.owner_id = npc.OwnerId;
            }
            if (npc.GetAiStateInfo().LeaderId > 0)
            {
                bder.leader_id = npc.GetAiStateInfo().LeaderId;
            }
            User user = npc.CustomData as User;

            if (null != user)
            {
                bder.key = user.GetKey();
            }
            bder.level = npc.Level;

            return(bder);
        }
示例#4
0
        public int SelectTargetForSkill(string type, int actorId, TableConfig.Skill cfg, int seq, HashSet <int> history)
        {
            if (string.IsNullOrEmpty(type))
            {
                return(0);
            }
            EntityViewModel view = GetEntityViewById(actorId);

            if (null != view && null != view.Entity)
            {
                EntityInfo entity = view.Entity;
                int        campId = entity.GetCampId();
                if (type.CompareTo("minhp") == 0)
                {
                    int   targetId            = 0;
                    float minhp               = float.MaxValue;
                    ScriptRuntime.Vector3 pos = entity.GetMovementStateInfo().GetPosition3D();
                    PluginFramework.Instance.KdTree.QueryWithAction(pos, cfg.skillData.distance, (float distSqr, KdTreeObject kdObj) => {
                        if (minhp > kdObj.Object.Hp && EntityInfo.GetRelation(campId, kdObj.Object.GetCampId()) == CharacterRelation.RELATION_ENEMY)
                        {
                            int objId = kdObj.Object.GetId();
                            if (!history.Contains(objId))
                            {
                                minhp    = kdObj.Object.Hp;
                                targetId = objId;
                            }
                        }
                    });
                    return(targetId);
                }
                else if (type.CompareTo("maxdist") == 0)
                {
                    int   targetId            = 0;
                    float maxDistSqr          = 0;
                    ScriptRuntime.Vector3 pos = entity.GetMovementStateInfo().GetPosition3D();
                    PluginFramework.Instance.KdTree.QueryWithAction(pos, cfg.skillData.distance, (float distSqr, KdTreeObject kdObj) => {
                        if (maxDistSqr < distSqr && EntityInfo.GetRelation(campId, kdObj.Object.GetCampId()) == CharacterRelation.RELATION_ENEMY)
                        {
                            int objId = kdObj.Object.GetId();
                            if (!history.Contains(objId))
                            {
                                maxDistSqr = distSqr;
                                targetId   = objId;
                            }
                        }
                    });
                    return(targetId);
                }
                else if (type.CompareTo("randenemy") == 0)
                {
                    return(GetRandEnemyId(campId, history));
                }
                else if (type.CompareTo("randfriend") == 0)
                {
                    return(GetRandFriendId(campId, history));
                }
            }
            return(0);
        }
示例#5
0
        /**
         * @brief 将字符串解析为Vector3D
         *
         * @param vec 字符串,类似于"100,200,200"
         *
         * @return
         */
        public static ScriptRuntime.Vector3 ConvertVector3D(string vec)
        {
            string strPos = vec;

            string[] resut = strPos.Split(s_ListSplitString, StringSplitOptions.None);
            ScriptRuntime.Vector3 vector = new ScriptRuntime.Vector3(Convert.ToSingle(resut[0]), Convert.ToSingle(resut[1]), Convert.ToSingle(resut[2]));
            return(vector);
        }
 private void OnAiPursue(EntityInfo entity, ScriptRuntime.Vector3 target)
 {
     if (null != entity)
     {
         EntityViewModel npcViewModel = EntityViewModelManager.Instance.GetEntityViewById(entity.GetId());
         npcViewModel.MoveTo(target.X, target.Y, target.Z);
     }
 }
 public void SetMoveDir(float dir)
 {
     if (Math.Abs(m_MoveDir - dir) > c_Precision)
     {
         m_MoveDir             = dir;
         m_IsMoveStatusChanged = true;
         m_MoveDir3D           = new ScriptRuntime.Vector3((float)Math.Sin(dir), 0, (float)Math.Cos(dir));
     }
 }
 public void SetFaceDir(float rot)
 {
     if (Math.Abs(m_FaceDir - rot) > c_Precision)
     {
         m_FaceDir          = rot;
         m_IsFaceDirChanged = true;
         m_FaceDir3D        = new ScriptRuntime.Vector3((float)Math.Sin(rot), 0, (float)Math.Cos(rot));
     }
 }
示例#9
0
        public void SyncPlayerFindPath(ScriptRuntime.Vector3 target_pos)
        {
            Msg_CRC_UserFindPath builder = new Msg_CRC_UserFindPath();

            builder.target_pos_x = target_pos.X;
            builder.target_pos_y = target_pos.Y;
            builder.target_pos_z = target_pos.Z;
            SendMessage(builder);
        }
        private static void AiPursue(EntityInfo npc, ScriptRuntime.Vector3 target)
        {
            MovementStateInfo msi = npc.GetMovementStateInfo();

            msi.IsMoving       = true;
            msi.TargetPosition = target;
            float dir = Geometry.GetYRadian(msi.GetPosition3D(), target);

            msi.SetFaceDir(dir);
        }
示例#11
0
 public void ServerNpcSkill(NpcInfo npc,
                            int skillId,
                            CharacterInfo target,
                            ScriptRuntime.Vector3 targetPos,
                            float targetAngle)
 {
     //bool ret = SkillSystem.Instance.StartSkill(npc, skillId, target, targetPos, targetAngle);
     //if (ret && null != OnNpcSkill)
     //OnNpcSkill(npc, skillId, target, targetPos, targetAngle);
 }
示例#12
0
 public void Reset()
 {
     m_Position           = new ScriptRuntime.Vector3();
     m_TargetPosition     = new ScriptRuntime.Vector3();
     m_IsMoving           = false;
     m_IsMoveMeetObstacle = false;
     m_FaceDir            = 0;
     m_MoveDir            = 0;
     m_WantMoveDir        = 0;
     m_MovementMode       = MovementMode.Normal;
 }
示例#13
0
 public static ScriptRuntime.Vector3 ConvertVector3D(string vec)
 {
     try {
         string   strPos = vec;
         string[] resut  = strPos.Split(s_ListSplitString, StringSplitOptions.RemoveEmptyEntries);
         ScriptRuntime.Vector3 vector = new ScriptRuntime.Vector3(
             Convert.ToSingle(resut[0]), Convert.ToSingle(resut[1]), Convert.ToSingle(resut[2]));
         return(vector);
     } catch (System.Exception ex) {
         LogSystem.Error("ConvertVector3D {0} Exception:{1}/{2}", vec, ex.Message, ex.StackTrace);
         throw;
     }
 }
        internal void SyncPlayerMoveToPos(ScriptRuntime.Vector3 target_pos)
        {
            EntityInfo userInfo = PluginFramework.Instance.GetEntityById(PluginFramework.Instance.RoomObjId);

            if (null != userInfo)
            {
                MovementStateInfo msi = userInfo.GetMovementStateInfo();

                Msg_CR_UserMoveToPos builder = new Msg_CR_UserMoveToPos();
                builder.target_pos = ToPosition(target_pos.X, target_pos.Z);
                SendMessage(RoomMessageDefine.Msg_CR_UserMoveToPos, builder);
            }
        }
        internal void SyncPlayerMoveToPos(ScriptRuntime.Vector3 target_pos)
        {
            EntityInfo userInfo = ClientModule.Instance.GetEntityById(ClientModule.Instance.LeaderID);

            if (null != userInfo)
            {
                MovementStateInfo msi = userInfo.GetMovementStateInfo();

                Msg_CR_UserMoveToPos builder = new Msg_CR_UserMoveToPos();
                builder.target_pos = ProtoHelper.EncodePosition2D(target_pos.X, target_pos.Z);
                SendMessage(RoomMessageDefine.Msg_CR_UserMoveToPos, builder);
            }
        }
示例#16
0
        public void ServerUserSkill(UserInfo user,
                                    int skillId,
                                    CharacterInfo target,
                                    ScriptRuntime.Vector3 targetPos,
                                    float targetAngle,
                                    int itemId)
        {
            bool ret = true;//SkillSystem.Instance.StartSkill(user, skillId, target, targetPos, targetAngle);

            if (ret && null != OnUserSkill)
            {
                OnUserSkill(user);
            }
        }
        private void MoveNpc(EntityInfo obj, long deltaTime)
        {
            if (obj.IsHaveStateFlag(CharacterState_Type.CST_Sleep) ||
                obj.IsHaveStateFlag(CharacterState_Type.CST_FixedPosition))
            {
                return;
            }
            MovementStateInfo msi = obj.GetMovementStateInfo();

            //npc执行移动时忽略阻挡与避让,这些行为由ai模块在规划其路径时执行。
            if (!obj.IsDead() && obj.CanMove && msi.IsMoving && !msi.IsSkillMoving)
            {
                ScriptRuntime.Vector3 pos = msi.GetPosition3D();
                float speed               = (float)obj.GetActualProperty().MoveSpeed;
                float distance            = (speed * (float)(int)deltaTime) / 1000.0f;
                ScriptRuntime.Vector3 dir = msi.TargetDir;

                //LogSystem.Debug("MovementSystem npc:{0} speed:{1} deltaTime:{2} distance:{3}", obj.GetId(), speed, deltaTime, distance);

                float x = 0, y = 0;
                if (msi.CalcDistancSquareToTarget() < distance * distance)
                {
                    x = msi.TargetPosition.X;
                    y = msi.TargetPosition.Z;
                    ScriptRuntime.Vector2 newPos = new ScriptRuntime.Vector2(x, y);
                    msi.SetPosition2D(newPos);

                    msi.IsMoving = false;
                    User user = obj.CustomData as User;
                    if (null != user)
                    {
                        Msg_RC_NpcMove npcMoveBuilder = DataSyncUtility.BuildNpcMoveMessage(obj);
                        if (null != npcMoveBuilder)
                        {
                            Scene scene = user.OwnRoom.ActiveScene;
                            if (null != scene)
                            {
                                scene.NotifyAllUser(RoomMessageDefine.Msg_RC_NpcMove, npcMoveBuilder);
                            }
                        }
                    }
                }
                else
                {
                    ScriptRuntime.Vector3 tpos = pos + dir * distance;
                    msi.SetPosition(tpos);
                }
            }
        }
        public static Msg_RC_NpcSkill BuildNpcSkillMessage(EntityInfo obj, int skillId)
        {
            MovementStateInfo msi = obj.GetMovementStateInfo();

            ScriptRuntime.Vector3 pos = msi.GetPosition3D();

            Msg_RC_NpcSkill msg = new Msg_RC_NpcSkill();

            msg.npc_id         = obj.GetId();
            msg.skill_id       = skillId;
            msg.stand_pos      = ToPosition(pos.X, pos.Z);
            msg.face_direction = msi.GetFaceDir();
            msg.target_id      = obj.GetAiStateInfo().Target;

            return(msg);
        }
示例#19
0
        /**
         * @brief 提取数据
         *
         * @param node
         *
         * @return
         */
        public bool CollectDataFromDBC(DBC_Row node)
        {
            m_Id       = DBCUtil.ExtractNumeric <int>(node, "Id", 0, true);
            m_LinkId   = DBCUtil.ExtractNumeric <int>(node, "LinkId", 0, true);
            m_CampId   = DBCUtil.ExtractNumeric <int>(node, "CampId", 0, true);
            m_Pos      = Converter.ConvertVector3D(DBCUtil.ExtractString(node, "Pos", "0.0,0.0,0.0", true));
            m_RotAngle = DBCUtil.ExtractNumeric <float>(node, "RotAngle", 0.0f, true) * (float)Math.PI / 180;
            m_IsEnable = DBCUtil.ExtractBool(node, "IsEnable", false, true);
            m_AiLogic  = DBCUtil.ExtractNumeric <int>(node, "AiLogic", 0, false);
            for (int i = 0; i < c_MaxAiParamNum; ++i)
            {
                m_AiParam[i] = DBCUtil.ExtractString(node, "AiParam" + i, "", false);
            }

            return(true);
        }
示例#20
0
        private void SyncMovement()
        {
            if (null != m_Entity && null != m_Actor)
            {
                float             curTime = Time.time;
                MovementStateInfo msi     = m_Entity.GetMovementStateInfo();
                if (msi.IsMoving)
                {
                    if (m_LastSyncTime + c_SyncInterval <= curTime)
                    {
                        m_LastSyncTime = curTime;
                        if (m_Entity.IsServerEntity)
                        {
                            Transform             t   = m_Actor.transform;
                            ScriptRuntime.Vector3 dir = msi.GetMoveDir3D();
                            Vector3 pos = t.position + new Vector3(dir.X, 0, dir.Z) * 8.0f * c_SyncInterval;
                        }
                    }

                    if (GlobalVariables.Instance.IsDebug)
                    {
                        Utility.EventSystem.Publish("ui_actor_name", "ui", m_Entity.GetId(), string.Format("{0}({1}):c({2},{3})", m_Entity.GetName(), m_Entity.GetId(), msi.PositionX, msi.PositionZ));
                    }

                    if (m_Entity.GetId() != PluginFramework.Instance.LeaderID)
                    {
                        if (Geometry.DistanceSquare(msi.GetPosition3D(), msi.TargetPosition) > 0.625f)
                        {
                            MoveTo(msi.TargetPosition.X, msi.TargetPosition.Y, msi.TargetPosition.Z);
                        }
                        else
                        {
                            msi.IsMoving = false;
                            StopMove();
                        }
                    }
                }
                else
                {
                    if (GlobalVariables.Instance.IsDebug)
                    {
                        Utility.EventSystem.Publish("ui_actor_name", "ui", m_Entity.GetId(), string.Format("{0}({1}):c({2},{3})", m_Entity.GetName(), m_Entity.GetId(), msi.PositionX, msi.PositionZ));
                    }
                }
            }
        }
示例#21
0
        public bool CalcPosAndDir(int targetId, out ScriptRuntime.Vector3 pos, out float dir)
        {
            EntityViewModel view = GetEntityViewById(targetId);

            if (null != view)
            {
                MovementStateInfo msi = view.Entity.GetMovementStateInfo();
                pos = msi.GetPosition3D();
                dir = msi.GetFaceDir();
                return(true);
            }
            else
            {
                pos = ScriptRuntime.Vector3.Zero;
                dir = 0;
                return(false);
            }
        }
示例#22
0
 public void Create(EntityInfo entity)
 {
     if (null != entity)
     {
         m_Entity = entity;
         MovementStateInfo     msi = m_Entity.GetMovementStateInfo();
         ScriptRuntime.Vector3 pos = msi.GetPosition3D();
         float dir = msi.GetFaceDir();
         CreateActor(m_Entity.GetId(), m_Entity.GetModel(), pos.X, pos.Y, pos.Z, dir, m_Entity.Scale, m_Entity.GetRadius(), entity.ActualProperty.GetFloat(CharacterPropertyEnum.x2011_最终速度));
         if (null != Actor)
         {
             m_Agent = Actor.GetComponent <NavMeshAgent>();
             if (m_Agent == null)
             {
                 m_Agent = Actor.AddComponent <NavMeshAgent>();
                 m_Agent.angularSpeed          = c_AngularSpeed;
                 m_Agent.acceleration          = c_Acceleration;
                 m_Agent.radius                = entity.GetRadius();
                 m_Agent.speed                 = entity.ActualProperty.GetFloat(CharacterPropertyEnum.x2011_最终速度);
                 m_Agent.obstacleAvoidanceType = ObstacleAvoidanceType.NoObstacleAvoidance;
             }
             m_Animator = Actor.GetComponentInChildren <Animator>();
             EntityDrawGizmos gizmos = Actor.GetComponent <EntityDrawGizmos>();
             if (null == gizmos)
             {
                 gizmos         = Actor.AddComponent <EntityDrawGizmos>();
                 gizmos.npcInfo = m_Entity;
             }
             else
             {
                 gizmos.npcInfo = m_Entity;
             }
             SetMoveAgentEnable(true);
             try{
                 if (null != m_Agent)
                 {
                     m_Agent.ResetPath();
                 }
             } catch {
                 m_Agent.enabled = true;
             }
         }
     }
 }
示例#23
0
        public ShipDeckBossShowInfo(string pstr)
        {
            string[] p = pstr.Split(':');
            BossDataId  = Int32.Parse(p[0]);
            BossSkillId = Int32.Parse(p[1]);
            string[] v = p[2].Split(' ');
            if (3 == v.Length)
            {
                BossPos = new ScriptRuntime.Vector3(
                    float.Parse(v[0]),
                    float.Parse(v[1]),
                    float.Parse(v[2]));
            }
            SkillInterval = float.Parse(p[3]);
            LastSkillTime = 0;

            BossId = -1;
            Phase  = (int)PhaseCode.OnStage;
        }
示例#24
0
        internal static Msg_RC_NpcMove BuildNpcMoveMessage(EntityInfo npc)
        {
            ScriptRuntime.Vector3 srcPos         = npc.GetMovementStateInfo().GetPosition3D();
            Msg_RC_NpcMove        npcMoveBuilder = new Msg_RC_NpcMove();

            if (npc.GetMovementStateInfo().IsMoving)
            {
                npcMoveBuilder.npc_id   = npc.GetId();
                npcMoveBuilder.velocity = ProtoHelper.EncodeFloat(npc.GetActualProperty().MoveSpeed);
                ScriptRuntime.Vector3 targetPos = npc.GetMovementStateInfo().TargetPosition;
                npcMoveBuilder.target_pos = ProtoHelper.EncodePosition2D(targetPos.X, targetPos.Z);
                npcMoveBuilder.cur_pos    = ProtoHelper.EncodePosition2D(srcPos.X, srcPos.Z);
            }
            else
            {
                npcMoveBuilder.npc_id  = npc.GetId();
                npcMoveBuilder.cur_pos = ProtoHelper.EncodePosition2D(srcPos.X, srcPos.Z);
            }
            return(npcMoveBuilder);
        }
示例#25
0
        public EntityInfo GetNearest(ScriptRuntime.Vector3 pos, ref float minPowDist)
        {
            EntityInfo result  = null;
            float      powDist = 0.0f;

            for (LinkedListNode <EntityInfo> linkNode = m_Entities.FirstValue; null != linkNode; linkNode = linkNode.Next)
            {
                EntityInfo entity = linkNode.Value;
                if (null != entity && entity.IsCombatNpc())
                {
                    powDist = Geometry.DistanceSquare(pos, entity.GetMovementStateInfo().GetPosition3D());
                    if (minPowDist > powDist)
                    {
                        result     = entity;
                        minPowDist = powDist;
                    }
                }
            }
            return(result);
        }
示例#26
0
        public static List <GameObject> FindTargetInSector(Vector3 center,
                                                           float radius,
                                                           Vector3 direction,
                                                           Vector3 degreeCenter,
                                                           float degree)
        {
            List <GameObject> result = new List <GameObject>();

            PluginFramework.Instance.KdTree.QueryWithAction(center.x, center.y, center.z, radius, (float distSqr, KdTreeObject kdTreeObj) => {
                ScriptRuntime.Vector3 pos = kdTreeObj.Position;
                Vector3 targetDir         = new Vector3(pos.X, pos.Y, pos.Z) - degreeCenter;
                targetDir.y = 0;
                if (Mathf.Abs(Vector3.Angle(targetDir, direction)) <= degree)
                {
                    GameObject obj = EntityController.Instance.GetGameObject(kdTreeObj.Object.GetId());
                    result.Add(obj);
                }
            });
            return(result);
        }
        public static Msg_RC_NpcMove BuildNpcMoveMessage(EntityInfo npc)
        {
            ScriptRuntime.Vector3 srcPos         = npc.GetMovementStateInfo().GetPosition3D();
            Msg_RC_NpcMove        npcMoveBuilder = new Msg_RC_NpcMove();

            if (npc.GetMovementStateInfo().IsMoving)
            {
                npcMoveBuilder.npc_id   = npc.GetId();
                npcMoveBuilder.velocity = npc.ActualProperty.GetFloat(CharacterPropertyEnum.x2011_最终速度);
                ScriptRuntime.Vector3 targetPos = npc.GetMovementStateInfo().TargetPosition;
                npcMoveBuilder.target_pos = ToPosition(targetPos.X, targetPos.Z);
                npcMoveBuilder.cur_pos    = ToPosition(srcPos.X, srcPos.Z);
            }
            else
            {
                npcMoveBuilder.npc_id  = npc.GetId();
                npcMoveBuilder.cur_pos = ToPosition(srcPos.X, srcPos.Z);
            }
            return(npcMoveBuilder);
        }
        private static void DoMoveCommandState(EntityInfo npc, long deltaTime)
        {
            //执行状态处理
            AiData_ForMoveCommand data = GetAiDataForMoveCommand(npc);

            if (null == data)
            {
                return;
            }

            if (!data.IsFinish)
            {
                if (WayPointArrived(npc, data))
                {
                    ScriptRuntime.Vector3 targetPos = new ScriptRuntime.Vector3();
                    MoveToNext(npc, data, ref targetPos);
                    if (!data.IsFinish)
                    {
                        AiPursue(npc, targetPos);
                    }
                }
                else
                {
                    ScriptRuntime.Vector3 targetPos = data.WayPoints[data.Index];
                    AiPursue(npc, targetPos);
                }
            }

            //判断是否状态结束并执行相应处理
            if (data.IsFinish)
            {
                Scene scene = npc.SceneContext.CustomData as Scene;
                if (null != scene)
                {
                    scene.StorySystem.SendMessage("npcarrived:" + npc.GetUnitId(), npc.GetId());
                    scene.StorySystem.SendMessage("objarrived", npc.GetId());
                }
                AiStopPursue(npc);
                npc.GetAiStateInfo().ChangeToState((int)PredefinedAiStateId.Idle);
            }
        }
        private static void DoMoveCommandState(EntityInfo npc, long deltaTime)
        {
            //执行状态处理
            AiData_ForMoveCommand data = GetAiDataForMoveCommand(npc);

            if (null == data)
            {
                return;
            }

            if (!data.IsFinish)
            {
                if (WayPointArrived(npc, data))
                {
                    ScriptRuntime.Vector3 targetPos = new ScriptRuntime.Vector3();
                    MoveToNext(npc, data, ref targetPos);
                    if (!data.IsFinish)
                    {
                        AiPursue(npc, targetPos);
                    }
                }
                else
                {
                    ScriptRuntime.Vector3 targetPos = data.WayPoints[data.Index];
                    AiPursue(npc, targetPos);
                }
            }

            //判断是否状态结束并执行相应处理
            if (data.IsFinish)
            {
                if (!string.IsNullOrEmpty(data.Event))
                {
                    GfxStorySystem.Instance.SendMessage(data.Event, npc.GetId(), npc.GetUnitId());
                }
                AiStopPursue(npc);
                npc.GetAiStateInfo().ChangeToState((int)PredefinedAiStateId.Idle);
            }
        }
示例#30
0
        /**
         * @brief 提取数据
         *
         * @param node
         *
         * @return
         */
        public bool CollectDataFromDBC(DBC_Row node)
        {
            Id       = DBCUtil.ExtractNumeric <int>(node, "Id", -1, true);
            Name     = DBCUtil.ExtractString(node, "Name", "", true);
            IsMusic  = DBCUtil.ExtractBool(node, "IsMusic", false, true);
            Priority = DBCUtil.ExtractNumeric <int>(node, "Priority", 1, false);
            Volume   = DBCUtil.ExtractNumeric <float>(node, "Volume", 1.0f, false);
            IsLoop   = DBCUtil.ExtractBool(node, "IsLoop", false, false);
            Position = Converter.ConvertVector3D(DBCUtil.ExtractString(node, "Position", "0,0,0", false));

            ParamNum = DBCUtil.ExtractNumeric <int>(node, "ParamNum", 0, false);
            ExtraParams.Clear();
            if (ParamNum > 0)
            {
                for (int i = 0; i < ParamNum; ++i)
                {
                    string key = "Param" + i.ToString();
                    ExtraParams.Insert(i, DBCUtil.ExtractString(node, key, "", false));
                }
            }

            return(true);
        }
 public MovementStateInfo()
 {
     m_Position = ScriptRuntime.Vector3.Zero;
 }
        public void Reset()
        {
            m_Position = ScriptRuntime.Vector3.Zero;
            m_TargetPosition = ScriptRuntime.Vector3.Zero;

            m_IsMoving = false;
            m_IsSkillMoving = false;
            m_FaceDir = 0;
            m_MoveDir = 0;
            m_TargetDir = ScriptRuntime.Vector3.Zero;
            m_FaceDir3D = ScriptRuntime.Vector3.Zero;
            m_MoveDir3D = ScriptRuntime.Vector3.Zero;
            m_IsFaceDirChanged = false;
            m_IsMoveStatusChanged = false;
        }
 public void SetPosition(ScriptRuntime.Vector3 pos)
 {
     m_Position = pos;
 }
 public void SetFaceDir(float rot)
 {
     if (Math.Abs(m_FaceDir - rot) > c_Precision) {
         m_FaceDir = rot;
         m_IsFaceDirChanged = true;
         m_FaceDir3D = new ScriptRuntime.Vector3((float)Math.Sin(rot), 0, (float)Math.Cos(rot));
     }
 }
 public void SetMoveDir(float dir)
 {
     if (Math.Abs(m_MoveDir - dir) > c_Precision) {
         m_MoveDir = dir;
         m_IsMoveStatusChanged = true;
         m_MoveDir3D = new ScriptRuntime.Vector3((float)Math.Sin(dir), 0, (float)Math.Cos(dir));
     }
 }