public void CancleBuffState(stCancelStateIcoListMagicUserCmd_S cmd) { BuffDataBase db = GameTableManager.Instance.GetTableItem <BuffDataBase>(cmd.wdState); if (db != null) { IEntitySystem es = ClientGlobal.Instance().GetEntitySystem(); if (es == null) { Engine.Utility.Log.Error("GetEntitySystem failed!"); } IEntity entity = EntitySystem.EntityHelper.GetEntity(cmd.byType, cmd.dwTempID); if (entity == null) { Engine.Utility.Log.Error("es.FindEntity useid is !" + cmd.dwTempID.ToString()); } else { Log.LogGroup("ZDY", "取消{0}身上的buff {1}===========", db.strName, entity.GetName()); } } else { Log.Error("找不到buff ===========" + cmd.wdState); } IBuffPart bp = GetBuffPart((GameCmd.SceneEntryType)cmd.byType, cmd.dwTempID); if (bp != null) { bp.CancleBuffState(cmd); } }
public void ReciveBuffState(stSendStateIcoListMagicUserCmd_S cmd) { IBuffPart bp = GetBuffPart((GameCmd.SceneEntryType)cmd.byType, cmd.dwTempID); if (bp != null) { bp.ReciveBuffState(cmd); } }
void OnEvent(int eventID, object param) { switch ((Client.GameEventID)eventID) { case GameEventID.BUFF_ADDTOTARGETBUFF: OnEeventAddBuff(eventID, (Client.stAddBuff)param); break; case GameEventID.BUFF_DELETETARGETBUFF: OnEventRemoveBuff(eventID, (Client.stRemoveBuff)param); break; case GameEventID.BUFF_UPDATEARGETBUFF: break; case GameEventID.ENTITYSYSTEM_TARGETCHANGE: { stTargetChange tc = (stTargetChange)param; IEntity en = tc.target; if (en != null) { IBuffPart bp = en.GetPart(EntityPart.Buff) as IBuffPart; if (bp != null) { List <stAddBuff> list = null; bp.GetBuffList(out list); if (list != null) { targetBuffList.Clear(); for (int i = 0; i < list.Count; i++) { targetBuffList.Insert(0, list[i]); } } } } } break; case GameEventID.RECONNECT_SUCESS: { stReconnectSucess reconnectSucess = (stReconnectSucess)param; if (reconnectSucess.isLogin) { ClearAllBuff(); } } break; } }
public IBuffPart GetBuffPart(GameCmd.SceneEntryType et, uint userID) { IEntitySystem es = ClientGlobal.Instance().GetEntitySystem(); if (es == null) { Engine.Utility.Log.Error("GetEntitySystem failed!"); return(null); } IEntity entity = EntitySystem.EntityHelper.GetEntity(et, userID); //IPlayer player = es.FindPlayer( userID ); if (entity == null) { Engine.Utility.Log.Error("es.FindEntity useid is !" + userID.ToString()); return(null); } IBuffPart buffPart = entity.GetPart(EntityPart.Buff) as IBuffPart; return(buffPart); }
//StringBuilder targetName = new StringBuilder(20); private void OnTargetChange(object param) { stTargetChange tc = (stTargetChange)param; if (tc.target == null) { m_trans_target.gameObject.SetActive(false); } else { IEntity entity = tc.target; string name = entity.GetName(); string lvstr = entity.GetProp((int)CreatureProp.Level).ToString(); m_label_MonsterLevel_Label.text = lvstr; bool showPackeage = false; if (entity.GetEntityType() == EntityType.EntityType_NPC) { INPC npc = entity as INPC; showPackeage = npc.IsBoss(); NpcDataBase ndb = GameTableManager.Instance.GetTableItem <NpcDataBase>((uint)npc.GetProp((int)EntityProp.BaseID)); if (ndb != null) { if (ndb.dwMonsterType == 1) { InitTargetUIInMonster(); m_widget_player.gameObject.SetActive(false); m_widget_monster.gameObject.SetActive(true); m_lableTargetLevel.text = entity.GetProp((int)CreatureProp.Level).ToString(); } else { InitTargetUI(); string iconName = UIManager.GetIconName(ndb.npcIcon, npc.IsPet()); UIManager.GetTextureAsyn(iconName, ref m_curTargetIconAsynSeed, () => { if (null != m_spriteTargetIcon) { m_spriteTargetIcon.mainTexture = null; } }, m_spriteTargetIcon, false); m_widget_player.gameObject.SetActive(true); m_widget_monster.gameObject.SetActive(false); } } if (npc.IsMonster() == false) { bool bVisit = true; if (npc.IsSummon() || npc.IsPet()) { bVisit = false; } CopyTypeTable ct = DataManager.Manager <ComBatCopyDataManager>().GetCurCopyType(); if (ct != CopyTypeTable.Arena) { if (bVisit) { Client.ClientGlobal.Instance().GetControllerSystem().GetActiveCtrl().VisiteNPC(npc.GetUID()); } } } else { //请 if (m_nLastNpcId != entity.GetUID()) { BShowEnemyList = false; m_transHateList.gameObject.SetActive(false); } } m_nLastNpcId = entity.GetUID(); if (m_nLastNpcId != 0) { stRefreshNPCBelongParam npcbelongdata = NpcAscription.Instance.GetNpcBelongByNpcID(m_nLastNpcId); UpdateTargetStatus(npcbelongdata.npcid, npcbelongdata.teamid, npcbelongdata.ownerid, npcbelongdata.clanid, npcbelongdata.ownerName); } } else { InitTargetUI(); m_widget_player.gameObject.SetActive(true); m_widget_monster.gameObject.SetActive(false); IPlayer player = entity as IPlayer; if (player != null) { int job = player.GetProp((int)PlayerProp.Job); int sex = player.GetProp((int)PlayerProp.Sex); SelectRoleDataBase sdb = table.SelectRoleDataBase.Where((GameCmd.enumProfession)job, (GameCmd.enmCharSex)sex); if (sdb != null) { UIManager.GetTextureAsyn(sdb.strprofessionIcon, ref m_curTargetIconAsynSeed, () => { if (null != m_spriteTargetIcon) { m_spriteTargetIcon.mainTexture = null; } }, m_spriteTargetIcon, false); } m_transHateList.gameObject.SetActive(false); //目标选择 OnSetSelectTargetGrid(player.GetID()); } } m_toggle_packageState.gameObject.SetActive(showPackeage); m_lableTargetName.text = name; //m_lableTargetLevel.text = entity.GetProp((int)CreatureProp.Level).ToString(); UpdateTargetHp(entity); BuffManager.TargetBuffList.Clear(); if (entity != null) { List <Client.stAddBuff> lstBuff; IBuffPart part = entity.GetPart(EntityPart.Buff) as IBuffPart; if (part != null) { part.GetBuffList(out lstBuff); for (int i = 0; i < lstBuff.Count; ++i) { stAddBuff buff = lstBuff[i]; table.BuffDataBase db = GameTableManager.Instance.GetTableItem <table.BuffDataBase>(buff.buffid); if (db != null) { if (db.dwShield == 1) {//不显示的直接跳过 continue; } } BuffManager.TargetBuffList.Add(lstBuff[i]); } } else { Engine.Utility.Log.Error("获取{0}Buff部件失败!", entity.GetName()); } } m_trans_target.gameObject.SetActive(true); RefreshBuffIcon(m_trans_TargetBUffContainer, BuffManager.TargetBuffList); } }
//------------------------------------------------------------------------------------------------------- public void AddPart(EntityPart enPart) { int entityPart = (int)enPart; if (m_Parts.ContainsKey(entityPart)) { return; } switch (enPart) { case EntityPart.Skill: // 技能 { ISkillSystem skillSys = EntitySystem.m_ClientGlobal.GetSkillSystem(); if (skillSys == null) { //编辑器模式不需要 break; } ISkillPart skillPart = skillSys.CreateSkillPart(); if (skillPart == null) { return; } if (!skillPart.Create(this)) { Engine.Utility.Log.Error("AddPart failed!"); skillPart = null; return; } m_Parts[entityPart] = skillPart; break; } case EntityPart.Buff: // Buff { ISkillSystem skillSys = EntitySystem.m_ClientGlobal.GetSkillSystem(); if (skillSys == null) { //编辑器模式不需要 break; } IBuffPart buffpart = skillSys.CreateBuffPart(); if (buffpart == null) { return; } if (!buffpart.Create(this)) { Engine.Utility.Log.Error("AddPart failed!"); buffpart = null; return; } m_Parts[entityPart] = buffpart; break; } case EntityPart.Equip: // Equip 装备 { IEquipPart equipPart = new EquipPart(); if (equipPart == null) { return; } if (!equipPart.Create(this)) { Engine.Utility.Log.Error("AddPart failed!"); equipPart = null; return; } m_Parts[entityPart] = equipPart; break; } } }
//------------------------------------------------------------------------------------------------ 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(); }
////////////////////////////////////////////////////////////////////////////////////////////////////////// private Client.IPlayer CreatePlayer(GameCmd.t_MapUserData userData) { IEntitySystem es = ClientGlobal.Instance().GetEntitySystem(); if (es == null) { Engine.Utility.Log.Error("严重错误:EntitySystem is null!"); return(null); } EntityCreateData data = RoleUtil.BuildCreateEntityData(EntityType.EntityType_Player, userData); IPlayer player = es.FindPlayer(userData.userdata.dwUserID); if (player != null) { uint clanIdLow = (uint)player.GetProp((int)CreatureProp.ClanIdLow); uint clanIdHigh = (uint)player.GetProp((int)CreatureProp.ClanIdHigh); uint clanid = (clanIdHigh << 16) | clanIdLow; // //uint clanid = (uint)player.GetProp((int)CreatureProp.ClanId); //玩家死亡 服务器会通过这里刷新 所以这里更新下玩家血条 if (userData.userdata.curhp <= 0) { stPropUpdate prop = new stPropUpdate(); prop.uid = player.GetUID(); prop.nPropIndex = (int)CreatureProp.Hp; prop.oldValue = player.GetProp((int)CreatureProp.Hp); player.UpdateProp(data); prop.newValue = player.GetProp((int)CreatureProp.Hp); Engine.Utility.EventEngine.Instance().DispatchEvent((int)GameEventID.ENTITYSYSTEM_HPUPDATE, prop); } else { stPropUpdate prop = new stPropUpdate(); prop.uid = player.GetUID(); prop.nPropIndex = (int)CreatureProp.Hp; prop.oldValue = player.GetProp((int)CreatureProp.Hp); player.UpdateProp(data); prop.newValue = player.GetProp((int)CreatureProp.Hp); if (prop.oldValue < prop.newValue) { Engine.Utility.EventEngine.Instance().DispatchEvent((int)GameEventID.ENTITYSYSTEM_HPUPDATE, prop); } } if (userData.userdata.clan_id != clanid) { Engine.Utility.EventEngine.Instance().DispatchEvent((int)Client.GameEventID.CLANREFRESHID, new Client.stClanUpdate() { uid = player.GetUID(), clanId = userData.userdata.clan_id }); } } else { if (UserData.IsMainRoleID(userData.userdata.dwUserID)) { data.nLayer = LayerMask.NameToLayer("MainPlayer"); data.bMainPlayer = true; // 设置主角标识 player = es.CreateEntity(EntityType.EntityType_Player, data, true) as IPlayer; if (player == null) { Engine.Utility.Log.Error("CreatePlayer:创建角色失败!"); return(null); } Engine.Utility.EventEngine.Instance().DispatchEvent((int)Client.GameEventID.ENTITYSYSTEM_MAINPLAYERCREATE, new Client.stCreateEntity() { uid = userData.userdata.dwUserID }); // 设置控制对象 Client.IControllerSystem cs = ClientGlobal.Instance().GetControllerSystem(); if (cs != null) { cs.GetActiveCtrl().SetHost(player); } // 补丁 服务器没有金钱没有放在角色属性上 { player.SetProp((int)PlayerProp.Money, (int)UserData.Money); player.SetProp((int)PlayerProp.Coupon, (int)UserData.Coupon); player.SetProp((int)PlayerProp.Cold, (int)UserData.Cold); player.SetProp((int)PlayerProp.Reputation, (int)UserData.Reputation); player.SetProp((int)PlayerProp.Score, (int)UserData.Score); player.SetProp((int)PlayerProp.CampCoin, (int)UserData.CampCoin); player.SetProp((int)PlayerProp.AchievePoint, (int)UserData.AchievePoint); player.SetProp((int)PlayerProp.ShouLieScore, (int)UserData.ShouLieScore); player.SetProp((int)PlayerProp.FishingMoney, (int)UserData.FishingMoney); player.SetProp((int)PlayerProp.YinLiang, (int)UserData.YinLiang); } // 设置主像机参数 SetupMainCamera(player); //玩家成功登陆回调 Engine.Utility.EventEngine.Instance().DispatchEvent((int)Client.GameEventID.PLAYER_LOGIN_SUCCESS, null); //Client.stCreateEntity createEntity = new Client.stCreateEntity(); //createEntity.uid = player.GetUID(); //Engine.Utility.EventEngine.Instance().DispatchEvent((int)GameEventID.ENTITYSYSTEM_CREATEENTITY, createEntity); //set hp DataManager.Manager <UIPanelManager>().SendMsg(PanelID.MainPanel, UIMsgID.eSetRoleProperty, player); //预加载资源 // PreLoadResource(player.GetProp((int)PlayerProp.Job)); } else { //Profiler.BeginSample("CreatePlayer"); player = es.CreateEntity(EntityType.EntityType_Player, data, !m_bDelayLoad) as IPlayer; //Profiler.EndSample(); Protocol.Instance.RequestName(userData.userdata.dwUserID); } if (player != 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; player.SendMessage(EntityMessage.EntityCommand_PlayAni, anim_param); } } IBuffPart buffpart = player.GetPart(EntityPart.Buff) as IBuffPart; if (buffpart != null) { buffpart.ReceiveBuffList(userData.statelist.data); } return(player); }