IsHaveStateFlag() public method

public IsHaveStateFlag ( CharacterState_Type type ) : bool
type CharacterState_Type
return bool
        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);
                }
            }
        }
Beispiel #2
0
        internal bool HaveState(int objId, string state)
        {
            EntityInfo entity = m_Scene.EntityManager.GetEntityInfo(objId);

            if (null != entity)
            {
                return(entity.IsHaveStateFlag(CharacterStateUtility.FromString(state)));
            }
            return(false);
        }
Beispiel #3
0
        internal bool HaveState(int objId, string state)
        {
            EntityViewModel view = GetEntityViewById(objId);

            if (null != view && null != view.Entity)
            {
                EntityInfo npc = view.Entity;
                return(npc.IsHaveStateFlag(CharacterStateUtility.FromString(state)));
            }
            return(false);
        }
        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 EntityInfo GetSeeingLivingCharacterInfoHelper(EntityInfo srcObj, int id)
        {
            EntityInfo target = srcObj.EntityManager.GetEntityInfo(id);

            if (null != target)
            {
                if (target.IsHaveStateFlag(CharacterState_Type.CST_Hidden))
                {
                    target = null;
                }
                else if (target.IsDead())
                {
                    target = null;
                }
                else if (!CanSee(srcObj, target))
                {
                    target = null;
                }
            }
            return(target);
        }
        public static bool CanSee(EntityInfo source, EntityInfo target, float distSqr, Vector3 pos1, Vector3 pos2)
        {
            bool ret = false;

            if (null != source && null != target)
            {
                //一、先判断距离
                if (distSqr < source.ViewRange * source.ViewRange)
                {
                    //二、再判断逻辑
                    //后面修改的同学注意下:
                    //1、我们目前的object层是数据接口层,是不需要使用多态的。概念变化的可能性比功能变化的可能性要小很多,所以我们将多态机制应用到Logic里。
                    //2、逻辑上的影响可能是对象buff或类型产生,如果判断逻辑比较复杂,采用结构化编程的风格拆分成多个函数即可。
                    //3、另一个不建议用多态理由是这个函数的调用频率会很高。
                    if (source.GetCampId() == target.GetCampId() ||
                        (!target.IsHaveStateFlag(CharacterState_Type.CST_Hidden))) //隐身状态判断(未考虑反隐)
                    {
                        ret = true;                                                //移动版本不计算视野,只考虑逻辑上的几个点供ai用
                    }
                }
            }
            return(ret);
        }
 public static bool CanSee(EntityInfo source, EntityInfo target, float distSqr, Vector3 pos1, Vector3 pos2)
 {
     bool ret = false;
     if (null != source && null != target) {
         //一、先判断距离
         if (distSqr < source.ViewRange * source.ViewRange) {
             //二、再判断逻辑
             //后面修改的同学注意下:
             //1、我们目前的object层是数据接口层,是不需要使用多态的。概念变化的可能性比功能变化的可能性要小很多,所以我们将多态机制应用到Logic里。
             //2、逻辑上的影响可能是对象buff或类型产生,如果判断逻辑比较复杂,采用结构化编程的风格拆分成多个函数即可。
             //3、另一个不建议用多态理由是这个函数的调用频率会很高。
             if (source.GetCampId() == target.GetCampId() ||
               (!target.IsHaveStateFlag(CharacterState_Type.CST_Hidden))) {//隐身状态判断(未考虑反隐)
                 ret = true;//移动版本不计算视野,只考虑逻辑上的几个点供ai用
             }
         }
     }
     return ret;
 }