public override void Update(float dt) { if (m_Owner == null) { return; } if (m_Owner.GetEntityType() == EntityType.EntityType_NPC) { INPC npc = m_Owner as INPC; if (npc != null && !npc.IsMonster()) { float fCurTime = Time.realtimeSinceStartup; switch (m_nAction) { case 0: { if (fCurTime - m_fStartTime > Engine.Utility.MathLib.Instance().RandomRange(8.0f, 25.0f)) { PlayAni playAni = new PlayAni(); playAni.strAcionName = Client.EntityAction.Idle; playAni.fSpeed = 1; playAni.nStartFrame = 0; playAni.nLoop = 1; playAni.fBlendTime = 0.1f; playAni.aniCallback = OnAniEndEvent; m_Owner.SendMessage(EntityMessage.EntityCommand_PlayAni, playAni); m_fStartTime = Time.realtimeSinceStartup; m_nAction = 1; } break; } case 1: { //if (fCurTime - m_fStartTime > Engine.Utility.MathLib.Instance().RandomRange(8.0f, 25.0f)) //{ // m_Owner.PlayAction(Client.EntityAction.Stand, 0, (float)m_Owner.SendMessage(EntityMessage.EntityCommand_GetMoveSpeedFact)); // m_fStartTime = Time.realtimeSinceStartup; // m_nAction = 0; //} break; } } } } }
/// <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); }
//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()); } } }
// 进入状态 public override void Enter(object param) { //m_param = (EntityNormalParam)param; m_Owner = m_Statemachine.GetOwner(); //if (EntitySystem.m_ClientGlobal.IsMainPlayer(m_Owner)) //{ // Engine.Utility.Log.LogGroup("ZDY", "enter normal"); //} //if (EntitySystem.m_ClientGlobal.IsMainPlayer(m_Owner)) //{ // Engine.Utility.Log.Info("Enter................. normal"); //} if (m_Owner != null) { if (param != null) { int nFlag = (int)param; switch (nFlag) { case 0: // 不忽略站立 { m_Owner.PlayAction(Client.EntityAction.Stand, 0, (float)m_Owner.SendMessage(EntityMessage.EntityCommand_GetMoveSpeedFact)); break; } case 1: // 忽略站立 { break; } case 2: // OnHitCallback 受击时切换到战备动作 { if (m_Owner.GetEntityType() == EntityType.EntityType_Player) { m_Owner.PlayAction(Client.EntityAction.Stand_Combat, 0, (float)m_Owner.SendMessage(EntityMessage.EntityCommand_GetMoveSpeedFact)); } else { m_Owner.PlayAction(Client.EntityAction.Stand, 0, (float)m_Owner.SendMessage(EntityMessage.EntityCommand_GetMoveSpeedFact)); } break; } } //if (!ignoreStand) //{ // if (m_Owner.GetEntityType() == EntityType.EntityType_Player) // { // m_Owner.PlayAction(EntityAction.Stand, 0, (float)m_Owner.SendMessage(EntityMessage.EntityCommand_GetMoveSpeedFact)); // } // else // { // m_Owner.PlayAction(Client.EntityAction.Stand, 0, (float)m_Owner.SendMessage(EntityMessage.EntityCommand_GetMoveSpeedFact)); // } //} } else { if (m_Owner.GetEntityType() == EntityType.EntityType_Player) { m_Owner.PlayAction(EntityAction.Stand, 0, (float)m_Owner.SendMessage(EntityMessage.EntityCommand_GetMoveSpeedFact)); } else { m_Owner.PlayAction(Client.EntityAction.Stand, 0, (float)m_Owner.SendMessage(EntityMessage.EntityCommand_GetMoveSpeedFact)); } } // 播放休闲动作 if (m_Owner.GetEntityType() == EntityType.EntityType_NPC) { INPC npc = m_Owner as INPC; if (npc != null && !npc.IsMonster()) { m_fStartTime = Time.realtimeSinceStartup; m_nAction = 0; } } } }