//隐藏实例 public void HideEntity(UInt64 sGUID) { if (!AllEntitys.ContainsKey(sGUID)) { return; } Ientity entity = null; //如果字典中存在这个实例并且实例类型是Player if (EntityManager.AllEntitys.TryGetValue(sGUID, out entity) && entity.entityType == EntityType.Player) { // if (PlayerManager.Instance.LocalAccount.ObjType == ObPlayerOrPlayer.PlayerType) { Iplayer.AddOrDelEnemy((Iplayer)entity, false); } } Iselfplayer player = PlayerManager.Instance.LocalPlayer; if (player != null && player.SyncLockTarget == AllEntitys[sGUID]) { //锁定对象实例为空 player.SetSyncLockTarget(null); } //隐藏血条 AllEntitys[sGUID].HideBloodBar(); //禁用实例 AllEntitys[sGUID].realObject.active = false; }
// Entity死亡 public virtual void OnEnterDead() //实体进入死亡状态 如果是本地玩家,则执行Iselfplayer中的OnEnterDead() { //目标死亡主角相关处理 Iselfplayer player = PlayerManager.Instance.LocalPlayer; if (player != null && player.SyncLockTarget != null && GameObjGUID == player.SyncLockTarget.GameObjGUID) { player.SetSyncLockTarget(null); //锁定目标为空 } //播放死亡声音 Vector3 pos = PlayerManager.Instance.LocalPlayer.RealEntity.transform.position; if (GetDistanceToPos(pos) <= 30)//获取某个位置的距离 { this.PlayDeadSound(); } //建筑物更换模型和表现特效 if (this.entityType == EntityType.Building && this.NPCCateChild != ENPCCateChild.eNPCChild_BUILD_Base) { if (!EntityManager.GetHomeBaseList().Contains(this)) { GameMethod.SetLoadJianTaBaoZha(this); //爆炸特效 int ret = EntityManager.HandleDelectEntity(this.GameObjGUID); //删除实体 if (ret != 0) { Debug.LogError("OnEnterDead HandleDelectEntity:" + GameObjGUID + "failed"); } } //广播建筑销毁消息,移除警告等 EventCenter.Broadcast <Ientity>((Int32)GameEventEnum.GameEvent_NotifyBuildingDes, this); return; } //非建筑物播死亡动画和清理血条寻路代理条等状态 this.DoEntityDead(); RealEntity.PlayerDeadAnimation(); }
public static int HandleDelectEntity(UInt64 sGUID) { if (!AllEntitys.ContainsKey(sGUID)) { return((int)ReturnRet.eT_DelEntityFailed); } Ientity entity = null; if (EntityManager.AllEntitys.TryGetValue(sGUID, out entity) && entity.entityType == EntityType.Player) { if (PlayerManager.Instance.LocalAccount.ObjType == ObPlayerOrPlayer.PlayerType) { Iplayer.AddOrDelEnemy((Iplayer)entity, false); } } Iselfplayer player = PlayerManager.Instance.LocalPlayer; if (player != null && player.SyncLockTarget == AllEntitys[sGUID]) { player.SetSyncLockTarget(null); } if (entity.entityType == EntityType.Building) { MonoBehaviour.DestroyImmediate(AllEntitys[sGUID].realObject); } else { //删除GameObject ObjectPool.Instance.ReleaseGO(AllEntitys[sGUID].resPath, AllEntitys[sGUID].realObject, PoolObjectTypeEnum.Entity); } AllEntitys[sGUID].DestroyBloodBar(); AllEntitys[sGUID] = null; AllEntitys.Remove(sGUID); return((int)ReturnRet.eT_Normal); }