GetCampId() 공개 메소드

public GetCampId ( ) : int
리턴 int
        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);
        }
        internal 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.GetLinkId();
            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.GetLevel();

            return bder;
        }
예제 #3
0
        public int GetRandFriendId(int campId, HashSet <int> history)
        {
            int        id  = 0;
            List <int> ids = new List <int>();

            for (LinkedListNode <EntityInfo> linkNode = PluginFramework.Instance.EntityManager.Entities.FirstValue; null != linkNode; linkNode = linkNode.Next)
            {
                EntityInfo info = linkNode.Value;
                if (EntityInfo.GetRelation(campId, info.GetCampId()) == CharacterRelation.RELATION_FRIEND && info.EntityType != (int)EntityTypeEnum.Tower)
                {
                    ids.Add(info.GetId());
                }
            }
            for (int ct = 0; ct < ids.Count; ++ct)
            {
                int index = Helper.Random.Next(ids.Count);
                if (index >= 0 && index < ids.Count)
                {
                    int _id = ids[index];
                    if (!history.Contains(id))
                    {
                        id = _id;
                        break;
                    }
                }
            }
            return(id);
        }
 internal static Msg_RC_CampChanged BuildCampChangedMessage(EntityInfo obj)
 {
     Msg_RC_CampChanged msg = new Msg_RC_CampChanged();
     msg.obj_id = obj.GetId();
     msg.camp_id = obj.GetCampId();
     return msg;
 }
예제 #5
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);
        }
        public static Msg_RC_CampChanged BuildCampChangedMessage(EntityInfo obj)
        {
            Msg_RC_CampChanged msg = new Msg_RC_CampChanged();

            msg.obj_id  = obj.GetId();
            msg.camp_id = obj.GetCampId();
            return(msg);
        }
예제 #7
0
        internal int SelectTargetForSkill(string type, int objId, TableConfig.Skill cfg, int seq, HashSet <int> history)
        {
            if (string.IsNullOrEmpty(type))
            {
                return(0);
            }
            EntityInfo entity = m_Scene.EntityManager.GetEntityInfo(objId);

            if (null != entity)
            {
                int campId = entity.GetCampId();
                if (type.CompareTo("minhp") == 0)
                {
                    int   targetId            = 0;
                    float minhp               = float.MaxValue;
                    ScriptRuntime.Vector3 pos = entity.GetMovementStateInfo().GetPosition3D();
                    m_Scene.KdTree.Query(pos, cfg.distance, (float distSqr, KdTreeObject kdObj) => {
                        if (minhp > kdObj.Object.Hp && EntityInfo.GetRelation(campId, kdObj.Object.GetCampId()) == CharacterRelation.RELATION_ENEMY)
                        {
                            int id = kdObj.Object.GetId();
                            if (!history.Contains(id))
                            {
                                minhp    = kdObj.Object.Hp;
                                targetId = id;
                            }
                        }
                    });
                    return(targetId);
                }
                else if (type.CompareTo("maxdist") == 0)
                {
                    int   targetId            = 0;
                    float maxDistSqr          = 0;
                    ScriptRuntime.Vector3 pos = entity.GetMovementStateInfo().GetPosition3D();
                    m_Scene.KdTree.Query(pos, cfg.distance, (float distSqr, KdTreeObject kdObj) => {
                        if (maxDistSqr < distSqr && EntityInfo.GetRelation(campId, kdObj.Object.GetCampId()) == CharacterRelation.RELATION_ENEMY)
                        {
                            int id = kdObj.Object.GetId();
                            if (!history.Contains(id))
                            {
                                maxDistSqr = distSqr;
                                targetId   = id;
                            }
                        }
                    });
                    return(targetId);
                }
                else if (type.CompareTo("randenemy") == 0)
                {
                    return(GetRandEnemyId(campId, history));
                }
                else if (type.CompareTo("randfriend") == 0)
                {
                    return(GetRandFriendId(campId, history));
                }
            }
            return(0);
        }
예제 #8
0
        public int GetCampId(EntityInfo obj)
        {
            int campId = 0;

            if (null != obj)
            {
                campId = obj.GetCampId();
            }
            return(campId);
        }
예제 #9
0
        public int GetCampId(int objId)
        {
            int        campId = 0;
            EntityInfo entity = m_Scene.EntityManager.GetEntityInfo(objId);

            if (null != entity)
            {
                campId = entity.GetCampId();
            }
            return(campId);
        }
예제 #10
0
        public int GetCampId(int objId)
        {
            int             campId = 0;
            EntityViewModel view   = GetEntityViewById(objId);

            if (null != view && null != view.Entity)
            {
                EntityInfo entity = view.Entity;
                campId = entity.GetCampId();
            }
            return(campId);
        }
예제 #11
0
        public int GetCampId(UnityEngine.GameObject obj)
        {
            int             campId = 0;
            EntityViewModel view   = GetEntityView(obj);

            if (null != view && null != view.Entity)
            {
                EntityInfo entity = view.Entity;
                campId = entity.GetCampId();
            }
            return(campId);
        }
예제 #12
0
        internal int GetBattleNpcCount(int campId)
        {
            int ct = 0;

            for (LinkedListNode <EntityInfo> linkNode = m_EntityManager.Entities.FirstValue; null != linkNode; linkNode = linkNode.Next)
            {
                EntityInfo info = linkNode.Value;
                if (null != info && !info.IsDead() && info.IsCombatNpc() && info.GetCampId() == campId)
                {
                    ++ct;
                }
            }
            return(ct);
        }
        private static bool CanSee(EntityInfo src, EntityInfo target)
        {
            int srcCampId    = src.GetCampId();
            int targetCampId = target.GetCampId();

            if (srcCampId == targetCampId)
            {
                return(true);
            }
            else if (srcCampId == (int)CampIdEnum.Hostile || targetCampId == (int)CampIdEnum.Hostile)
            {
                return(EntityInfo.CanSee(src, target));
            }
            else
            {
                return(true);
            }
        }
예제 #14
0
        //阵营可为Friendly、Hostile、Blue、Red
        //Friendly 全部友好
        //Hostile 全部敌对(同阵营友好)
        //Blue 与Hostile与Red敌对
        //Red 与Hostile与Blue敌对
        public static CharacterRelation GetRelation(EntityInfo pObj_A, EntityInfo pObj_B)
        {
            if (pObj_A == null || pObj_B == null)
            {
                return(CharacterRelation.RELATION_INVALID);
            }

            if (pObj_A == pObj_B)
            {
                return(CharacterRelation.RELATION_FRIEND);
            }

            int campA = pObj_A.GetCampId();
            int campB = pObj_B.GetCampId();
            CharacterRelation relation = GetRelation(campA, campB);

            return(relation);
        }
예제 #15
0
        public void EnterScene(User newUser)
        {
            Msg_LR_RoomUserInfo lobbyUserData = newUser.LobbyUserData;

            if (null == lobbyUserData)
            {
                return;
            }
            TableConfig.Actor cfg  = TableConfig.ActorProvider.Instance.GetActor(lobbyUserData.Hero);
            EntityInfo        info = m_EntityMgr.AddEntity(0, lobbyUserData.Camp, cfg, string.Empty);

            info.SetUnitId(EntityInfo.c_StartUserUnitId + info.GetId());
            info.GetMovementStateInfo().FormationIndex = 0;
            if (null != m_SceneConfig)
            {
                info.GetMovementStateInfo().SetPosition2D(m_SceneConfig.EnterX + (Helper.Random.NextFloat() - 0.5f) * m_SceneConfig.EnterRadius, m_SceneConfig.EnterY + (Helper.Random.NextFloat() - 0.5f) * m_SceneConfig.EnterRadius);
            }
            newUser.Info = info;

            AttrCalculator.Calc(info);
            if (newUser.HaveHpArmor)
            {
                info.Hp     = newUser.Hp;
                info.Energy = newUser.Energy;
            }
            else
            {
                info.Hp     = newUser.Info.HpMax;
                info.Energy = newUser.Info.EnergyMax;
            }

            info.SceneContext = m_SceneContext;
            AddCareList(info);
            if (newUser.IsEntered)
            {
                var args = m_StorySystem.NewBoxedValueList();
                args.Add(info.GetId());
                args.Add(info.GetUnitId());
                args.Add(info.GetCampId());
                args.Add(info.GetMovementStateInfo().PositionX);
                args.Add(info.GetMovementStateInfo().PositionZ);
                m_StorySystem.SendMessage("user_enter_scene", args);
            }
        }
예제 #16
0
        internal int GetRandFriendId(int campId)
        {
            int        id  = 0;
            List <int> ids = new List <int>();

            for (LinkedListNode <EntityInfo> linkNode = m_Scene.EntityManager.Entities.FirstValue; null != linkNode; linkNode = linkNode.Next)
            {
                EntityInfo info = linkNode.Value;
                if (EntityInfo.GetRelation(campId, info.GetCampId()) == CharacterRelation.RELATION_FRIEND && info.EntityType != (int)EntityTypeEnum.Tower)
                {
                    ids.Add(info.GetId());
                }
            }
            int index = Helper.Random.Next(ids.Count);

            if (index >= 0 && index < ids.Count)
            {
                id = ids[index];
            }
            return(id);
        }
예제 #17
0
        public int GetRandEnemyId(int campId)
        {
            int        id  = 0;
            List <int> ids = new List <int>();

            for (LinkedListNode <EntityInfo> linkNode = PluginFramework.Instance.EntityManager.Entities.FirstValue; null != linkNode; linkNode = linkNode.Next)
            {
                EntityInfo info = linkNode.Value;
                if (EntityInfo.GetRelation(campId, info.GetCampId()) == CharacterRelation.RELATION_ENEMY && info.EntityType != (int)EntityTypeEnum.Tower)
                {
                    ids.Add(info.GetId());
                }
            }
            int index = Helper.Random.Next(ids.Count);

            if (index >= 0 && index < ids.Count)
            {
                id = ids[index];
            }
            return(id);
        }
예제 #18
0
        public void LeaveScene(User user)
        {
            user.HaveEnterPosition = false;
            user.IsEntered         = false;
            EntityInfo info = user.Info;

            if (null != info)
            {
                RemoveCareList(info);
                var args = m_StorySystem.NewBoxedValueList();
                args.Add(info.GetId());
                args.Add(info.GetUnitId());
                args.Add(info.GetCampId());
                args.Add(info.GetMovementStateInfo().PositionX);
                args.Add(info.GetMovementStateInfo().PositionZ);
                m_StorySystem.SendMessage("user_leave_scene", args);
                user.SetHpArmor(info.Hp, info.Energy);
                info.NeedDelete = true;
                user.Info       = null;
            }
        }
예제 #19
0
        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);
        }
예제 #20
0
        public static void Execute(object msg, User user)
        {
            Msg_CR_Enter enter_msg = msg as Msg_CR_Enter;

            if (enter_msg == null)
            {
                return;
            }
            LogSys.Log(LOG_TYPE.DEBUG, "user {0}({1},{2},{3}) enter.", user.RoleId, user.GetKey(), user.Guid, user.Name);
            user.UserControlState = (int)UserControlState.User;
            user.IsEntered        = true;

            RoomUserManager roomUserMgr = user.OwnRoomUserManager;

            if (null != roomUserMgr)
            {
                Scene scene = roomUserMgr.ActiveScene;
                if (null != scene)
                {
                    EntityInfo userInfo = user.Info;
                    if (null != userInfo)
                    {
                        if (scene.SceneState == SceneState.Running)
                        {
                            scene.SyncForNewUser(user);
                            var args = scene.StorySystem.NewBoxedValueList();
                            args.Add(userInfo.GetId());
                            args.Add(userInfo.GetUnitId());
                            args.Add(userInfo.GetCampId());
                            args.Add(userInfo.GetMovementStateInfo().PositionX);
                            args.Add(userInfo.GetMovementStateInfo().PositionZ);
                            scene.StorySystem.SendMessage("user_enter_scene", args);
                        }
                    }
                }
            }
        }
예제 #21
0
        internal void LeaveScene(User user)
        {
            EntityInfo info = user.Info;

            RemoveCareList(info);
            m_StorySystem.SendMessage("user_leave_scene", info.GetId(), info.GetUnitId(), info.GetCampId(), info.GetMovementStateInfo().PositionX, info.GetMovementStateInfo().PositionZ);
            user.SetHpArmor(info.Hp, info.Energy);
            user.HaveEnterPosition = false;
            user.IsEntered         = false;
            info.NeedDelete        = true;
            user.Info = null;
        }
예제 #22
0
 private void TickEntities()
 {
     m_DeletedEntities.Clear();
     for (LinkedListNode <EntityInfo> linkNode = m_EntityManager.Entities.FirstValue; null != linkNode; linkNode = linkNode.Next)
     {
         EntityInfo info = linkNode.Value;
         info.RetireAttackerInfos(10000);
         if (info.LevelChanged || info.GetSkillStateInfo().BuffChanged)
         {
             AttrCalculator.Calc(info);
             info.LevelChanged = false;
             info.GetSkillStateInfo().BuffChanged = false;
         }
         if (info.IsBorning)
         {
             if (info.BornTime <= 0)
             {
                 SkillInfo skillInfo = info.GetSkillStateInfo().GetSkillInfoById(info.BornSkillId);
                 if (info.BornSkillId > 0 && null != skillInfo)
                 {
                     info.BornTime = TimeUtility.GetLocalMilliseconds();
                     GfxSkillSystem.Instance.StartSkill(info.GetId(), skillInfo.ConfigData, 0);
                 }
                 else
                 {
                     info.IsBorning = false;
                     info.BornTime  = 0;
                     info.SetAIEnable(true);
                     info.SetStateFlag(Operate_Type.OT_RemoveBit, CharacterState_Type.CST_Invincible);
                 }
             }
             else if (info.BornTime + info.BornTimeout < TimeUtility.GetLocalMilliseconds())
             {
                 info.IsBorning = false;
                 info.BornTime  = 0;
                 info.SetAIEnable(true);
                 info.SetStateFlag(Operate_Type.OT_RemoveBit, CharacterState_Type.CST_Invincible);
             }
         }
         if (info.IsDead() && !info.NeedDelete)
         {
             if (info.CanDead)
             {
                 if (info.DeadTime <= 0)
                 {
                     SkillInfo skillInfo = info.GetSkillStateInfo().GetSkillInfoById(info.DeadSkillId);
                     if (info.DeadSkillId > 0 && null != skillInfo)
                     {
                         info.DeadTime = TimeUtility.GetLocalMilliseconds();
                         GfxSkillSystem.Instance.StopAllSkill(info.GetId(), true, false, true);
                         GfxSkillSystem.Instance.StartSkill(info.GetId(), skillInfo.ConfigData, 0);
                         OnEntityKilled(info);
                         EntityDrop(info); // 掉落
                     }
                     else
                     {
                         info.DeadTime   = 0;
                         info.NeedDelete = true;
                         OnEntityKilled(info);
                         EntityDrop(info); // 掉落
                     }
                 }
                 else if (info.DeadTime + info.DeadTimeout < TimeUtility.GetLocalMilliseconds())
                 {
                     info.DeadTime   = 0;
                     info.NeedDelete = true;
                 }
             }
             else
             {
                 info.CanDead = true;
             }
         }
         else
         {
             //每个tick复位CanDead,技能里需要鞭尸时应使用触发器每帧标记目标不可死亡(keeplive)
             info.CanDead = true;
         }
         if (info.NeedDelete)
         {
             m_DeletedEntities.Add(info);
         }
     }
     if (m_DeletedEntities.Count > 0)
     {
         int enemyCt  = 0;
         int friendCt = 0;
         for (int i = 0; i < m_DeletedEntities.Count; ++i)
         {
             EntityInfo ni = m_DeletedEntities[i];
             if (CharacterRelation.RELATION_ENEMY == EntityInfo.GetRelation(CampId, ni.GetCampId()))
             {
                 ++enemyCt;
             }
             else if (CharacterRelation.RELATION_FRIEND == EntityInfo.GetRelation(CampId, ni.GetCampId()))
             {
                 ++friendCt;
             }
             DestroyEntity(ni);
         }
         TryAllKilledOrAllDied(enemyCt > 0, friendCt > 0);
     }
 }
예제 #23
0
        internal void EnterScene(User newUser)
        {
            Msg_LR_RoomUserInfo lobbyUserData = newUser.LobbyUserData;

            if (null == lobbyUserData)
            {
                return;
            }
            TableConfig.Actor cfg  = TableConfig.ActorProvider.Instance.GetActor(lobbyUserData.Hero);
            EntityInfo        info = m_EntityMgr.AddEntity(0, lobbyUserData.Camp, cfg, (int)AiStateLogicId.Entity_Leader);

            info.SetUnitId(EntityInfo.c_StartUserUnitId + info.GetId());
            info.GetMovementStateInfo().FormationIndex = 0;
            if (null != m_SceneConfig)
            {
                info.GetMovementStateInfo().SetPosition2D(m_SceneConfig.EnterX + (Helper.Random.NextFloat() - 0.5f) * m_SceneConfig.EnterRadius, m_SceneConfig.EnterY + (Helper.Random.NextFloat() - 0.5f) * m_SceneConfig.EnterRadius);
            }
            newUser.Info = info;

            AttrCalculator.Calc(info);
            if (newUser.HaveHpArmor)
            {
                info.SetHp(Operate_Type.OT_Absolute, newUser.Hp);
                info.SetEnergy(Operate_Type.OT_Absolute, newUser.Energy);
            }
            else
            {
                info.SetHp(Operate_Type.OT_Absolute, newUser.Info.GetActualProperty().HpMax);
                info.SetEnergy(Operate_Type.OT_Absolute, newUser.Info.GetActualProperty().EnergyMax);
            }

            info.SceneContext = m_SceneContext;
            AddCareList(info);
            if (newUser.IsEntered)
            {
                m_StorySystem.SendMessage("user_enter_scene", info.GetId(), info.GetUnitId(), info.GetCampId(), info.GetMovementStateInfo().PositionX, info.GetMovementStateInfo().PositionZ);
            }
        }
예제 #24
0
        private void TickEntities()
        {
            m_DeletedEntities.Clear();
            for (LinkedListNode <EntityInfo> linkNode = m_EntityMgr.Entities.FirstNode; null != linkNode; linkNode = linkNode.Next)
            {
                EntityInfo info = linkNode.Value;
                info.RetireAttackerInfos(60000);
                if (info.LevelChanged || info.GetSkillStateInfo().BuffChanged)
                {
                    AttrCalculator.Calc(info);
                    info.LevelChanged = false;
                    info.GetSkillStateInfo().BuffChanged = false;
                }
                if (info.IsBorning)
                {
                    if (info.BornTime <= 0)
                    {
                        SkillInfo skillInfo = info.GetSkillStateInfo().GetSkillInfoById(info.BornSkillId);
                        if (info.BornSkillId > 0 && null != skillInfo)
                        {
                            info.BornTime = TimeUtility.GetLocalMilliseconds();
                        }
                        else
                        {
                            info.IsBorning = false;
                            info.BornTime  = 0;
                            info.SetAIEnable(true);
                            info.RemoveState(CharacterPropertyEnum.x3009_无敌);
                        }
                    }
                    else if (info.BornTime + info.BornTimeout < TimeUtility.GetLocalMilliseconds())
                    {
                        info.IsBorning = false;
                        info.BornTime  = 0;
                        info.SetAIEnable(true);
                        info.RemoveState(CharacterPropertyEnum.x3009_无敌);
                    }
                }
                if (info.IsDead() && !info.NeedDelete)
                {
                    if (info.DeadTime <= 0)
                    {
                        CalcKillIncome(info);
                        //发送npc死亡消息
                        Msg_RC_NpcDead npcDeadBuilder = new Msg_RC_NpcDead();
                        npcDeadBuilder.npc_id = info.GetId();
                        NotifyAllUser(RoomMessageDefine.Msg_RC_NpcDead, npcDeadBuilder);

                        SkillInfo skillInfo = info.GetSkillStateInfo().GetSkillInfoById(info.DeadSkillId);
                        if (info.DeadSkillId > 0 && null != skillInfo)
                        {
                            info.DeadTime = TimeUtility.GetLocalMilliseconds();
                            OnEntityKilled(info);
                        }
                        else
                        {
                            if (null == info.CustomData as User)
                            {
                                info.DeadTime   = 0;
                                info.NeedDelete = true;
                                OnEntityKilled(info);
                            }
                            else
                            {
                                info.DeadTime = TimeUtility.GetLocalMilliseconds();
                            }
                        }
                    }
                    else
                    {
                        if (null == info.CustomData as User && info.DeadTime + info.DeadTimeout < TimeUtility.GetLocalMilliseconds())
                        {
                            info.DeadTime   = 0;
                            info.NeedDelete = true;

                            //重新发送npc死亡消息
                            Msg_RC_NpcDead npcDeadBuilder = new Msg_RC_NpcDead();
                            npcDeadBuilder.npc_id = info.GetId();
                            NotifyAllUser(RoomMessageDefine.Msg_RC_NpcDead, npcDeadBuilder);
                        }
                        else if (null != info.CustomData as User && info.DeadTime + info.ReliveTimeout < TimeUtility.GetLocalMilliseconds())
                        {
                            info.DeadTime = 0;
                            info.Hp       = info.HpMax;
                            info.Energy   = info.EnergyMax;

                            Msg_RC_SyncProperty npcProp = DataSyncUtility.BuildSyncPropertyMessage(info);
                            NotifyAllUser(RoomMessageDefine.Msg_RC_SyncProperty, npcProp);
                        }
                    }
                }
                if (info.NeedDelete)
                {
                    m_DeletedEntities.Add(info);
                }
            }
            if (m_DeletedEntities.Count > 0)
            {
                int enemyCt  = 0;
                int friendCt = 0;
                Msg_RC_DestroyNpc destroyNpcBuilder = new Msg_RC_DestroyNpc();
                for (int i = 0; i < m_DeletedEntities.Count; ++i)
                {
                    EntityInfo ni = m_DeletedEntities[i];
                    if (CharacterRelation.RELATION_ENEMY == EntityInfo.GetRelation((int)CampIdEnum.Blue, ni.GetCampId()))
                    {
                        ++enemyCt;
                    }
                    else if (CharacterRelation.RELATION_FRIEND == EntityInfo.GetRelation((int)CampIdEnum.Blue, ni.GetCampId()))
                    {
                        ++friendCt;
                    }
                    //发送npc消失消息
                    destroyNpcBuilder.npc_id = ni.GetId();
                    NotifyAllUser(RoomMessageDefine.Msg_RC_DestroyNpc, destroyNpcBuilder);
                    DestroyEntity(ni);
                }
                TryAllKilledOrAllDied(enemyCt > 0, friendCt > 0);
            }
            m_EntityMgr.ExecuteDelayAdd();
        }
예제 #25
0
        //阵营可为Friendly、Hostile、Blue、Red
        //Friendly 全部友好
        //Hostile 全部敌对(同阵营友好)
        //Blue 与Hostile与Red敌对
        //Red 与Hostile与Blue敌对
        public static CharacterRelation GetRelation(EntityInfo pObj_A, EntityInfo pObj_B)
        {
            if (pObj_A == null || pObj_B == null) {
                return CharacterRelation.RELATION_INVALID;
            }

            if (pObj_A == pObj_B) {
                return CharacterRelation.RELATION_FRIEND;
            }

            int campA = pObj_A.GetCampId();
            int campB = pObj_B.GetCampId();
            CharacterRelation relation = GetRelation(campA, campB);
            return relation;
        }
예제 #26
0
 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;
 }
 internal int GetCampId(EntityInfo obj)
 {
     int campId = 0;
     if (null != obj) {
         campId = obj.GetCampId();
     }
     return campId;
 }
예제 #28
0
        internal int GetDyingBattleNpcCount(int campId, CharacterRelation relation)
        {
            int ct = 0;

            for (LinkedListNode <EntityInfo> linkNode = m_EntityManager.Entities.FirstValue; null != linkNode; linkNode = linkNode.Next)
            {
                EntityInfo info = linkNode.Value;
                if (null != info && info.IsDead() && info.DeadTime != 0 && info.IsCombatNpc() && EntityInfo.GetRelation(campId, info.GetCampId()) == relation)
                {
                    ++ct;
                }
            }
            return(ct);
        }
예제 #29
0
        public int GetDyingBattleNpcCount(int campId)
        {
            int ct = 0;

            for (LinkedListNode <EntityInfo> linkNode = m_EntityMgr.Entities.FirstNode; null != linkNode; linkNode = linkNode.Next)
            {
                EntityInfo info = linkNode.Value;
                if (null != info && info.IsDead() && info.DeadTime != 0 && info.IsCombatNpc() && info.GetCampId() == campId)
                {
                    ++ct;
                }
            }
            return(ct);
        }
 private static bool CanSee(EntityInfo src, EntityInfo target)
 {
     int srcCampId = src.GetCampId();
     int targetCampId = target.GetCampId();
     if (srcCampId == targetCampId)
         return true;
     else if (srcCampId == (int)CampIdEnum.Hostile || targetCampId == (int)CampIdEnum.Hostile) {
         return EntityInfo.CanSee(src, target);
     } else {
         return true;
     }
 }
예제 #31
0
        private void OnCreateEntity(EntityInfo entity)
        {
            if (null != entity)
            {
                GfxStorySystem.Instance.SendMessage("obj_created", entity.GetId());
                GfxStorySystem.Instance.SendMessage(string.Format("npc_created:{0}", entity.GetUnitId()), entity.GetId());

                bool isGreen = CharacterRelation.RELATION_FRIEND == EntityInfo.GetRelation(entity.GetCampId(), CampId);
                Utility.EventSystem.Publish("ui_add_actor", "ui", entity.GetId(), isGreen, entity.ConfigData);
            }
        }