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 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); } } }
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; } }
public void Execuete(GameCmd.stReturnObjectPosMagicUserCmd_S cmd) { //冲锋应该是goto 瞬移应该是enumMoveType_Immediate 此处待后台修改 前台先山寨一下 if (cmd.byMoveType == stReturnObjectPosMagicUserCmd_S.enumMoveType.enumMoveType_GoTo || cmd.byMoveType == stReturnObjectPosMagicUserCmd_S.enumMoveType.enumMoveType_Immediate) { IEntitySystem es = ClientGlobal.Instance().GetEntitySystem(); if (es == null) { Engine.Utility.Log.Error("GetEntitySystem failed!"); return; } stEntryPosition userPos = cmd.userpos; if (userPos != null) { IEntity player = es.FindEntity <IPlayer>(userPos.dwTempID); if (player != null) { //MapVector2 mapPos = MapVector2.FromCoordinate(userPos.x, userPos.y); Vector3 pos = new Vector3(userPos.cur_pos.x * 0.01f, 0, -userPos.cur_pos.y * 0.01f); // 服务器到客户端坐标转换 ISkillPart skillPart = SkillHelper.GetSkillPart(userPos.dwTempID, EntityType.EntityType_Player); if (skillPart != null) { if (skillPart.IsFastMove()) { Move move = new Move(); move.m_target = pos; move.m_ignoreStand = true; player.SendMessage(EntityMessage.EntityCommand_MoveTo, (object)move); } else { //不是在释放快速移动技能 立刻设置位置 否则延迟设置 player.SendMessage(EntityMessage.EntityCommand_SetPos, (object)pos); //Vector3 rot = GameUtil.S2CDirection(userPos.byDir); //player.SendMessage(EntityMessage.EntityCommand_SetRotate, (object)rot); } IEntity skillTarget = skillPart.GetSkillTarget(); if (skillTarget != null && skillTarget.GetUID() != player.GetUID()) { SkillDatabase db = skillPart.GetCurSkillDataBase(); if (db != null) { if (db.targetType == (int)SkillTargetType.TargetForwardPoint) { return; } } player.SendMessage(EntityMessage.EntityCommand_LookTarget, skillTarget.GetPos()); } } } } if (cmd.npcpos != null) { INPC npc = es.FindEntity <INPC>(cmd.npcpos.dwTempID); if (npc != null) { //MapVector2 mapPos = MapVector2.FromCoordinate(cmd.npcpos.x, cmd.npcpos.y); Vector3 pos = new Vector3(cmd.npcpos.cur_pos.x * 0.01f, 0, -cmd.npcpos.cur_pos.y * 0.01f); // 服务器到客户端坐标转换 ISkillPart skillPart = SkillHelper.GetSkillPart(cmd.npcpos.dwTempID, EntityType.EntityType_NPC); if (skillPart != null) { //不是在释放快速移动技能 立刻设置位置 否则延迟设置 npc.SendMessage(EntityMessage.EntityCommand_StopMove, (object)pos); } } } EventEngine.Instance().DispatchEvent((int)GameEventID.CAMERA_MOVE_END); } }
//------------------------------------------------------------------------------------------------ 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(); }