Example #1
0
    public void Execute(GameCmd.stAddMapNpcAndPosMapScreenUserCmd_S cmd)
    {
        //AddNPC(cmd.data);
        Profiler.BeginSample("stAddMapNpcAndPosMapScreenUserCmd_S");
        EntityCreator.Instance().AddNPC(cmd.data, cmd.master_id);
        IEntitySystem es = ClientGlobal.Instance().GetEntitySystem();

        if (es == null)
        {
            Engine.Utility.Log.Error("严重错误:EntitySystem is null!");
            return;
        }
        uint userUID = ClientGlobal.Instance().MainPlayer.GetID();

        if (userUID == cmd.master_id && cmd.pet_id != 0)
        {
            DataManager.Manager <PetDataManager>().AddPetToNpc(cmd.pet_id, cmd.data.mapnpcdata.npcdata.dwTempID);
        }

        GameCmd.stNpcBelongListMapScreenUserCmd_S belongcmd = new GameCmd.stNpcBelongListMapScreenUserCmd_S();
        belongcmd.teamid = cmd.data.mapnpcdata.npcdata.owernteamid;
        belongcmd.userid = cmd.master_id;
        belongcmd.npcid  = cmd.data.mapnpcdata.npcdata.dwTempID;
        Execute(belongcmd);
        RoleStateBarManager.RefreshAllRoleBarHeadStatus(HeadStatusType.Hp);
        Profiler.EndSample();
    }
Example #2
0
    [Execute]//Npc归属人列表返回信息
    public void Execute(GameCmd.stNpcBelongListMapScreenUserCmd_S cmd)
    {
        IEntitySystem es = ClientGlobal.Instance().GetEntitySystem();

        if (es == null)
        {
            Engine.Utility.Log.Error("严重错误:EntitySystem is null!");
            return;
        }

        INPC npc = es.FindNPC(cmd.npcid);

        if (npc != null)
        {
            npc.OwnerID = cmd.userid;
            npc.TeamID  = cmd.teamid;
            bool belongOther = false;
            if (cmd.userid != 0)
            {
                if (cmd.userid != ClientGlobal.Instance().MainPlayer.GetID())
                {
                    belongOther = true;
                }
                else
                {
                    npc.BelongMe = true;
                }
            }
            if (!belongOther && (cmd.teamid != 0 || cmd.clanid != 0))
            {
                if (DataManager.Manager <TeamDataManager>().IsJoinTeam == true)
                {
                    if (DataManager.Manager <TeamDataManager>().TeamId != cmd.teamid)
                    {
                        belongOther = true;
                    }
                }
                else if (DataManager.Manager <ClanManger>().IsJoinClan == true)
                {
                    if (DataManager.Manager <ClanManger>().ClanId != cmd.clanid)
                    {
                        belongOther = true;
                    }
                }
                else
                {
                    belongOther = true;
                }
            }

            npc.BelongOther = belongOther;
            stEntityChangename e = new stEntityChangename();
            e.uid = npc.GetUID();
            Engine.Utility.EventEngine.Instance().DispatchEvent((int)Client.GameEventID.ENTITYSYSTEM_CHANGENAME, e);

            stRefreshNPCBelongParam param = new stRefreshNPCBelongParam()
            {
                npcid     = npc.GetUID(),
                teamid    = cmd.teamid,
                ownerid   = cmd.userid,
                clanid    = cmd.clanid,
                ownerName = cmd.ownername,
            };
            NpcAscription.Instance.OnBelongChanged(param);
            DataManager.Manager <UIPanelManager>().SendMsg(PanelID.MainPanel, UIMsgID.eRefreshNpcBelong, param);
        }
    }