public void Excute(GameCmd.stBatchRemoveNpcMapScreenUserCmd_S cmd) { Profiler.BeginSample("stBatchRemoveNpcMapScreenUserCmd_S"); IEntitySystem es = ClientGlobal.Instance().GetEntitySystem(); if (es == null) { Engine.Utility.Log.Error("严重错误:EntitySystem is null!"); return; } for (int i = 0; i < cmd.id.Count; ++i) { EntityCreator.Instance().RemoveNPC(cmd.id[i]); // Engine.Utility.Log.LogGroup( "ZDY" , "stBatchRemoveNpcMapScreenUserCmd_S remove entity ----------------" + cmd.id[i] ); IEntity npc = es.FindNPC(cmd.id[i]); if (npc == null) { npc = es.FindRobot(cmd.id[i]); } if (npc != null) { long uid = npc.GetUID(); Client.stRemoveEntity removeEntiy = new Client.stRemoveEntity(); removeEntiy.uid = uid; Engine.Utility.EventEngine.Instance().DispatchEvent((int)GameEventID.ENTITYSYSTEM_REMOVEENTITY, removeEntiy); NpcAscription.Instance.OnRemoveBelongData(uid); } es.RemoveEntity(npc); } Profiler.EndSample(); }
/// <summary> /// 移除npc身上特效 /// </summary> /// <param name="npcId"></param> public bool RemoveCollectNpcEffectByNpcId(uint npcId) { List <int> linkIdList; if (m_dicCollectNpcEffectLinkId.TryGetValue(npcId, out linkIdList)) { IEntitySystem es = ClientGlobal.Instance().GetEntitySystem(); if (es == null) { return(false); } INPC npc = es.FindNPC(npcId); if (npc == null) { return(false); } for (int i = 0; i < linkIdList.Count; i++) { EntitySystem.EntityHelper.RemoveEffect(npc, linkIdList[i]); } return(true); } return(false); }
public void Execute(GameCmd.stNpcMoveMoveUserCmd cmd) { IEntitySystem es = ClientGlobal.Instance().GetEntitySystem(); if (es == null) { Engine.Utility.Log.Error("严重错误:EntitySystem is null!"); return; } MapVector2 mapPos = MapVector2.FromCoordinate(cmd.dst_x, cmd.dst_y); Vector3 pos = new Vector3(mapPos.x, 0, -mapPos.y); // 服务器到客户端坐标转换 IEntity en = null; en = es.FindNPC(cmd.dwNpcTempID); if (en == null) { //Engine.Utility.Log.Info("机器人 移动pos {0}", pos); en = es.FindRobot(cmd.dwNpcTempID); } if (en != null) { Engine.Utility.Log.LogGroup("XXF", "{0}Move to{1},{2}", en.GetName(), pos.x, pos.z); Move move = new Move(); //move.m_dir = Global.S2CDirection(cmd.dir); move.strRunAct = EntityAction.Run; // 动作名需要统一处理 move.m_target = pos; move.m_speed = en.GetProp((int)WorldObjProp.MoveSpeed) * EntityConst.MOVE_SPEED_RATE; // Log.Error( "npc pos is" + pos.ToString() ); en.SendMessage(EntityMessage.EntityCommand_MoveTo, (object)move); } }
void ChangePetBody(uint suitID, uint petID) { PetDataManager pm = DataManager.Manager <PetDataManager>(); if (pm != null) { //if (pm.CurFightingPet != 0) { IEntitySystem es = ClientGlobal.Instance().GetEntitySystem(); if (es != null) { INPC npc = es.FindNPC(petID); if (npc != null) { if (suitID != 0) { SuitDataBase sdb = GameTableManager.Instance.GetTableItem <SuitDataBase>(suitID, 1); if (sdb != null) { Client.ChangeBody cb = new Client.ChangeBody(); cb.resId = (int)sdb.resid; cb.modleScale = sdb.sceneModleScale; npc.SendMessage(EntityMessage.EntityCommand_Change, cb); } } else { npc.SendMessage(EntityMessage.EntityCommand_Restore); } } } } } }
public void AddNPC(t_MapNpcDataPos data, uint master_id) { Profiler.BeginSample("AddNpc"); if (data == null) { return; } Engine.Utility.Log.Trace("添加NPC:{0}", data.mapnpcdata.npcdata.dwBaseID); IEntitySystem es = ClientGlobal.Instance().GetEntitySystem(); if (es == null) { Engine.Utility.Log.Error("严重错误:EntitySystem is null!"); return; } table.NpcDataBase npctable = GameTableManager.Instance.GetTableItem <table.NpcDataBase>((uint)data.mapnpcdata.npcdata.dwBaseID); if (npctable == null) { Engine.Utility.Log.Error("严重错误:not fount npc baseid {0}", data.mapnpcdata.npcdata.dwBaseID); return; } if (npctable.dwType == (uint)GameCmd.enumNpcType.NPC_TYPE_ROBOT) { if (es.FindRobot(data.mapnpcdata.npcdata.dwTempID) != null) { CreateRobot(data, npctable.job); // 更新数据 return; } if (m_dicNPCData.ContainsKey(data.mapnpcdata.npcdata.dwTempID)) { return; } CreateRobot(data, npctable.job); } else { if (es.FindNPC(data.mapnpcdata.npcdata.dwTempID) != null) { CreateNPC(data, master_id); // 更新数据 return; } if (m_dicNPCData.ContainsKey(data.mapnpcdata.npcdata.dwTempID)) { return; } CreateNPC(data, master_id); } Profiler.EndSample(); }
public INPC GetNpcByPetID(uint petID) { uint npcID = GetNpcIDByPetID(petID); IEntitySystem es = ClientGlobal.Instance().GetEntitySystem(); if (es == null) { Engine.Utility.Log.Error("严重错误:EntitySystem is null!"); return(null); } INPC npc = es.FindNPC(npcID); return(npc); }
public void OnChangeNpcName(stBroadCastNamePetUserCmd_S cmd) { if (cmd != null) { IEntitySystem es = ClientGlobal.Instance().GetEntitySystem(); if (es == null) { Engine.Utility.Log.Error("严重错误:EntitySystem is null!"); return; } INPC npc = es.FindNPC(cmd.id); if (npc != null) { npc.SendMessage(EntityMessage.EntityCommond_SetName, cmd.name); } } }
/// <summary> /// 为采集物添加特效 /// </summary> /// <param name="npcId">npcId</param> /// <param name="effectId">特效ID</param> public void AddCollectNpcEffect(uint npcId, int effectId) { IEntitySystem es = ClientGlobal.Instance().GetEntitySystem(); if (es == null) { return; } INPC npc = es.FindNPC(npcId); if (npc == null) { return; } List <int> effectIdList; if (m_dicCollectNpcEffectId.TryGetValue(npcId, out effectIdList)) { if (false == effectIdList.Contains(effectId)) { effectIdList.Add(effectId); List <int> linkIdList; if (m_dicCollectNpcEffectLinkId.TryGetValue(npcId, out linkIdList)) { int linkId = EntitySystem.EntityHelper.AddEffect(npc, effectId); linkIdList.Add(linkId); } } } else { effectIdList = new List <int>(); effectIdList.Add(effectId); m_dicCollectNpcEffectId.Add(npcId, effectIdList); int linkId = EntitySystem.EntityHelper.AddEffect(npc, effectId); List <int> linkIdList = new List <int>(); linkIdList.Add(linkId); m_dicCollectNpcEffectLinkId.Add(npcId, linkIdList); } }
IEntity GetEntity(uint id, EntityType type) { IEntitySystem es = ClientGlobal.Instance().GetEntitySystem(); if (es == null) { return(null); } IEntity entity = null; switch (type) { case EntityType.EntityType_Item: entity = es.FindItem(id); break; case EntityType.EntityType_Monster: entity = es.FindMonster(id); break; case EntityType.EntityType_NPC: { entity = es.FindNPC(id); if (entity == null) { entity = es.FindRobot(id); } } break; case EntityType.EntityType_Player: entity = es.FindPlayer(id); break; case EntityType.EntityType_Puppet: entity = es.FindPuppet(id); break; default: break; } return(entity); }
public void Excute(GameCmd.stRemoveMapNpcMapScreenUserCmd_S cmd) { Profiler.BeginSample("stRemoveMapNpcMapScreenUserCmd_S"); //RemoveNpc(cmd.dwTempID); IEntitySystem es = ClientGlobal.Instance().GetEntitySystem(); if (es == null) { Engine.Utility.Log.Error("严重错误:EntitySystem is null!"); return; } { EntityCreator.Instance().RemoveNPC(cmd.dwTempID); //Engine.Utility.Log.LogGroup( "ZDY" , "single remove entity ----------------" + cmd.dwTempID ); //PetDataManager petData = DataManager.Manager<PetDataManager>(); //if(petData.NpcIsPet(cmd.dwTempID)) //{ // petData.OnPetDead( cmd.dwTempID ); //} IEntity npc = es.FindNPC(cmd.dwTempID); if (npc == null) { npc = es.FindRobot(cmd.dwTempID); } if (npc != null) { long uid = npc.GetUID(); Client.stRemoveEntity removeEntiy = new Client.stRemoveEntity(); removeEntiy.uid = uid; Engine.Utility.EventEngine.Instance().DispatchEvent((int)GameEventID.ENTITYSYSTEM_REMOVEENTITY, removeEntiy); NpcAscription.Instance.OnRemoveBelongData(uid); } es.RemoveEntity(npc); } Profiler.EndSample(); }
public void Execute(GameCmd.stChangeMoveSpeedDataUserCmd_S cmd) { IEntitySystem es = ClientGlobal.Instance().GetEntitySystem(); if (es == null) { Engine.Utility.Log.Error("严重错误:EntitySystem is null!"); return; } switch (cmd.type) { case (uint)SceneEntryType.SceneEntry_NPC: { INPC npc = es.FindNPC(cmd.id); if (npc != null) { npc.SetProp((int)WorldObjProp.MoveSpeed, (int)cmd.mvspd); npc.SendMessage(EntityMessage.EntityCommand_SetAniSpeed, (object)1.0f); } } break; case (uint)SceneEntryType.SceneEntry_Player: { IPlayer player = es.FindPlayer(cmd.id); if (player != null) { player.SetProp((int)WorldObjProp.MoveSpeed, (int)cmd.mvspd); player.SendMessage(EntityMessage.EntityCommand_SetAniSpeed, (object)1.0f); } } break; default: break; } }
[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); } }
//------------------------------------------------------------------------------------------------ private void CreateNPC(GameCmd.t_MapNpcDataPos npcdata, uint master_id) { Profiler.BeginSample("CreateNPC"); IEntitySystem es = ClientGlobal.Instance().GetEntitySystem(); if (es == null) { Engine.Utility.Log.Error("严重错误:EntitySystem is null!"); return; } //MapVector2 mapPos = MapVector2.FromCoordinate(npcdata.cur_pos.x * 0.01f, npcdata.cur_pos*0.01f); Vector3 pos = new Vector3(npcdata.cur_pos.x * 0.01f, 0, -npcdata.cur_pos.y * 0.01f); // 服务器到客户端坐标转换 EntityCreateData data = RoleUtil.BuildCreateEntityData(EntityType.EntityType_NPC, npcdata, master_id); INPC npc = es.FindNPC(npcdata.mapnpcdata.npcdata.dwTempID); if (npc != null) { npc.UpdateProp(data); NpcAscription.Instance.UpdateBelong(npc, npcdata.mapnpcdata.npcdata.owernuserid, npcdata.mapnpcdata.npcdata.owernteamid, npcdata.mapnpcdata.npcdata.owernclanid, npcdata.mapnpcdata.npcdata.ownername); } else { npc = es.CreateEntity(EntityType.EntityType_NPC, data, !m_bDelayLoad) as INPC; // 发送事件 CreateEntity if (npc != null) { NpcAscription.Instance.UpdateBelong(npc, npcdata.mapnpcdata.npcdata.owernuserid, npcdata.mapnpcdata.npcdata.owernteamid, npcdata.mapnpcdata.npcdata.owernclanid, npcdata.mapnpcdata.npcdata.ownername); table.NpcDataBase npctable = GameTableManager.Instance.GetTableItem <table.NpcDataBase>((uint)npcdata.mapnpcdata.npcdata.dwBaseID); if (npctable != null) { //Debug.LogError("********** npctable.dwID = " + npctable.dwID); if (npcdata.mapnpcdata.npcdata.arenanpctype == ArenaNpcType.ArenaNpcType_Player)//离线的真实玩家名字,用服务器的 { npc.SendMessage(EntityMessage.EntityCommond_SetName, npcdata.mapnpcdata.npcdata.name); } else { if (string.IsNullOrEmpty(npcdata.mapnpcdata.npcdata.name)) { npc.SendMessage(EntityMessage.EntityCommond_SetName, npctable.strName); } } if (npctable.dwType == (uint)GameCmd.enumNpcType.NPC_TYPE_TRANSFER)//传送阵 { EntityOnTrigger callback = new EntityOnTrigger(); npc.SetCallback(callback); } } if (npc != null) { PlayAni anim_param = new PlayAni(); anim_param.strAcionName = EntityAction.Stand; anim_param.fSpeed = 1; anim_param.nStartFrame = 0; anim_param.nLoop = -1; anim_param.fBlendTime = 0.2f; npc.SendMessage(EntityMessage.EntityCommand_PlayAni, anim_param); } } } if (npc != null) { npc.SendMessage(EntityMessage.EntityCommand_SetPos, (object)pos); Vector3 rot = GameUtil.S2CDirection(npcdata.mapnpcdata.npcdata.byDirect); npc.SendMessage(EntityMessage.EntityCommand_SetRotate, (object)rot); IBuffPart buffpart = npc.GetPart(EntityPart.Buff) as IBuffPart; if (buffpart != null) { buffpart.ReceiveBuffList(npcdata.mapnpcdata.statelist.data); } } Profiler.EndSample(); }