Exemple #1
0
        public override void ServerDo(ClientConnectionWorker connectionWork)
        {
            NetManager.Instance.server.sceneManager.ChangedSign(pos, sign);
            for (int i = 0; i < changedBlocks.Count; i++)
            {
                NetManager.Instance.server.sceneManager.ChangedBlock(pos, changedBlocks[i]);
            }
//			UnityEngine.Debug.Log("收到chunkPos:" + pos.ToString() + "的生物群落产生消息,数量为:" + changedBlocks.Count + " sign:" + sign);
            NetManager.Instance.server.sceneManager.BroadcastPlayerHasChunkPackage(connectionWork.player, pos, this, false);
        }
Exemple #2
0
        public override void ServerDo(ClientConnectionWorker connectionWork)
        {
            ClientEntity entity = NetManager.Instance.server.entityManager.GetEntity(aoId);

            if (entity != null && entity.hostPlayer != null && entity.hostPlayer.id == connectionWork.player.id)
            {
                entity.UpdatePosition(position);
                NetManager.Instance.server.entityManager.BroadcastPackageInEntityViewPlayers(this, entity, connectionWork.player.id);
            }
        }
        public override void ServerDo(ClientConnectionWorker connectionWork)
        {
            List <int> viewEntities = connectionWork.player.viewEntities;

            list = new List <ClientEntityInfo>(viewEntities.Count);
            for (int i = 0; i < viewEntities.Count; i++)
            {
                ClientEntity entity = NetManager.Instance.server.entityManager.GetEntity(viewEntities[i]);
                list.Add(entity.GetClientEntityInfo());
            }
            connectionWork.SendPackage(this);
        }
Exemple #4
0
        public override void ServerDo(ClientConnectionWorker connectionWork)
        {
            ClientEntity entity = NetManager.Instance.server.entityManager.GetEntity(aoId);

            if (entity != null && entity.viewPlayers.Contains(connectionWork.player.id))
            {
                needRefresh = true;
                info        = entity.GetClientEntityInfo();
            }
            else
            {
                needRefresh = false;
            }
            connectionWork.SendPackage(this);
        }
        public override void ServerDo(ClientConnectionWorker connectionWork)
        {
            ClientPlayer           player = NetManager.Instance.server.playerManager.GetPlayer(roleId);
            ClientChangedChunkData data   = NetManager.Instance.server.sceneManager.GetChangedChunkData(pos);

            if (data != null)
            {
                hasChangedData = true;
                changedData    = data;
            }
            if (player != null)
            {
                player.worker.SendPackage(this);
            }
        }
        public override void ServerDo(ClientConnectionWorker connectionWork)
        {
            ClientPlayerInfo playerInfo = new ClientPlayerInfo();

            playerInfo.id         = roleId;
            playerInfo.aoId       = aoId;
            playerInfo.playerId   = playerId;
            playerInfo.position   = position;
            playerInfo.configName = worldConfigName;
            playerInfo.seed       = seed;
            Debug.Log("初始化世界配置:" + worldConfigName);
            connectionWork.InitPlayer(playerInfo);
            NetManager.Instance.server.gameTime = time;
            NetManager.Instance.server.playerManager.AddPlayer(connectionWork.player, true);
            Debug.Log("服务器初始化主玩家信息完成!");
        }
Exemple #7
0
        public override void ServerDo(ClientConnectionWorker connectionWork)
        {
            List <int> viewPlayers = connectionWork.player.viewPlayers;

            list = new List <PlayerInfo>(viewPlayers.Count);
            for (int i = 0; i < viewPlayers.Count; i++)
            {
                ClientPlayer player = NetManager.Instance.server.playerManager.GetPlayer(viewPlayers[i]);
                PlayerInfo   info   = new PlayerInfo();
                info.aoId     = player.aoId;
                info.playerId = player.playerId;
                info.position = player.position;
                info.isMe     = false;
                list.Add(info);
            }
            connectionWork.SendPackage(this);
        }
Exemple #8
0
        public override void ServerDo(ClientConnectionWorker connectionWork)
        {
            ResponseRemoveChunkExtDataPackage package = PackageFactory.GetPackage(PackageType.ResponseRemoveChunkExtData)
                                                        as ResponseRemoveChunkExtDataPackage;

            package.pos      = pos;
            package.needSave = NetManager.Instance.server.sceneManager.CanchangedChunkSaved(pos);
            package.entities = new List <ClientEntityInfo>();
            List <ClientEntity> list = NetManager.Instance.server.entityManager.GetEntitiesInChunk(pos);

            if (list != null)
            {
                for (int i = 0; i < list.Count; i++)
                {
                    package.entities.Add(list[i].GetClientEntityInfo());
                }
            }
            connectionWork.SendPackage(package);
        }
Exemple #9
0
        public override void ServerDo(ClientConnectionWorker connectionWork)
        {
            //在服务器中初始化当前加入玩家的信息
            int              aoId       = AoIdManager.instance.getAoId();
            Vector3          birthPlace = NetManager.Instance.server.playerManager.mainPlayer.position;
            ClientPlayerInfo playerInfo = new ClientPlayerInfo();

            playerInfo.id         = roleId;
            playerInfo.aoId       = aoId;
            playerInfo.position   = birthPlace;
            playerInfo.playerId   = playerId;
            playerInfo.configName = NetManager.Instance.server.playerManager.mainPlayer.configName;
            playerInfo.seed       = NetManager.Instance.server.playerManager.mainPlayer.seed;
            connectionWork.InitPlayer(playerInfo);
            NetManager.Instance.server.playerManager.AddPlayer(connectionWork.player);

            //通知自己进入游戏,并返回一些配置
            ClientJoinGamePackage package = PackageFactory.GetPackage(PackageType.ClientJoinGame) as ClientJoinGamePackage;

            package.playerId        = playerId;
            package.aoId            = aoId;
            package.birthPlace      = birthPlace;
            package.worldConfigName = NetManager.Instance.server.playerManager.mainPlayer.configName;
            package.seed            = NetManager.Instance.server.playerManager.mainPlayer.seed;
            package.time            = NetManager.Instance.server.gameTime;
            connectionWork.SendPackage(package);

            //通知其他人我已进入游戏,并出现在他们视野内
            PlayerJoinViewPackage joinViewPackage = PackageFactory.GetPackage(PackageType.PlayerJoinView) as PlayerJoinViewPackage;

            joinViewPackage.playerId   = playerId;
            joinViewPackage.aoId       = aoId;
            joinViewPackage.birthPlace = birthPlace;
            List <int> viewPlayers = connectionWork.player.viewPlayers;

            for (int i = 0; i < viewPlayers.Count; i++)
            {
                ClientPlayer otherPlayer = NetManager.Instance.server.playerManager.GetPlayer(viewPlayers[i]);
                otherPlayer.worker.SendPackage(joinViewPackage);
            }
        }
Exemple #10
0
 public override void ServerDo(ClientConnectionWorker connectionWork)
 {
     for (int i = 0; i < entityInfos.Count; i++)
     {
         NetManager.Instance.server.entityManager.InitEntity(entityInfos[i]);
     }
     //可是entity全部交由服务器来管理,因此,客户端的某些怪物可能需要移掉(不在视野范围之内)
     for (int i = 0; i < entityInfos.Count; i++)
     {
         ClientEntity clientEntity = NetManager.Instance.server.entityManager.GetEntity(entityInfos[i].aoId);
         //检测归属变更
         clientEntity.CheckViewHold();
         if (clientEntity.viewPlayers.Count <= 0)
         {
             EntityLeaveViewPackage leaveViewPackage = PackageFactory.GetPackage(PackageType.EntityLeaveView) as EntityLeaveViewPackage;
             leaveViewPackage.aoId = clientEntity.aoId;
             leaveViewPackage.type = clientEntity.type;
             connectionWork.SendPackage(leaveViewPackage);
         }
     }
 }
        public override void ServerDo(ClientConnectionWorker connectionWork)
        {
            if (NetManager.Instance.server.sceneManager.RefreshEntity(pos))
            {
                List <int> listRefershEntity = new List <int>();
                for (int i = 0; i < entities.Count; i++)
                {
                    int aoId = AoIdManager.instance.getAoId();
                    ClientEntityInfo info = new ClientEntityInfo();
                    info.aoId     = aoId;
                    info.entityId = entities[i].id;
                    info.type     = entities[i].type;
                    info.extData  = entities[i].exData;
                    info.position = entities[i].pos;
                    info.roleId   = connectionWork.player.id;
                    NetManager.Instance.server.entityManager.InitEntity(info);
                    listRefershEntity.Add(aoId);
                }
                //全部刷新完成后,通知持有该块的玩家更改刷新标志,并通知其刷新怪物
                ChunkSignChangedPackage signChangedPackage = PackageFactory.GetPackage(PackageType.ChunkSignChanged) as ChunkSignChangedPackage;
                signChangedPackage.pos  = pos;
                signChangedPackage.sign = NetManager.Instance.server.sceneManager.GetSign(pos);
                NetManager.Instance.server.sceneManager.BroadcastPlayerHasChunkPackage(connectionWork.player, pos, signChangedPackage, true);
                for (int i = 0; i < listRefershEntity.Count; i++)
                {
                    ClientEntity          clientEntity          = NetManager.Instance.server.entityManager.GetEntity(listRefershEntity[i]);
                    ClientEntityInfo      clientEntityInfo      = clientEntity.GetClientEntityInfo();
                    EntityJoinViewPackage entityJoinViewPackage = PackageFactory.GetPackage(PackageType.EntityJoinView)
                                                                  as EntityJoinViewPackage;
                    entityJoinViewPackage.info = clientEntityInfo;
                    for (int j = 0; j < clientEntity.viewPlayers.Count; j++)
                    {
                        ClientPlayer clientPlayer = NetManager.Instance.server.playerManager.GetPlayer(clientEntity.viewPlayers[j]);
                        clientPlayer.worker.SendPackage(entityJoinViewPackage);
                    }
                }
//				Debug.Log("请求刷新区块pos:" + pos.ToString() + "的entity成功,刷新数量:" + listRefershEntity.Count + " changedSign:" +signChangedPackage.sign);
            }
        }
Exemple #12
0
        public override void ServerDo(ClientConnectionWorker connectionWork)
        {
            ClientPlayer mainPlayer = NetManager.Instance.server.playerManager.mainPlayer;

            if (mainPlayer.id == roleId)
            {
                ResponseChunkPackage package = PackageFactory.GetPackage(PackageType.ResponseChunk) as ResponseChunkPackage;
                package.roleId = roleId;
                package.pos    = pos;
                package.isExit = false;
                ClientChangedChunkData data = NetManager.Instance.server.sceneManager.GetChangedChunkData(pos);
                if (data != null)
                {
                    package.hasChangedData = true;
                    package.changedData    = data;
                }
                mainPlayer.worker.SendPackage(package);
            }
            else
            {
                mainPlayer.worker.SendPackage(this);
            }
        }
 public override void ServerDo(ClientConnectionWorker connectionWork)
 {
     //将当前玩家的chunk更新数据添加到服务器上
     NetManager.Instance.server.sceneManager.AddPlayerInChunks(connectionWork.player, pos, sign);
 }
Exemple #14
0
 public virtual void ServerDo(ClientConnectionWorker connectionWork)
 {
 }
 public override void ServerDo(ClientConnectionWorker connectionWork)
 {
     connectionWork.player.UpdatePosition(position);
     NetManager.Instance.server.BroadcastPackage(this, connectionWork.player, connectionWork.player.viewWidth, false);
 }
 public override void ServerDo(ClientConnectionWorker connectionWork)
 {
     NetManager.Instance.server.entityManager.RemoveEntitiesInChunk(pos);
     NetManager.Instance.server.sceneManager.RemovePlayerChunks(connectionWork.player, pos);
 }
Exemple #17
0
 public override void ServerDo(ClientConnectionWorker connectionWork)
 {
     NetManager.Instance.server.sceneManager.ChangedSign(pos, sign);
     //再转发给其他人有这个区块的人
     NetManager.Instance.server.sceneManager.BroadcastPlayerHasChunkPackage(connectionWork.player, pos, this, false);
 }
 public override void ServerDo(ClientConnectionWorker connectionWork)
 {
     UnityEngine.Debug.Log("收到客户端:" + this.ip + ":" + this.port + "的连接请求!");
     connectionWork.SendPackage(PackageFactory.GetPackage(this.id));
 }
Exemple #19
0
 public override void ServerDo(ClientConnectionWorker connectionWork)
 {
     NetManager.Instance.server.playerManager.mainPlayer.worker.SendPackage(this);
 }
Exemple #20
0
 public override void ServerDo(ClientConnectionWorker connectionWork)
 {
     NetManager.Instance.server.sceneManager.ChangedArea(area);
     NetManager.Instance.server.sceneManager.BroadcastPlaerAreaChangedPackage(connectionWork.player, area, this, true);
     //UnityEngine.Debug.Log("收到更改chunk:" + pos.ToString() + " block:" + changedBlock.index + " " + changedBlock.blockType);
 }
Exemple #21
0
        public override void ServerDo(ClientConnectionWorker connectionWork)
        {
            ClientEntity clientEntity = NetManager.Instance.server.entityManager.GetEntity(aoId);

            NetManager.Instance.server.entityManager.BroadcastPackageInEntityViewPlayers(this, clientEntity, connectionWork.player.id);
        }
 public override void ServerDo(ClientConnectionWorker connectionWork)
 {
     NetManager.Instance.server.gameTime = time;
     NetManager.Instance.server.BroadcastPackage(this, connectionWork.player, false);
 }