void RPC_S2C_MonsterBook(uLink.BitStream stream, uLink.NetworkMessageInfo info)
    {
        bool ownerData = stream.Read <bool>();

        if (ownerData)
        {
            MonsterHandbookData.Deserialize(stream.Read <byte[]>());
        }
        else
        {
            MonsterHandbookData.AddMhByKilledMonsterID(stream.Read <int>());
        }
    }
Exemplo n.º 2
0
    void OnEntityDeath(SkEntity entity, SkEntity caster)
    {
        CommonCmpt common = entity.GetComponent <CommonCmpt>();

        if (common != null)
        {
            if (common.entityProto.proto == EEntityProto.Doodad)
            {
                DestroyEntity(entity, 30.0f);
            }

            if (common.entityProto.proto == EEntityProto.Monster)
            {
                MonsterHandbookData.AddMhByKilledMonsterID(common.entityProto.protoId);
                if (common.GetComponent <TowerCmpt>() == null)
                {
                    float    reviveTime = 10;
                    PeEntity mon        = entity.GetComponent <PeEntity>();
                    if (mon != null)
                    {
                        if (StroyManager.Instance != null)
                        {
                            if (StroyManager.Instance.m_RecordKillMons.Count != 0)
                            {
                                foreach (var item in StroyManager.Instance.m_RecordKillMons.Values)
                                {
                                    if (item.type == KillMons.Type.fixedId && SceneEntityCreatorArchiver.Instance.GetEntityByFixedSpId(item.monId) == mon)
                                    {
                                        reviveTime = (item.reviveTime == 0 ? reviveTime : item.reviveTime);
                                        break;
                                    }
                                    else if (item.type == KillMons.Type.protoTypeId && Vector3.Distance(mon.position, item.center) <= item.radius &&
                                             (item.monId == -999 ? true : common.entityProto.protoId == item.monId))
                                    {
                                        reviveTime = (item.reviveTime == 0 ? reviveTime : item.reviveTime);
                                        break;
                                    }
                                }
                            }
                        }
                    }
                    DestroyEntity(entity, reviveTime);
                }
            }

            NpcCmpt npc = entity.GetComponent <NpcCmpt>();
            if (common.entityProto.proto == EEntityProto.Npc)
            {
                if (GameUI.Instance != null)
                {
                    if (GameUI.Instance.mNpcWnd.IsOpen() && GameUI.Instance.mNpcWnd.m_CurSelNpc.commonCmpt == common)
                    {
                        GameUI.Instance.mNpcWnd.Hide();
                    }
                }
                if (npc != null && npc.Type != ENpcType.Follower && npc.ReviveTime > 0)
                {
                    ReviveEntity(entity, 10.0f);
                }
                if (npc.ReviveTime <= 0)
                {
                    PeEntity npcentity = npc.GetComponent <PeEntity>();
                    if (MissionManager.Instance != null && MissionManager.Instance.m_PlayerMission != null)
                    {
                        MissionManager.Instance.m_PlayerMission.SetMissionState(npcentity, NpcMissionState.Max);
                    }

                    NpcMissionData missionData = npcentity.GetUserData() as NpcMissionData;
                    if (missionData != null)
                    {
                        missionData.m_MissionList.Clear();
                    }
                }
            }
            else if (common.entityProto.proto == EEntityProto.RandomNpc)
            {
                if (npc != null && !npc.IsServant)
                {
                    if (npc.ReviveTime > 0)
                    {
                        if (PeGameMgr.IsMultiStory)
                        {
                            if (entity._net is AiAdNpcNetwork)
                            {
                                int tempid            = ((AiAdNpcNetwork)(entity._net)).ExternId;
                                RandomNpcDb.Item item = RandomNpcDb.Get(tempid);
                                if (item != null)
                                {
                                    if (item.reviveTime != -1)
                                    {
                                        ReviveEntity(entity, item.reviveTime);
                                    }
                                }
                            }
                        }
                        else
                        {
                            ReviveEntity(entity, npc.ReviveTime);
                        }
                    }
                }

                //follower revive
//				if (npc != null && npc.IsServant)
//				{
//					ReviveEntity(entity, npc.ReviveTime + npc.FollowerReviceTime);
//				}
            }
        }
    }