def pushScene(placeId,players,monsters):
    '''推送场景信息'''
    if not players:
        return
    from app.scense.protoFile.scene import pushSceneMessage_pb2
    sceneInfo = pushSceneMessage_pb2.pushSceneMessage()
    sendList = []
    for player in players:
        PlayerPosition = sceneInfo.PlayerPosition.add()
        PlayerPosition.id = player.baseInfo.id
        PlayerPosition.name = player.baseInfo.getNickName()
        PlayerPosition.profession = player.profession.getProfessionName()
        GuildInfo = player.guild.getGuildInfo()
        if GuildInfo:
            PlayerPosition.guildname = GuildInfo.get('name','')
        PlayerPosition.figure = player.profession.getSceneFigure()
        if player.baseInfo.id<10000 and random.randint(1,10)==10:
            player.baseInfo.setPosition((random.randint(300,2000),random.randint(450,560)))
        PlayerPosition.x = int(player.baseInfo.getDestination()[0])
        PlayerPosition.y = int(player.baseInfo.getDestination()[1])
        sendList.append(player.dynamicId)
    if not sendList:
        return
    for monster in monsters.values():
        MonsterPosition = sceneInfo.MonsterPosition.add()
        MonsterPosition.id = monster.baseInfo.id
        MonsterPosition.profession = monster.formatInfo['name']
        MonsterPosition.figure  = monster.formatInfo['resourceid']
        MonsterPosition.name = monster.formatInfo['name']
        MonsterPosition.x = int(monster.baseInfo.getPosition()[0])
        MonsterPosition.y = int(monster.baseInfo.getPosition()[1])
    sceneInfo.sceneId = placeId
    msg = sceneInfo.SerializeToString()
    pushApplyMessage(602,msg, sendList)
Beispiel #2
0
 def pushSceneInfo(self,rate):
     '''给每一个在场景中的玩家推送场景信息
     @param rate: int 移动的频率
     '''
     if not self._canRec:
         return
     self.updateAllPlayerLocation(rate)
     if self._monsters:
         self.updateAllMonsterLocation()
     
     groupState = configure.isteamInstanceTime(20)#组队副本时间判断
     guildFightState = fortress.IsWarTime()#国战时间判断
     
     for room in self.rooms:
         sendlist = []
         sceneInfo = pushSceneMessage_pb2.pushSceneMessage()
         for playerId in room:
             player = PlayersManager().getPlayerByID(playerId)
             if not player:
                 continue
             player.icon.groupIconManager(groupState)#组队战图标管理
             player.icon.guildFightManager(guildFightState)#国战图标管理
             PlayerPosition = sceneInfo.PlayerPosition.add()
             PlayerPosition.id = player.baseInfo.id
             PlayerPosition.name = player.baseInfo.getNickName()
             PlayerPosition.profession = player.profession.getProfessionName()
             PlayerPosition.headicon = player.profession.getFigure()
             GuildInfo = player.guild.getGuildInfo()
             if GuildInfo:
                 PlayerPosition.guildname = GuildInfo.get('name','')
             PlayerPosition.figure = player.profession.getSceneFigure()
             position = player.baseInfo.getDestination()
             PlayerPosition.x = int(position[0])
             PlayerPosition.y = int(position[1])
             PlayerPosition.level = player.level.getLevel()
             PlayerPosition.viptype = player.baseInfo.getType()
             PlayerPosition.gemlevel = player.pack._equipmentSlot.getGemLevel()
             sendlist.append(player.getDynamicId())
             ###############角色展示宠物的处理################
             petremove = player.pet.popLastRemove()
             for petId in petremove:
                 self.dropPet(petId)
             for petId in player.matrix._matrixSetting.values():
                 if petId<=0:
                     continue
                 pet = player.pet.getPet(petId)
                 figure = pet.templateInfo['resourceid']
                 position = pet.getPosition()
                 PetPosition = sceneInfo.petInfo.add()
                 PetPosition.id = petId
                 PetPosition.name = pet.baseInfo.getName()
                 PetPosition.profession = pet.baseInfo.getName()
                 PetPosition.headicon = figure
                 PetPosition.figure = figure
                 PetPosition.x = int(position[0])
                 PetPosition.y = int(position[1])
                 PetPosition.masterId = playerId
         sceneInfo.sceneId = self._id
         msg = sceneInfo.SerializeToString()
         pushApplyMessage(602,msg, sendlist)
Beispiel #3
0
 def pushNowScenePosition(self,sendId,playerID):
     '''推送在场景中当前的所有角色和怪物的坐标
     @param sendId: int 推送的目标ID
     '''
     self._canRec.add(playerID)
     sceneInfo = pushSceneMessage_pb2.pushSceneMessage()
     for playerId in self._playerlist:
         player = PlayersManager().getPlayerByID(playerId)
         PlayerPosition = sceneInfo.PlayerPosition.add()
         PlayerPosition.id = player.baseInfo.id
         PlayerPosition.name = player.baseInfo.getNickName()
         PlayerPosition.profession = player.profession.getProfessionName()
         PlayerPosition.headicon = player.profession.getFigure()
         GuildInfo = player.guild.getGuildInfo()
         if GuildInfo:
             PlayerPosition.guildname = GuildInfo.get('name','')
         PlayerPosition.figure = player.profession.getSceneFigure()
         position = player.baseInfo.getPosition()
         PlayerPosition.x = int(position[0])
         PlayerPosition.y = int(position[1])
         PlayerPosition.level = player.level.getLevel()
         PlayerPosition.viptype = player.baseInfo.getType()
         PlayerPosition.gemlevel = player.pack._equipmentSlot.getGemLevel()
         PlayerPosition.currentHP = player.attribute.getHp()
         PlayerPosition.MaxHP = player.attribute.getMaxHp()
         ###############角色展示宠物的处理################
         player.pet.updatePetPosition(position)
         for petId in player.matrix._matrixSetting.values():
             if petId<=0:
                 continue
             pet = player.pet.getPet(petId)
             figure = pet.templateInfo['resourceid']
             position = pet.getPosition()
             PetPosition = sceneInfo.petInfo.add()
             PetPosition.id = petId
             PetPosition.name = pet.baseInfo.getName()
             PetPosition.profession = pet.baseInfo.getName()
             PetPosition.headicon = figure
             PetPosition.figure = figure
             PetPosition.x = int(position[0])
             PetPosition.y = int(position[1])
             PetPosition.masterId = playerId
             PetPosition.currentHP = pet.attribute.getHp()
             PetPosition.MaxHP = pet.attribute.getMaxHp()
     
     for monster in self._monsters.values():
         MonsterPosition = sceneInfo.MonsterPosition.add()
         MonsterPosition.id = monster.baseInfo.id
         MonsterPosition.profession = monster.formatInfo['name']
         MonsterPosition.figure  = monster.formatInfo['resourceid']
         MonsterPosition.name = monster.formatInfo['name']
         MonsterPosition.x = int(monster.baseInfo.getPosition()[0])
         MonsterPosition.y = int(monster.baseInfo.getPosition()[1])
         MonsterPosition.currentHP = monster.formatInfo['maxHp']
         MonsterPosition.MaxHP = monster.formatInfo['maxHp']
     sceneInfo.sceneId = self._id
     msg = sceneInfo.SerializeToString()
     pushApplyMessage(602,msg, [sendId])
Beispiel #4
0
    def pushNowScenePosition(self, sendId, playerID):
        '''推送在场景中当前的所有角色和怪物的坐标
        @param sendId: int 推送的目标ID
        '''
        self._canRec.add(playerID)
        sceneInfo = pushSceneMessage_pb2.pushSceneMessage()
        for playerId in self._playerlist:
            player = PlayersManager().getPlayerByID(playerId)
            PlayerPosition = sceneInfo.PlayerPosition.add()
            PlayerPosition.id = player.baseInfo.id
            PlayerPosition.name = player.baseInfo.getNickName()
            PlayerPosition.profession = player.profession.getProfessionName()
            PlayerPosition.headicon = player.profession.getFigure()
            GuildInfo = player.guild.getGuildInfo()
            if GuildInfo:
                PlayerPosition.guildname = GuildInfo.get('name', '')
            PlayerPosition.figure = player.profession.getSceneFigure()
            position = player.baseInfo.getPosition()
            PlayerPosition.x = int(position[0])
            PlayerPosition.y = int(position[1])
            PlayerPosition.level = player.level.getLevel()
            PlayerPosition.viptype = player.baseInfo.getType()
            PlayerPosition.gemlevel = player.pack._equipmentSlot.getGemLevel()
            PlayerPosition.currentHP = player.attribute.getHp()
            PlayerPosition.MaxHP = player.attribute.getMaxHp()
            ###############角色展示宠物的处理################
            player.pet.updatePetPosition(position)
            for petId in player.matrix._matrixSetting.values():
                if petId <= 0:
                    continue
                pet = player.pet.getPet(petId)
                figure = pet.templateInfo['resourceid']
                position = pet.getPosition()
                PetPosition = sceneInfo.petInfo.add()
                PetPosition.id = petId
                PetPosition.name = pet.baseInfo.getName()
                PetPosition.profession = pet.baseInfo.getName()
                PetPosition.headicon = figure
                PetPosition.figure = figure
                PetPosition.x = int(position[0])
                PetPosition.y = int(position[1])
                PetPosition.masterId = playerId
                PetPosition.currentHP = pet.attribute.getHp()
                PetPosition.MaxHP = pet.attribute.getMaxHp()

        for monster in self._monsters.values():
            MonsterPosition = sceneInfo.MonsterPosition.add()
            MonsterPosition.id = monster.baseInfo.id
            MonsterPosition.profession = monster.formatInfo['name']
            MonsterPosition.figure = monster.formatInfo['resourceid']
            MonsterPosition.name = monster.formatInfo['name']
            MonsterPosition.x = int(monster.baseInfo.getPosition()[0])
            MonsterPosition.y = int(monster.baseInfo.getPosition()[1])
            MonsterPosition.currentHP = monster.formatInfo['maxHp']
            MonsterPosition.MaxHP = monster.formatInfo['maxHp']
        sceneInfo.sceneId = self._id
        msg = sceneInfo.SerializeToString()
        pushApplyMessage(602, msg, [sendId])
Beispiel #5
0
 def pushSceneInfo(self,rate):
     '''给每一个在场景中的玩家推送场景信息
     @param rate: int 移动的频率
     '''
     if not self._playerlist:
         return
     self.updateAllPlayerLocation(rate)
     if self._monsters:
         self.updateAllMonsterLocation()
     sendlist = self.getSendList()
     sceneInfo = pushSceneMessage_pb2.pushSceneMessage()
     for playerId in self._playerlist:
         player = PlayersManager().getPlayerByID(playerId)
         PlayerPosition = sceneInfo.PlayerPosition.add()
         PlayerPosition.id = player.baseInfo.id
         PlayerPosition.name = player.baseInfo.getNickName()
         PlayerPosition.profession = player.profession.getProfessionName()
         PlayerPosition.headicon = player.profession.getFigure()
         GuildInfo = player.guild.getGuildInfo()
         if GuildInfo:
             PlayerPosition.guildname = GuildInfo.get('name','')
         PlayerPosition.figure = player.profession.getSceneFigure()
         position = player.baseInfo.getDestination()
         PlayerPosition.x = int(position[0])
         PlayerPosition.y = int(position[1])
         PlayerPosition.level = player.level.getLevel()
         PlayerPosition.viptype = player.baseInfo.getType()
         PlayerPosition.gemlevel = player.pack._equipmentSlot.getGemLevel()
         PlayerPosition.currentHP = player.attribute.getHp()
         PlayerPosition.MaxHP = player.attribute.getMaxHp()
         ###############角色展示宠物的处理################
         petremove = player.pet.popLastRemove()
         for petId in petremove:
             self.dropPet(petId)
         for petId in player.matrix._matrixSetting.values():
             if petId<=0:
                 continue
             pet = player.pet.getPet(petId)
             figure = pet.templateInfo['resourceid']
             position = pet.getPosition()
             PetPosition = sceneInfo.petInfo.add()
             PetPosition.id = petId
             PetPosition.name = pet.baseInfo.getName()
             PetPosition.profession = pet.baseInfo.getName()
             PetPosition.headicon = figure
             PetPosition.figure = figure
             PetPosition.x = int(position[0])
             PetPosition.y = int(position[1])
             PetPosition.masterId = playerId
             PetPosition.currentHP = pet.attribute.getHp()
             PetPosition.MaxHP = pet.attribute.getMaxHp()
             
     for monster in self._monsters.values():
         MonsterPosition = sceneInfo.MonsterPosition.add()
         MonsterPosition.id = monster.baseInfo.id
         MonsterPosition.profession = monster.formatInfo['name']
         MonsterPosition.figure  = monster.formatInfo['resourceid']
         MonsterPosition.name = monster.formatInfo['name']
         MonsterPosition.x = int(monster.baseInfo.getPosition()[0])
         MonsterPosition.y = int(monster.baseInfo.getPosition()[1])
         MonsterPosition.currentHP = monster.formatInfo['maxHp']
         MonsterPosition.MaxHP = monster.formatInfo['maxHp']
     sceneInfo.sceneId = self._id
     msg = sceneInfo.SerializeToString()
     pushApplyMessage(602,msg, sendlist)
Beispiel #6
0
    def pushNowScenePosition(self,sendId,playerID):
        '''推送在场景中当前的所有角色和怪物的坐标
        @param sendId: int 推送的目标ID
        '''
        self._canRec.add(playerID)
        for room in self.rooms:
            if playerID not in room:
                continue
            sceneInfo = pushSceneMessage_pb2.pushSceneMessage()
            for playerId in room:
                player = PlayersManager().getPlayerByID(playerId)
                if not player:
                    continue
                PlayerPosition = sceneInfo.PlayerPosition.add()
                PlayerPosition.id = player.baseInfo.id
                PlayerPosition.name = player.baseInfo.getNickName()
                PlayerPosition.profession = player.profession.getProfessionName()
                PlayerPosition.headicon = player.profession.getFigure()
                GuildInfo = player.guild.getGuildInfo()
                if GuildInfo:
                    PlayerPosition.guildname = GuildInfo.get('name','')
                PlayerPosition.figure = player.profession.getSceneFigure()
                position = player.baseInfo.getPosition()
                PlayerPosition.x = int(position[0])
                PlayerPosition.y = int(position[1])
                PlayerPosition.level = player.level.getLevel()
                PlayerPosition.viptype = player.baseInfo.getType()
                PlayerPosition.gemlevel = player.pack._equipmentSlot.getGemLevel()
                ###############角色展示宠物的处理################
                player.pet.updatePetPosition(position)
                for petId in player.matrix._matrixSetting.values():
                    if petId<=0:
                        continue
                    pet = player.pet.getPet(petId)
                    figure = pet.templateInfo['resourceid']
                    position = pet.getPosition()
                    PetPosition = sceneInfo.petInfo.add()
                    PetPosition.id = petId
                    PetPosition.name = pet.baseInfo.getName()
                    PetPosition.profession = pet.baseInfo.getName()
                    PlayerPosition.headicon = figure
                    PetPosition.figure = figure
                    PetPosition.x = int(position[0])
                    PetPosition.y = int(position[1])
                    PetPosition.masterId = playerId
#                for petId in player.pet._pets.keys():
#                    pet = player.pet.getPet(petId)
#                    flowFlag = pet.getFlowFlag()
#                    if not flowFlag:
#                        continue
#                    figure = pet._baseInfo['resourceid']
#                    position = pet.getPosition()
#                    PetPosition = sceneInfo.petInfo.add()
#                    PetPosition.id = petId
#                    PetPosition.name = pet.getName()
#                    PetPosition.profession = pet.getName()
#                    PetPosition.figure = figure
#                    PetPosition.x = int(position[0])
#                    PetPosition.y = int(position[1])
            sceneInfo.sceneId = self._id
            msg = sceneInfo.SerializeToString()
            pushApplyMessage(602,msg, [sendId])
            return
Beispiel #7
0
    def pushSceneInfo(self, rate):
        '''给每一个在场景中的玩家推送场景信息
        @param rate: int 移动的频率
        '''
        if not self._canRec:
            return
        self.updateAllPlayerLocation(rate)
        if self._monsters:
            self.updateAllMonsterLocation()

        groupState = configure.isteamInstanceTime(20)  #组队副本时间判断
        guildFightState = fortress.IsWarTime()  #国战时间判断

        for room in self.rooms:
            sendlist = []
            sceneInfo = pushSceneMessage_pb2.pushSceneMessage()
            for playerId in room:
                player = PlayersManager().getPlayerByID(playerId)
                if not player:
                    continue
                player.icon.groupIconManager(groupState)  #组队战图标管理
                player.icon.guildFightManager(guildFightState)  #国战图标管理
                PlayerPosition = sceneInfo.PlayerPosition.add()
                PlayerPosition.id = player.baseInfo.id
                PlayerPosition.name = player.baseInfo.getNickName()
                PlayerPosition.profession = player.profession.getProfessionName(
                )
                PlayerPosition.headicon = player.profession.getFigure()
                GuildInfo = player.guild.getGuildInfo()
                if GuildInfo:
                    PlayerPosition.guildname = GuildInfo.get('name', '')
                PlayerPosition.figure = player.profession.getSceneFigure()
                position = player.baseInfo.getDestination()
                PlayerPosition.x = int(position[0])
                PlayerPosition.y = int(position[1])
                PlayerPosition.level = player.level.getLevel()
                PlayerPosition.viptype = player.baseInfo.getType()
                PlayerPosition.gemlevel = player.pack._equipmentSlot.getGemLevel(
                )
                sendlist.append(player.getDynamicId())
                ###############角色展示宠物的处理################
                petremove = player.pet.popLastRemove()
                for petId in petremove:
                    self.dropPet(petId)
                for petId in player.matrix._matrixSetting.values():
                    if petId <= 0:
                        continue
                    pet = player.pet.getPet(petId)
                    figure = pet.templateInfo['resourceid']
                    position = pet.getPosition()
                    PetPosition = sceneInfo.petInfo.add()
                    PetPosition.id = petId
                    PetPosition.name = pet.baseInfo.getName()
                    PetPosition.profession = pet.baseInfo.getName()
                    PetPosition.headicon = figure
                    PetPosition.figure = figure
                    PetPosition.x = int(position[0])
                    PetPosition.y = int(position[1])
                    PetPosition.masterId = playerId
            sceneInfo.sceneId = self._id
            msg = sceneInfo.SerializeToString()
            pushApplyMessage(602, msg, sendlist)
Beispiel #8
0
    def pushNowScenePosition(self, sendId, playerID):
        '''推送在场景中当前的所有角色和怪物的坐标
        @param sendId: int 推送的目标ID
        '''
        self._canRec.add(playerID)
        for room in self.rooms:
            if playerID not in room:
                continue
            sceneInfo = pushSceneMessage_pb2.pushSceneMessage()
            for playerId in room:
                player = PlayersManager().getPlayerByID(playerId)
                if not player:
                    continue
                PlayerPosition = sceneInfo.PlayerPosition.add()
                PlayerPosition.id = player.baseInfo.id
                PlayerPosition.name = player.baseInfo.getNickName()
                PlayerPosition.profession = player.profession.getProfessionName(
                )
                PlayerPosition.headicon = player.profession.getFigure()
                GuildInfo = player.guild.getGuildInfo()
                if GuildInfo:
                    PlayerPosition.guildname = GuildInfo.get('name', '')
                PlayerPosition.figure = player.profession.getSceneFigure()
                position = player.baseInfo.getPosition()
                PlayerPosition.x = int(position[0])
                PlayerPosition.y = int(position[1])
                PlayerPosition.level = player.level.getLevel()
                PlayerPosition.viptype = player.baseInfo.getType()
                PlayerPosition.gemlevel = player.pack._equipmentSlot.getGemLevel(
                )
                ###############角色展示宠物的处理################
                player.pet.updatePetPosition(position)
                for petId in player.matrix._matrixSetting.values():
                    if petId <= 0:
                        continue
                    pet = player.pet.getPet(petId)
                    figure = pet.templateInfo['resourceid']
                    position = pet.getPosition()
                    PetPosition = sceneInfo.petInfo.add()
                    PetPosition.id = petId
                    PetPosition.name = pet.baseInfo.getName()
                    PetPosition.profession = pet.baseInfo.getName()
                    PlayerPosition.headicon = figure
                    PetPosition.figure = figure
                    PetPosition.x = int(position[0])
                    PetPosition.y = int(position[1])
                    PetPosition.masterId = playerId
#                for petId in player.pet._pets.keys():
#                    pet = player.pet.getPet(petId)
#                    flowFlag = pet.getFlowFlag()
#                    if not flowFlag:
#                        continue
#                    figure = pet._baseInfo['resourceid']
#                    position = pet.getPosition()
#                    PetPosition = sceneInfo.petInfo.add()
#                    PetPosition.id = petId
#                    PetPosition.name = pet.getName()
#                    PetPosition.profession = pet.getName()
#                    PetPosition.figure = figure
#                    PetPosition.x = int(position[0])
#                    PetPosition.y = int(position[1])
            sceneInfo.sceneId = self._id
            msg = sceneInfo.SerializeToString()
            pushApplyMessage(602, msg, [sendId])
            return
Beispiel #9
0
    def pushSceneInfo(self, rate):
        '''给每一个在场景中的玩家推送场景信息
        @param rate: int 移动的频率
        '''
        if not self._playerlist:
            return
        self.updateAllPlayerLocation(rate)
        if self._monsters:
            self.updateAllMonsterLocation()
        sendlist = self.getSendList()
        sceneInfo = pushSceneMessage_pb2.pushSceneMessage()
        for playerId in self._playerlist:
            player = PlayersManager().getPlayerByID(playerId)
            PlayerPosition = sceneInfo.PlayerPosition.add()
            PlayerPosition.id = player.baseInfo.id
            PlayerPosition.name = player.baseInfo.getNickName()
            PlayerPosition.profession = player.profession.getProfessionName()
            PlayerPosition.headicon = player.profession.getFigure()
            GuildInfo = player.guild.getGuildInfo()
            if GuildInfo:
                PlayerPosition.guildname = GuildInfo.get('name', '')
            PlayerPosition.figure = player.profession.getSceneFigure()
            position = player.baseInfo.getDestination()
            PlayerPosition.x = int(position[0])
            PlayerPosition.y = int(position[1])
            PlayerPosition.level = player.level.getLevel()
            PlayerPosition.viptype = player.baseInfo.getType()
            PlayerPosition.gemlevel = player.pack._equipmentSlot.getGemLevel()
            PlayerPosition.currentHP = player.attribute.getHp()
            PlayerPosition.MaxHP = player.attribute.getMaxHp()
            ###############角色展示宠物的处理################
            petremove = player.pet.popLastRemove()
            for petId in petremove:
                self.dropPet(petId)
            for petId in player.matrix._matrixSetting.values():
                if petId <= 0:
                    continue
                pet = player.pet.getPet(petId)
                figure = pet.templateInfo['resourceid']
                position = pet.getPosition()
                PetPosition = sceneInfo.petInfo.add()
                PetPosition.id = petId
                PetPosition.name = pet.baseInfo.getName()
                PetPosition.profession = pet.baseInfo.getName()
                PetPosition.headicon = figure
                PetPosition.figure = figure
                PetPosition.x = int(position[0])
                PetPosition.y = int(position[1])
                PetPosition.masterId = playerId
                PetPosition.currentHP = pet.attribute.getHp()
                PetPosition.MaxHP = pet.attribute.getMaxHp()

        for monster in self._monsters.values():
            MonsterPosition = sceneInfo.MonsterPosition.add()
            MonsterPosition.id = monster.baseInfo.id
            MonsterPosition.profession = monster.formatInfo['name']
            MonsterPosition.figure = monster.formatInfo['resourceid']
            MonsterPosition.name = monster.formatInfo['name']
            MonsterPosition.x = int(monster.baseInfo.getPosition()[0])
            MonsterPosition.y = int(monster.baseInfo.getPosition()[1])
            MonsterPosition.currentHP = monster.formatInfo['maxHp']
            MonsterPosition.MaxHP = monster.formatInfo['maxHp']
        sceneInfo.sceneId = self._id
        msg = sceneInfo.SerializeToString()
        pushApplyMessage(602, msg, sendlist)