Esempio n. 1
0
    internal static void Execute(object msg, NetConnection conn)
    {
        Msg_RC_DestroyNpc destroyMsg = msg as Msg_RC_DestroyNpc;

        if (destroyMsg == null)
        {
            return;
        }
        EntityInfo info = PluginFramework.Instance.GetEntityById(destroyMsg.npc_id);

        if (null == info)
        {
            LogSystem.Info("NpcDestroy can't find obj:" + destroyMsg.npc_id);
            return;
        }
        LogSystem.Info("NpcDestroy:" + destroyMsg.npc_id);

        EntityInfo npc = info;

        if (null != npc)
        {
            EntityViewModelManager.Instance.DestroyEntityView(npc.GetId());
            PluginFramework.Instance.DestroyEntityById(npc.GetId());
        }
    }
Esempio n. 2
0
    internal static void Execute(object msg, NetConnection conn, NetworkSystem networkSystem)
    {
        Msg_RC_DestroyNpc destroyMsg = msg as Msg_RC_DestroyNpc;

        if (destroyMsg == null)
        {
            return;
        }
        List <int> ownedNpcs = networkSystem.Robot.OwnedNpcs;

        ownedNpcs.Remove(destroyMsg.npc_id);
        List <int> otherIds = networkSystem.Robot.OtherIds;

        otherIds.Remove(destroyMsg.npc_id);
    }
        internal void DestroyEntities(int[] unit_ids)
        {
            Msg_RC_DestroyNpc destroyNpcBuilder = new Msg_RC_DestroyNpc();

            for (int i = 0; i < unit_ids.Length; i++)
            {
                NpcInfo npc = NpcManager.GetNpcInfoByUnitId(unit_ids[i]);
                if (npc != null)
                {
                    destroyNpcBuilder.npc_id = npc.GetId();
                    NotifyAllUser(destroyNpcBuilder);
                    NpcManager.RemoveNpc(npc.GetId());
                }
            }
        }
        public void DestroyEntities(int[] unit_ids)
        {
            Msg_RC_DestroyNpc destroyNpcBuilder = new Msg_RC_DestroyNpc();

            for (int i = 0; i < unit_ids.Length; i++)
            {
                EntityInfo npc = EntityManager.GetEntityInfoByUnitId(unit_ids[i]);
                if (npc != null)
                {
                    destroyNpcBuilder.npc_id = npc.GetId();
                    NotifyAllUser(RoomMessageDefine.Msg_RC_DestroyNpc, destroyNpcBuilder);
                    EntityManager.RemoveEntity(npc.GetId());
                }
            }
        }
Esempio n. 5
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();
        }
Esempio n. 6
0
        private void TickNpcs()
        {
            List <NpcInfo> deletes        = new List <NpcInfo>();
            List <NpcInfo> deletes2       = new List <NpcInfo>();
            Msg_RC_NpcDead npcDeadBuilder = new Msg_RC_NpcDead();

            for (LinkedListNode <NpcInfo> linkNode = NpcManager.Npcs.FirstValue; null != linkNode; linkNode = linkNode.Next)
            {
                NpcInfo info = linkNode.Value;
                if (info.LevelChanged || info.GetSkillStateInfo().BuffChanged || info.GetEquipmentStateInfo().EquipmentChanged || info.GetLegacyStateInfo().LegacyChanged)
                {
                    NpcAttrCalculator.Calc(info);
                    info.LevelChanged = false;
                    info.GetSkillStateInfo().BuffChanged          = false;
                    info.GetEquipmentStateInfo().EquipmentChanged = false;
                    info.GetLegacyStateInfo().LegacyChanged       = false;
                }
                // 伙伴自动掉血
                if ((int)NpcTypeEnum.Partner == info.NpcType)
                {
                    UserInfo owner = UserManager.GetUserInfo(info.OwnerId);
                    if (null != owner)
                    {
                        PartnerInfo pi = owner.GetPartnerInfo();
                        if (null != pi && TimeUtility.GetServerMilliseconds() - pi.LastTickTime > pi.TickInterval)
                        {
                            info.SetHp(Operate_Type.OT_Relative, (int)pi.GetHpCostPerTick(info.GetActualProperty().HpMax));
                            pi.LastTickTime = TimeUtility.GetServerMilliseconds();
                        }
                    }
                }
                if (info.NeedDelete)
                {
                    deletes2.Add(info);
                }
                else if (info.IsDead())
                {
                    if (info.DeadTime <= 0)
                    {
                        info.DeadTime = TimeUtility.GetServerMilliseconds();
                        //击杀收益计算
                        CalcKillIncome(info);
                        //解除控制
                        ReleaseControl(info);
                        //发送npc死亡消息
                        npcDeadBuilder.npc_id = info.GetId();
                        NotifyAllUser(npcDeadBuilder);

                        if (info.IsCombatNpc())
                        {
                            m_StorySystem.SendMessage("objkilled", info.GetId(), GetBattleNpcCount());
                            m_StorySystem.SendMessage(string.Format("npckilled:{0}", info.GetUnitId()), info.GetId(), GetBattleNpcCount());
                            if (info.GetUnitId() > 0)
                            {
                                if (m_IsAttemptScene)
                                {
                                    if ((int)NpcTypeEnum.BigBoss == info.NpcType)
                                    {
                                        TryFireAllNpcKilled();
                                    }
                                }
                                else
                                {
                                    TryFireAllNpcKilled();
                                }
                            }
                        }
                    }
                    else if (TimeUtility.GetServerMilliseconds() - info.DeadTime > info.ReleaseTime && info.GfxDead)
                    {
                        deletes.Add(info);
                    }
                }
                if (info.IsBorning && IsNpcBornOver(info))
                {
                    info.IsBorning = false;
                    info.SetAIEnable(true);
                    info.SetStateFlag(Operate_Type.OT_RemoveBit, CharacterState_Type.CST_Invincible);
                }
                CheckNpcOwnerId(info);
            }
            if (deletes.Count > 0)
            {
                Msg_RC_DestroyNpc destroyNpcBuilder = new Msg_RC_DestroyNpc();
                foreach (NpcInfo ni in deletes)
                {
                    //发送npc消失消息
                    destroyNpcBuilder.npc_id           = ni.GetId();
                    destroyNpcBuilder.need_play_effect = true;
                    NotifyAllUser(destroyNpcBuilder);
                    //删除npc
                    NpcManager.RemoveNpc(ni.GetId());
                    LogSystem.Debug("Npc {0}  name {1} is deleted.", ni.GetId(), ni.GetName());
                }
            }
            if (deletes2.Count > 0)
            {
                Msg_RC_DestroyNpc destroyNpcBuilder = new Msg_RC_DestroyNpc();
                foreach (NpcInfo ni in deletes2)
                {
                    //发送npc消失消息
                    destroyNpcBuilder.npc_id           = ni.GetId();
                    destroyNpcBuilder.need_play_effect = false;
                    NotifyAllUser(destroyNpcBuilder);
                    //删除npc
                    NpcManager.RemoveNpc(ni.GetId());
                    LogSystem.Debug("Npc {0}  name {1} is deleted.", ni.GetId(), ni.GetName());
                }
            }
            NpcManager.ExecuteDelayAdd();
        }