//隐藏实例
        public void HideEntity(UInt64 sGUID)
        {
            if (!AllEntitys.ContainsKey(sGUID))
            {
                return;
            }

            IEntity entity = null;

            //如果字典中存在这个实例并且实例类型是Player
            if (EntityManager.AllEntitys.TryGetValue(sGUID, out entity) && entity.entityType == EntityTypeEnum.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;
        }
Esempio n. 2
0
        public override void OnUpdate()
        {
            base.OnUpdate();
            ISelfPlayer playerSelf = PlayerManager.Instance.LocalPlayer;

            if (playerSelf != null && playerSelf.realObject != null && !this.IsSameCamp(playerSelf.EntityCamp))
            {                                                                                          //enemy player
                float dis = Vector3.Distance(playerSelf.objTransform.position, objTransform.position); //self player distance with enemy player
                if (dis > GameConstDefine.PlayerLockTargetDis)
                {
                    return;
                }
                if ((this.FSM != null && this.FSM.State == Thanos.FSM.FsmStateEnum.DEAD) || (this.realObject.activeSelf == false))
                {
                    AddOrDelEnemy(this, false);// UIEnemyTeamMateInfo.Instance.RemovePlayerEnemy(this);
                }
                else  // if(UIEnemyTeamMateInfo.Instance != null){
                      // UIEnemyTeamMateInfo.Instance.SetPlayerEnemy(this);
                {
                    if (this.realObject.active == true)
                    {
                        AddOrDelEnemy(this, true);
                    }
                }
            }
        }
Esempio n. 3
0
        }                                              //战况  平手,失败,胜利


        //创建实例(英雄)  英雄ID   英雄阵营
        public override IEntity HandleCreateEntity(UInt64 sGUID, EntityCampTypeEnum campType)
        {
            //entity id
            IPlayer player;

            if (GameUserModel.Instance.IsLocalPlayer(sGUID))
            {
                player = new ISelfPlayer(sGUID, campType);
            }
            else
            {
                player = new IPlayer(sGUID, campType);
            }

            player.GameUserId = sGUID;
            return(player);
        }
Esempio n. 4
0
        // 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 == EntityTypeEnum.Building && this.NPCCateChild != NPCCateChildEnum.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)ResultEnum.DelEntityFailed);
            }
            IEntity entity = null;

            if (EntityManager.AllEntitys.TryGetValue(sGUID, out entity) && entity.entityType == EntityTypeEnum.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 == EntityTypeEnum.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)ResultEnum.Normal);
        }