IsDead() public méthode

public IsDead ( ) : bool
Résultat bool
        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);
                }
            }
        }
Exemple #2
0
        internal ImpactInfo TrackImpact(TableConfig.Skill cfg, int seq, int curObjId, int srcObjId, int targetId, string emitBone, int emitImpact, Vector3 offset, Dictionary <string, object> args)
        {
            EntityInfo targetObj = m_Scene.EntityManager.GetEntityInfo(targetId);
            EntityInfo srcObj    = m_Scene.EntityManager.GetEntityInfo(srcObjId);

            if (null != targetObj && !targetObj.IsDead())
            {
                if (null != cfg)
                {
                    ImpactInfo impactInfo = null;
                    if (emitImpact <= 0 || emitImpact >= SkillInstance.c_FirstInnerEmitSkillId)
                    {
                        impactInfo = new ImpactInfo(m_Scene.SkillSystem.PredefinedSkill.EmitSkillCfg);
                    }
                    else
                    {
                        impactInfo = new ImpactInfo(emitImpact);
                    }
                    if (TryInitImpactInfo(impactInfo, cfg, seq, curObjId, srcObjId, args))
                    {
                        if (null != srcObj)
                        {
                            Vector3 pos = srcObj.GetMovementStateInfo().GetPosition3D();
                            pos.Y += srcObj.GetRadius();
                            impactInfo.SenderPosition = pos;
                        }
                        targetObj.GetSkillStateInfo().AddImpact(impactInfo);
                        m_Scene.SkillSystem.StartSkill(targetId, impactInfo.ConfigData, impactInfo.Seq, args);
                        return(impactInfo);
                    }
                }
            }
            return(null);
        }
 protected override bool OnStateLogicCheck(EntityInfo npc, long deltaTime)
 {
     if (npc.IsDead()) {
         NotifyAiDead(npc);
         return false;
     }
     return true;
 }
 protected override bool OnStateLogicCheck(EntityInfo npc, long deltaTime)
 {
     if (npc.IsDead())
     {
         NotifyAiDead(npc);
         return(false);
     }
     return(true);
 }
 protected override bool OnStateLogicCheck(EntityInfo entity, long deltaTime)
 {
     if (entity.IsDead()) {
         if (entity.GetAiStateInfo().CurState != (int)AiStateId.Idle) {
             NotifyAiStopPursue(entity);
             ChangeToState(entity, (int)AiStateId.Idle);
         }
         return false;
     }
     return true;
 }
 protected override bool OnStateLogicCheck(EntityInfo entity, long deltaTime)
 {
     if (entity.IsDead())
     {
         if (entity.GetAiStateInfo().CurState != (int)AiStateId.Idle)
         {
             NotifyAiStopPursue(entity);
             ChangeToState(entity, (int)AiStateId.Idle);
         }
         return(false);
     }
     return(true);
 }
        public static EntityInfo GetLivingCharacterInfoHelper(EntityInfo srcObj, int id)
        {
            EntityInfo target = srcObj.EntityManager.GetEntityInfo(id);

            if (null != target)
            {
                if (target.IsDead())
                {
                    target = null;
                }
            }
            return(target);
        }
        private bool IsLeaderDead(EntityInfo entity)
        {
            bool           ret    = true;
            AiStateInfo    info   = entity.GetAiStateInfo();
            AiData_General data   = GetAiData(entity);
            EntityInfo     leader = AiLogicUtility.GetLivingCharacterInfoHelper(entity, info.LeaderID);

            if (null != leader)
            {
                ret = leader.IsDead();
            }
            return(ret);
        }
Exemple #9
0
        internal int GetBossCount()
        {
            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.EntityType == (int)EntityTypeEnum.Boss)
                {
                    ++ct;
                }
            }
            return(ct);
        }
Exemple #10
0
        internal int GetBattleNpcCount()
        {
            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())
                {
                    ++ct;
                }
            }
            return(ct);
        }
Exemple #11
0
        internal int GetBattleNpcCount(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.IsCombatNpc() && EntityInfo.GetRelation(campId, info.GetCampId()) == relation)
                {
                    ++ct;
                }
            }
            return(ct);
        }
Exemple #12
0
        internal int GetDyingBattleNpcCount(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.DeadTime != 0 && info.IsCombatNpc() && info.GetCampId() == campId)
                {
                    ++ct;
                }
            }
            return(ct);
        }
Exemple #13
0
        private void TickProperty()
        {
            for (LinkedListNode <EntityInfo> linkNode = EntityManager.Entities.FirstNode; null != linkNode; linkNode = linkNode.Next)
            {
                EntityInfo info = linkNode.Value;
                if (!info.IsDead() && info.PropertyChanged)
                {
                    info.PropertyChanged = false;

                    Msg_RC_SyncProperty builder = DataSyncUtility.BuildSyncPropertyMessage(info);
                    NotifyAllUser(RoomMessageDefine.Msg_RC_SyncProperty, builder);
                }
            }
        }
Exemple #14
0
        public int GetBattleNpcCount(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.IsCombatNpc() && info.GetCampId() == campId)
                {
                    ++ct;
                }
            }
            return(ct);
        }
Exemple #15
0
        public int GetBattleNpcCount(EntityInfo src, CharacterRelation relation)
        {
            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.IsCombatNpc() && EntityInfo.GetRelation(src, info) == relation)
                {
                    ++ct;
                }
            }
            return(ct);
        }
        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);
                }
            }
        }
 protected override bool OnStateLogicCheck(EntityInfo entity, long deltaTime)
 {
     if (entity.IsDead()) {
         if (entity.GetAiStateInfo().CurState != (int)AiStateId.Idle) {
             NotifyAiStopPursue(entity);
             ChangeToState(entity, (int)AiStateId.Idle);
         }
         return false;
     }
     if (IsLeaderDead(entity)) {
         entity.SetHp(Operate_Type.OT_Absolute, 0);
         return false;
     }
     return true;
 }
Exemple #18
0
        public bool HasCombatNpcAlive()
        {
            bool result = false;

            for (LinkedListNode <EntityInfo> linkNode = m_Entities.FirstValue; null != linkNode; linkNode = linkNode.Next)
            {
                EntityInfo entity = linkNode.Value;
                if (null != entity && entity.IsCombatNpc() && !entity.IsDead())
                {
                    result = true;
                    break;
                }
            }
            return(result);
        }
 protected override bool OnStateLogicCheck(EntityInfo entity, long deltaTime)
 {
     if (entity.IsDead())
     {
         if (entity.GetAiStateInfo().CurState != (int)AiStateId.Idle)
         {
             NotifyAiStopPursue(entity);
             ChangeToState(entity, (int)AiStateId.Idle);
         }
         return(false);
     }
     if (IsLeaderDead(entity))
     {
         entity.SetHp(Operate_Type.OT_Absolute, 0);
         return(false);
     }
     return(true);
 }
Exemple #20
0
        internal int GetNpcCount(int startUnitId, int endUnitId)
        {
            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())
                {
                    int unitId = info.GetUnitId();
                    if (unitId >= startUnitId && unitId <= endUnitId)
                    {
                        ++ct;
                    }
                }
            }
            return(ct);
        }
Exemple #21
0
        internal ImpactInfo TrackSendImpact(int targetId, int impactId, int seq, int impactToTarget, Dictionary <string, object> args)
        {
            EntityInfo targetObj = m_Scene.EntityManager.GetEntityInfo(targetId);

            if (null != targetObj && !targetObj.IsDead())
            {
                ImpactInfo trackImpactInfo = targetObj.GetSkillStateInfo().GetImpactInfoBySeq(seq);
                if (null != trackImpactInfo && impactId == trackImpactInfo.ImpactId)
                {
                    ImpactInfo impactInfo = null;
                    if (impactToTarget <= 0 || impactToTarget >= SkillInstance.c_FirstInnerHitSkillId)
                    {
                        impactToTarget = PredefinedSkill.c_HitSkillId;
                        impactInfo     = new ImpactInfo(m_Scene.SkillSystem.PredefinedSkill.HitSkillCfg);
                    }
                    var addArgs = new Dictionary <string, object>();
                    if (null == impactInfo)
                    {
                        impactInfo = new ImpactInfo(impactId);
                    }
                    impactInfo.StartTime      = TimeUtility.GetLocalMilliseconds();
                    impactInfo.ImpactSenderId = trackImpactInfo.ImpactSenderId;
                    impactInfo.SenderPosition = trackImpactInfo.SenderPosition;
                    impactInfo.SkillId        = trackImpactInfo.SkillId;
                    impactInfo.DurationTime   = trackImpactInfo.DurationTime > 0 ? trackImpactInfo.DurationTime : impactInfo.ConfigData.duration;
                    impactInfo.TargetType     = trackImpactInfo.TargetType;
                    impactInfo.DamageData.CopyFrom(trackImpactInfo.DamageData);
                    impactInfo.DamageData.Merge(impactInfo.ConfigData.damageData);
                    if (impactInfo.ConfigData.type == (int)SkillOrImpactType.Buff)
                    {
                        ImpactInfo oldImpactInfo = targetObj.GetSkillStateInfo().FindImpactInfoById(impactInfo.ImpactId);
                        if (null != oldImpactInfo)
                        {
                            oldImpactInfo.DurationTime += impactInfo.DurationTime;
                            return(oldImpactInfo);
                        }
                    }
                    targetObj.GetSkillStateInfo().AddImpact(impactInfo);
                    m_Scene.SkillSystem.StartSkill(targetId, impactInfo.ConfigData, impactInfo.Seq, args, addArgs);
                    return(impactInfo);
                }
            }
            return(null);
        }
        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);
        }
        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);
                }
            }
        }
        private static void StepCalcNearstTarget(EntityInfo srcObj, CharacterRelation relation, AiTargetType type, float powDist, EntityInfo obj, ref float minPowDist, ref EntityInfo nearstTarget)
        {
            EntityInfo target = GetSeeingLivingCharacterInfoHelper(srcObj, obj.GetId());

            if (null != target && !target.IsDead())
            {
                if (!target.IsTargetNpc())
                {
                    return;
                }
                if (type == AiTargetType.HERO && target.EntityType != (int)EntityTypeEnum.Hero)
                {
                    return;
                }
                if (type == AiTargetType.TOWER && target.EntityType != (int)EntityTypeEnum.Tower)
                {
                    return;
                }
                if (type == AiTargetType.BOSS && target.EntityType != (int)EntityTypeEnum.Boss)
                {
                    return;
                }
                if (type == AiTargetType.NPC && target.EntityType != (int)EntityTypeEnum.Normal)
                {
                    return;
                }
                if (relation == EntityInfo.GetRelation(srcObj, target))
                {
                    if (powDist < minPowDist)
                    {
                        if (powDist > c_MaxViewRangeSqr || CanSee(srcObj, target))
                        {
                            nearstTarget = target;
                            minPowDist   = powDist;
                        }
                    }
                }
            }
        }
Exemple #25
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();
        }
Exemple #26
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);
     }
 }
Exemple #27
0
        internal void ImpactDamage(int srcObjId, int targetId, int impactId, int seq)
        {
            EntityInfo targetObj = m_Scene.EntityManager.GetEntityInfo(targetId);
            EntityInfo srcObj    = m_Scene.EntityManager.GetEntityInfo(srcObjId);

            if (null != targetObj && !targetObj.IsDead())
            {
                ImpactInfo impactInfo = targetObj.GetSkillStateInfo().GetImpactInfoBySeq(seq);
                if (null != impactInfo && impactId == impactInfo.ImpactId)
                {
                    TableConfig.Skill cfg = impactInfo.ConfigData;
                    int   targetType      = impactInfo.TargetType;
                    float damage          = impactInfo.DamageData.Damage;
                    int   addShield       = impactInfo.DamageData.AddShield;
                    int   hpRecover       = impactInfo.DamageData.HpRecover;

                    if (hpRecover != 0)
                    {
                        targetObj.SetHp(Operate_Type.OT_Relative, (int)impactInfo.DamageData.HpRecover);
                        targetObj.SetAttackerInfo(srcObjId, false, true, false, -impactInfo.DamageData.HpRecover, 0);
                    }
                    if (addShield != 0)
                    {
                        targetObj.SetShield(Operate_Type.OT_Relative, impactInfo.DamageData.AddShield);
                    }
                    if ((targetType == (int)SkillTargetType.Enemy || targetType == (int)SkillTargetType.RandEnemy) && damage != 0)
                    {
                        if (targetObj.EntityType == (int)EntityTypeEnum.Tower)
                        {
                            if (null != srcObj && srcObj.NormalSkillId != impactInfo.SkillId)
                            {
                                //技能打塔不产生伤害
                                return;
                            }
                        }
                        bool isKiller = false;
                        if (targetObj.Shield >= damage)
                        {
                            targetObj.SetShield(Operate_Type.OT_Relative, -(int)damage);
                        }
                        else if (targetObj.Shield > 0)
                        {
                            int leftDamage = (int)damage - targetObj.Shield;
                            targetObj.SetShield(Operate_Type.OT_Absolute, 0);
                            targetObj.SetHp(Operate_Type.OT_Relative, -(int)leftDamage);
                            if (targetObj.Hp <= 0)
                            {
                                isKiller = true;
                            }
                        }
                        else
                        {
                            targetObj.SetHp(Operate_Type.OT_Relative, -(int)damage);
                            if (targetObj.Hp <= 0)
                            {
                                isKiller = true;
                            }
                        }
                        if (isKiller)
                        {
                            targetObj.GetCombatStatisticInfo().AddDeadCount(1);
                            if (null != srcObj)
                            {
                                EntityInfo killer = srcObj;
                                if (killer.SummonerId > 0)
                                {
                                    killer = m_Scene.EntityManager.GetEntityInfo(killer.SummonerId);
                                }
                                if (targetObj.EntityType == (int)EntityTypeEnum.Tower)
                                {
                                    killer.GetCombatStatisticInfo().AddKillTowerCount(1);
                                }
                                else if (targetObj.EntityType == (int)EntityTypeEnum.Hero)
                                {
                                    killer.GetCombatStatisticInfo().AddKillHeroCount(1);
                                    killer.GetCombatStatisticInfo().AddMultiKillCount(1);
                                }
                                else
                                {
                                    killer.GetCombatStatisticInfo().AddKillNpcCount(1);
                                }
                            }
                        }
                        targetObj.SetAttackerInfo(srcObjId, isKiller, true, false, (int)damage, 0);
                    }
                }
            }
        }
        public bool SkillCanFindTarget(int objId, int skillId)
        {
            bool       ret = false;
            EntityInfo obj = GetEntityById(objId);

            if (null != obj)
            {
                SkillInfo skillInfo = obj.GetSkillStateInfo().GetSkillInfoById(skillId);
                if (null != skillInfo)
                {
                    bool find = false;
                    KdTree.QueryWithFunc(obj, skillInfo.Distance, (float distSqr, KdTreeObject _obj) => {
                        EntityInfo target = _obj.Object;
                        if (CharacterRelation.RELATION_ENEMY == EntityInfo.GetRelation(obj, target) && !target.IsDead())
                        {
                            find = true;
                            return(false);
                        }
                        return(true);
                    });
                    ret = find;
                }
            }
            return(ret);
        }