/// <summary> /// 根据baseID获取npc /// </summary> /// <param name="uid"></param> /// <returns></returns> public static INPC GetNPCByBaseID(uint uid) { IEntitySystem es = ClientGlobal.Instance().GetEntitySystem(); if (es != null) { return(es.FindNPCByBaseId((int)uid)); } return(null); }
/// <summary> /// 城战基本信息 进入副本时下发一次 /// </summary> /// <param name="cmd"></param> public void OnCityWarBaseInfo(GameCmd.stCityWarBaseInfoClanUserCmd_S cmd) { m_bEnterCityWar = true;// m_lstCityWarClanId = cmd.clans_id; m_lstCityWarClanName = cmd.clans_name; m_lstCityWarTotemBaseId = cmd.towers_base_id; m_lstCityWarTotemClanId = cmd.tower_clan_id; //图腾 m_lstCityWarTotem = new List <CityWarTotem>(); for (int i = 0; i < m_lstCityWarTotemBaseId.Count; i++) { CityWarTotem cityWarTotem = new CityWarTotem(); cityWarTotem.npcBaseId = m_lstCityWarTotemBaseId[i]; cityWarTotem.clanId = m_lstCityWarTotemClanId[i]; m_lstCityWarTotem.Add(cityWarTotem); //设置实体clanID; IEntitySystem es = Client.ClientGlobal.Instance().GetEntitySystem(); if (es != null) { INPC npc = es.FindNPCByBaseId((int)cityWarTotem.npcBaseId); if (npc != null) { uint clanId = cityWarTotem.clanId; int clanIdLow = (int)(clanId & 0x0000ffff); int clanIdHigh = (int)(clanId >> 16); npc.SetProp((int)Client.CreatureProp.ClanIdLow, clanIdLow); npc.SetProp((int)Client.CreatureProp.ClanIdHigh, clanIdHigh); //npc.SetProp((int)Client.CreatureProp.ClanId, (int)cityWarTotem.clanId); } } } //氏族名称 for (int i = 0; i < m_lstCityWarTotem.Count; i++) { if (m_lstCityWarTotem[i].clanId == 0) { continue; } int clanIndex = m_lstCityWarClanId.IndexOf(m_lstCityWarTotem[i].clanId); string clanName = clanIndex < m_lstCityWarClanName.Count ? m_lstCityWarClanName[clanIndex] : ""; m_lstCityWarTotem[i].clanName = clanName; } if (DataManager.Manager <UIPanelManager>().IsShowPanel(PanelID.CityWarFightingPanel)) { DataManager.Manager <UIPanelManager>().SendMsg(PanelID.CityWarFightingPanel, UIMsgID.eCityWarInfoUpdate, null); } }
/// <summary> /// 图腾改变状态时 发客户端 /// </summary> /// <param name="cmd"></param> public void OnCityWarTowerChange(stCityWarTowerChangeClanUserCmd_S cmd) { //图腾NPC List <uint> totemNpcIdList = GameTableManager.Instance.GetGlobalConfigList <uint>(CONST_COTYWARTOTEM_NAME, (cmd.tower_idx).ToString()); if (totemNpcIdList == null) { return; } if (cmd.tower_idx - 1 > m_lstCityWarTotem.Count) { return; } CityWarTotem cityWarTotem = m_lstCityWarTotem[(int)cmd.tower_idx - 1]; //图腾氏族ID cityWarTotem.clanId = cmd.clan_id; //图腾npc ID if (cmd.clan_id != 0) { int clanIndex = m_lstCityWarClanId.IndexOf(cmd.clan_id); cityWarTotem.npcBaseId = totemNpcIdList[clanIndex]; //图腾对应的npc string clanName = clanIndex < m_lstCityWarClanName.Count ? m_lstCityWarClanName[clanIndex] : ""; cityWarTotem.clanName = clanName; } else { cityWarTotem.npcBaseId = totemNpcIdList[totemNpcIdList.Count - 1]; //最后一个默认为中立的npc cityWarTotem.clanName = string.Empty; } //设置实体clanID; IEntitySystem es = Client.ClientGlobal.Instance().GetEntitySystem(); if (es != null) { INPC npc = es.FindNPCByBaseId((int)cityWarTotem.npcBaseId); if (npc != null) { uint clanId = cityWarTotem.clanId; int clanIdLow = (int)(clanId & 0x0000ffff); int clanIdHigh = (int)(clanId >> 16); npc.SetProp((int)Client.CreatureProp.ClanIdLow, clanIdLow); npc.SetProp((int)Client.CreatureProp.ClanIdHigh, clanIdHigh); //npc.SetProp((int)Client.CreatureProp.ClanId, (int)cityWarTotem.clanId); } } EventEngine.Instance().DispatchEvent((int)GameEventID.CITYWARTOTEMCLANNAMECHANGE, cityWarTotem.npcBaseId); }
private void OnResume(bool bShowTip) { if (m_status == CombatRobotStatus.RUNNING) { return; } IPlayer mainPlayer = ControllerSystem.m_ClientGlobal.MainPlayer; if (mainPlayer == null) { return; } //如果挂机打指定怪的时候跑到别的地方 找不到指定怪则不打指定怪了 if (m_nTargetID != 0) { IEntitySystem es = ControllerSystem.m_ClientGlobal.GetEntitySystem(); INPC npc = es.FindNPCByBaseId(m_nTargetID); if (npc == null) { m_nTargetID = 0; } } ChangeStatus(CombatRobotStatus.RUNNING); ChangeRoleAction(RoleAction.NONE); if (bShowTip) { Client.ITipsManager tip = ControllerSystem.m_ClientGlobal.GetTipsManager(); if (tip != null) { tip.ShowTipsById(702); } } m_centerPos = mainPlayer.GetPos(); m_fStopTime = 0; AddEventListener(GameEventID.SKILLINFO_REFRESH); AddEventListener(GameEventID.SKILLNONESTATE_ENTER); AddEventListener(GameEventID.ROBOTCOMBAT_NEXTCMD); Engine.Utility.EventEngine.Instance().DispatchEvent((int)Client.GameEventID.ROBOTCOMBAT_START, null); }
private IEntity GetNearestMonster() { Client.IPlayer mainplayer = ControllerSystem.m_ClientGlobal.MainPlayer; if (mainplayer == null) { return(null); } IEntitySystem es = ControllerSystem.m_ClientGlobal.GetEntitySystem(); if (es == null) { return(null); } IMapSystem ms = ControllerSystem.m_ClientGlobal.GetMapSystem(); if (ms == null) { return(null); } IEntity monster = null; if (m_nTargetID != 0) { monster = es.FindNPCByBaseId(m_nTargetID, true); } else { PLAYERPKMODEL pkmodel = (PLAYERPKMODEL)mainplayer.GetProp((int)PlayerProp.PkMode); MapAreaType atype = ms.GetAreaTypeByPos(mainplayer.GetPos()); IControllerHelper ch = GetControllerHelper(); if (ch != null) { uint attackPriority = ch.GetAttackPriority(); monster = es.FindEntityByArea_PkModel(atype, pkmodel, m_centerPos, m_nSearchRang, attackPriority); } } return(monster); }