/// <summary> /// 是宠物或者召唤物 /// </summary> /// <param name="en"></param> /// <returns></returns> public static bool IsPetAndSummon(IEntity en) { IControllerSystem cs = EntitySystem.m_ClientGlobal.GetControllerSystem(); if (cs == null) { return(false); } //IControllerHelper ch = cs.GetControllerHelper(); //if ( ch == null ) //{ // return false; //} //if ( ch.NpcIsPet( en ) ) //{ // return true; //} INPC npc = en as INPC; if (npc != null) { if (npc.IsPet()) { return(true); } if (npc.IsSummon()) { return(true); } } return(false); }
public ColorType GetNpcNameColor(IEntity entity) { ColorType nameColor = ColorType.JSXT_NpcCheFu; INPC npc = entity as INPC; if (npc.IsCanAttackNPC()) { if (npc.IsMercenary()) { nameColor = ColorType.JSXT_Enemy_White; } else { if (npc.IsPet()) { nameColor = ColorType.JSXT_ZhanHun; } else if (npc.IsSummon()) { nameColor = ColorType.JSXT_ZhaoHuanWu; } else { int level = MainPlayerHelper.GetPlayerLevel(); int monsterLv = entity.GetProp((int)CreatureProp.Level); int levelGap = GameTableManager.Instance.GetGlobalConfig <int>("MonsterWarningLevelGap"); if (level + levelGap < monsterLv) { nameColor = ColorType.JSXT_Enemy_Red; } else { nameColor = ColorType.JSXT_Enemy_White; } } } } else { table.NpcDataBase npcdb = GameTableManager.Instance.GetTableItem <table.NpcDataBase>((uint)entity.GetProp((int)Client.EntityProp.BaseID)); if (npcdb != null) { if (npcdb.dwType == (int)GameCmd.enumNpcType.NPC_TYPE_COLLECT_PLANT) { nameColor = ColorType.JSXT_CaiJiWu; } else if (npcdb.dwType == (int)GameCmd.enumNpcType.NPC_TYPE_TRANSFER || npcdb.dwType == (int)GameCmd.enumNpcType.NPC_TYPE_FUNCTION) { nameColor = ColorType.JSXT_ChuanSongZhen; } else { nameColor = ColorType.White; } } } return(nameColor); }
/// <summary> /// 通过玩家id获取所属宠物 /// </summary> /// <param name="playerID"></param> /// <returns></returns> public INPC GetOwnPetByPlayerID(uint playerID) { List <INPC> npcList = new List <INPC>(); GetOwnNpcByPlayerID(playerID, ref npcList); for (int i = 0; i < npcList.Count; i++) { INPC npc = npcList[i]; if (npc.IsPet()) { return(npc); } } npcList.Clear(); return(null); }
bool IsHideFx() { if (IsMainPlayer()) { return(false); } IEntity en = m_Master; if (en != null) { INPC npc = en as INPC; if (npc != null) { if (npc.IsPet() || npc.IsSummon()) { if (npc.IsMainPlayerSlave()) { return(false); } else { return(m_bHideOtherFx || m_bHideOtherPlayer); } } else { return(false); } } else { //player return(m_bHideOtherFx || m_bHideOtherPlayer); } } return(false); }
/// <summary> /// 获取实体血条 /// </summary> /// <param name="entity"></param> /// <returns></returns> public static EntityHpSprite GetEntityHpSpData(IEntity entity) { EntityHpSprite spriteParams = new EntityHpSprite(); spriteParams.spriteType = UISprite.Type.Filled; if (entity.GetEntityType() == EntityType.EntityType_Player) { GameCmd.eCamp mycamp = (GameCmd.eCamp)MainPlayerHelper.GetMainPlayer().GetProp((int)CreatureProp.Camp); GameCmd.eCamp camp = (GameCmd.eCamp)entity.GetProp((int)CreatureProp.Camp); spriteParams.bgSpriteName = GetHpSpriteName(HpSpriteType.PlayerBg); if (entity == MainPlayerHelper.GetMainPlayer()) { spriteParams.spriteName = GetHpSpriteName(HpSpriteType.Me); } else { if (EntityCanAttack(entity)) { spriteParams.spriteName = GetHpSpriteName(HpSpriteType.Enemy); } else { spriteParams.spriteName = GetHpSpriteName(HpSpriteType.Friend); } } spriteParams.bShow = true; } else if (entity.GetEntityType() == EntityType.EntityType_NPC) { INPC npc = entity as INPC; //任意NPC先给一个默认的血条 spriteParams.bgSpriteName = GetHpSpriteName(HpSpriteType.NoneBg); spriteParams.spriteName = GetHpSpriteName(HpSpriteType.None); spriteParams.bShow = IsNeedHpSlider(entity); if (npc.WhetherShowHeadTips()) { //是可以攻击的NPC if (npc.IsCanAttackNPC()) { //是不是佣兵 if (npc.IsMercenary()) { spriteParams.spriteName = GetHpSpriteName(HpSpriteType.Friend); spriteParams.bgSpriteName = GetHpSpriteName(HpSpriteType.PlayerBg); spriteParams.bShow = true; } else { if (npc.IsPet()) { spriteParams.bgSpriteName = GetHpSpriteName(HpSpriteType.PetBg); if (npc.IsMainPlayerSlave()) { spriteParams.spriteName = GetHpSpriteName(HpSpriteType.MyPet); } else { if (EntityCanAttack(entity)) { spriteParams.spriteName = GetHpSpriteName(HpSpriteType.EnemyPet); } } } else if (npc.IsSummon()) { spriteParams.bgSpriteName = GetHpSpriteName(HpSpriteType.SummonBg); if (npc.IsMainPlayerSlave()) { spriteParams.spriteName = GetHpSpriteName(HpSpriteType.MySummon); } else { if (EntityCanAttack(entity)) { spriteParams.spriteName = GetHpSpriteName(HpSpriteType.EnemySummon); } } } else if (npc.IsMonster()) { spriteParams.bgSpriteName = GetHpSpriteName(HpSpriteType.MonsterBg); spriteParams.spriteName = GetHpSpriteName(HpSpriteType.Monster); spriteParams.spriteType = UISprite.Type.Simple; } } } } else { spriteParams.bShow = false; } } else if (entity.GetEntityType() == EntityType.EntityTYpe_Robot) { GameCmd.eCamp mycamp = (GameCmd.eCamp)MainPlayerHelper.GetMainPlayer().GetProp((int)CreatureProp.Camp); GameCmd.eCamp camp = (GameCmd.eCamp)entity.GetProp((int)CreatureProp.Camp); spriteParams.bgSpriteName = GetHpSpriteName(HpSpriteType.PlayerBg); if (entity == MainPlayerHelper.GetMainPlayer()) { spriteParams.spriteName = GetHpSpriteName(HpSpriteType.Me); } else { if (EntityCanAttack(entity)) { spriteParams.spriteName = GetHpSpriteName(HpSpriteType.Enemy); } else { spriteParams.spriteName = GetHpSpriteName(HpSpriteType.Friend); } } spriteParams.bShow = true; } return(spriteParams); }
public static bool IsNeedHpSlider(Client.IEntity entity) { if (entity.GetEntityType() == EntityType.EntityType_NPC) { INPC npc = entity as INPC; //是可以攻击的NPC if (npc.IsCanAttackNPC()) { Client.ISkillPart skillPart = MainPlayerHelper.GetMainPlayer().GetPart(EntityPart.Skill) as Client.ISkillPart; bool canAttack = true; if (skillPart != null) { int skillerror = 0; canAttack = skillPart.CheckCanAttackTarget(entity, out skillerror); } if (npc.IsPet()) { if (npc.IsMainPlayerSlave()) { return(true); } else { if (canAttack) { return(true); } } return(false); } else if (npc.IsSummon()) { if (npc.IsMainPlayerSlave()) { return(true); } else { if (canAttack) { return(true); } } return(false); } else if (npc.IsMonster()) { int hp = entity.GetProp((int)CreatureProp.Hp); int maxhp = entity.GetProp((int)CreatureProp.MaxHp); return(hp < maxhp); } } else { table.NpcDataBase npcdb = GameTableManager.Instance.GetTableItem <table.NpcDataBase>((uint)entity.GetProp((int)Client.EntityProp.BaseID)); if (npcdb != null) { if (npcdb.dwType == (int)GameCmd.enumNpcType.NPC_TYPE_TRANSFER || npcdb.dwType == (int)GameCmd.enumNpcType.NPC_TYPE_COLLECT_PLANT || npcdb.dwType == (int)GameCmd.enumNpcType.NPC_TYPE_FUNCTION) { return(false); } } } } return(true); }
void InitTargetChangeUI() { IEntity ie = Client.ClientGlobal.Instance().GetControllerSystem().GetActiveCtrl().GetCurTarget(); if (ie == null) { m_trans_target.gameObject.SetActive(false); } else { m_trans_target.gameObject.SetActive(true); IEntity entity = ie; string name = entity.GetName(); string lvstr = entity.GetProp((int)CreatureProp.Level).ToString(); m_label_MonsterLevel_Label.text = lvstr; bool showPackage = false; //怪 if (entity.GetEntityType() == EntityType.EntityType_NPC) { INPC npc = entity as INPC; NpcDataBase ndb = GameTableManager.Instance.GetTableItem <NpcDataBase>((uint)npc.GetProp((int)EntityProp.BaseID)); if (ndb == null) { return; } showPackage = npc.IsBoss(); 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); } } // 玩家 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); } } m_toggle_packageState.gameObject.SetActive(showPackage); m_lableTargetName.text = name; UpdateTargetHp(entity); } }
//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); } }
EntityHpSprite GetSpiteName(IEntity entity) { EntityHpSprite spriteParams = new EntityHpSprite(); spriteParams.spriteType = UISprite.Type.Filled; bool needHp = RoleStateBarManagerOld.Instance().IsNeedHpSlider(entity); Client.ISkillPart skillPart = MainPlayerHelper.GetMainPlayer().GetPart(EntityPart.Skill) as Client.ISkillPart; bool canAttack = true; if (skillPart != null) { int skillerror = 0; canAttack = skillPart.CheckCanAttackTarget(entity, out skillerror); } if (entity.GetEntityType() == EntityType.EntityType_Player) { GameCmd.eCamp mycamp = (GameCmd.eCamp)MainPlayerHelper.GetMainPlayer().GetProp((int)CreatureProp.Camp); GameCmd.eCamp camp = (GameCmd.eCamp)entity.GetProp((int)CreatureProp.Camp); spriteParams.bgSpriteName = RoleStateBarManager.GetHpSpriteName(HpSpriteType.PlayerBg); if (entity == MainPlayerHelper.GetMainPlayer()) { spriteParams.spriteName = RoleStateBarManager.GetHpSpriteName(HpSpriteType.Me); } else { if (canAttack) { spriteParams.spriteName = RoleStateBarManager.GetHpSpriteName(HpSpriteType.Enemy); } else { spriteParams.spriteName = RoleStateBarManager.GetHpSpriteName(HpSpriteType.Friend); } } spriteParams.bShow = true; } else if (entity.GetEntityType() == EntityType.EntityType_NPC) { INPC npc = entity as INPC; //任意NPC先给一个默认的血条 spriteParams.bgSpriteName = RoleStateBarManager.GetHpSpriteName(HpSpriteType.NoneBg); spriteParams.spriteName = RoleStateBarManager.GetHpSpriteName(HpSpriteType.None); spriteParams.bShow = needHp; //是可以攻击的NPC if (npc.IsCanAttackNPC()) { //是不是佣兵 if (npc.IsMercenary()) { spriteParams.spriteName = RoleStateBarManager.GetHpSpriteName(HpSpriteType.Friend); spriteParams.bgSpriteName = RoleStateBarManager.GetHpSpriteName(HpSpriteType.PlayerBg); spriteParams.bShow = true; } else { if (npc.IsPet()) { spriteParams.bgSpriteName = RoleStateBarManager.GetHpSpriteName(HpSpriteType.PetBg); if (npc.IsMainPlayerSlave()) { spriteParams.spriteName = RoleStateBarManager.GetHpSpriteName(HpSpriteType.MyPet); } else { if (canAttack) { spriteParams.spriteName = RoleStateBarManager.GetHpSpriteName(HpSpriteType.EnemyPet); } } } else if (npc.IsSummon()) { spriteParams.bgSpriteName = RoleStateBarManager.GetHpSpriteName(HpSpriteType.SummonBg); if (npc.IsMainPlayerSlave()) { spriteParams.spriteName = RoleStateBarManager.GetHpSpriteName(HpSpriteType.MySummon); } else { if (canAttack) { spriteParams.spriteName = RoleStateBarManager.GetHpSpriteName(HpSpriteType.EnemySummon); } } } else if (npc.IsMonster()) { spriteParams.bgSpriteName = RoleStateBarManager.GetHpSpriteName(HpSpriteType.MonsterBg); spriteParams.spriteName = RoleStateBarManager.GetHpSpriteName(HpSpriteType.Monster); spriteParams.spriteType = UISprite.Type.Simple; } } } } else if (entity.GetEntityType() == EntityType.EntityTYpe_Robot) { GameCmd.eCamp mycamp = (GameCmd.eCamp)MainPlayerHelper.GetMainPlayer().GetProp((int)CreatureProp.Camp); GameCmd.eCamp camp = (GameCmd.eCamp)entity.GetProp((int)CreatureProp.Camp); spriteParams.bgSpriteName = RoleStateBarManager.GetHpSpriteName(HpSpriteType.PlayerBg); if (entity == MainPlayerHelper.GetMainPlayer()) { spriteParams.spriteName = RoleStateBarManager.GetHpSpriteName(HpSpriteType.Me); } else { if (canAttack) { spriteParams.spriteName = RoleStateBarManager.GetHpSpriteName(HpSpriteType.Enemy); } else { spriteParams.spriteName = RoleStateBarManager.GetHpSpriteName(HpSpriteType.Friend); } } spriteParams.bShow = true; } return(spriteParams); }
void AddIcon(IList npcList, IconType type) { for (int j = 0; j < npcList.Count; j++) { IEntity entity = npcList[j] as IEntity; if (entity != null) { if (entity is INPC) { INPC npc = entity as INPC; if (npc != null) { if (npc.IsTrap()) {//陷阱不显示 continue; } if (npc.IsMonster()) { type = IconType.mastericon; } else if (npc.IsPet()) { type = IconType.peticon; } else { type = IconType.npcicon; } } } if (entity is IRobot) { type = IconType.robot; } if (entity is IPlayer) { IPlayer player = entity as IPlayer; if (player != null) { type = GetIconTypeByPlayer(player); } } GameObject iconGo; if (!iconDic.TryGetValue(entity.GetUID(), out iconGo)) { iconGo = MapIconPoolManager.Instance.GetIcon(type, entity, m_widget_Root.transform); iconDic.Add(entity.GetUID(), iconGo); AddIconToMap(iconGo, entity); } else { iconGo.name = MapIconPoolManager.Instance.GetIconName(type, entity); UISprite spr = iconGo.GetComponent <UISprite>(); if (spr != null) { SetIconSprite(type, spr); } AddIconToMap(iconGo, entity); } } } List <long> lstUID = entityTable[GetStrByIconType(type)]; if (lstUID != null) { lstUID.Clear(); for (int i = 0; i < npcList.Count; ++i) { IEntity entity = npcList[i] as IEntity; if (entity == null) { continue; } lstUID.Add(entity.GetUID()); } } }