Example #1
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 == HolyTech.FSM.FsmState.FSM_STATE_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);
                    }
                }
            }
        }
Example #2
0
        //隐藏实例
        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;
        }
Example #3
0
        }                                              //战况  平手,失败,胜利


        //创建实例(英雄)  英雄ID   英雄阵营
        public override Ientity HandleCreateEntity(UInt64 sGUID, EntityCampType 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);
        }
Example #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 == 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();
        }
Example #5
0
        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);
        }