Exemple #1
0
def enterPlace_601(dynamicId, characterId, placeId,force,player):
    '''进入场景'''
    state = 0
    if not player:
        player = PlayerCharacter(characterId,dynamicId = dynamicId)
        player.setlastOnline(datetime.datetime.now())
        pushPlayerGonggaoXinxi(player)
    else:
        player = cPickle.loads(player)
        player.startAllTimer()
        state = 1
    #判断是否满足进入场景的需求
    sceneInfo = dbMap.ALL_MAP_INFO.get(placeId,{})
    levelRequired = sceneInfo['level']
    if player.level.getLevel()<sceneInfo['level']:
        msg = Lg().g(607)%levelRequired
        pushOtherMessage(905, msg, [dynamicId])
        return {'result':False,'message':Lg().g(332)}
    player.baseInfo.setTown( placeId)
    player.baseInfo.setState(0)
    PlayersManager().addPlayer(player)
    defencelog_app.isReward(player.baseInfo.id, player.getDynamicId())
    scene = MapManager().getMapId(placeId)
    scenename = scene.getSceneName()
    chatnoderemote.callRemote('JoinRoom',characterId,placeId,scenename)
    scene.addPlayer(characterId)
    player.quest.setNpcList(scene._npclist)
    scene.pushEnterPlace([dynamicId])
#    if not state:
#        publicnoderemote.callRemote('addPcharacter',characterId,getNodeId())
#    else:
#        publicnoderemote.callRemote('updatePCharacterNodeId',characterId,getNodeId())
    return {'result':True,'message':'','data':{'placeId':placeId}}
def tiaozhuan(dynamicId,characterid,csz):
    '''场景间的跳转或者进入副本
    '''
    player = PlayersManager().getPlayerByID(characterid)
    if not player:
        return {'result':False,'message':Lg().g(18)}
    doorinfo = dbMap.ALL_DOOR_INFO.get(csz)#获取传送门的信息
    lastscene = MapManager().getMapId(player.baseInfo.getTown())
    if doorinfo.get('functionType')==1:#跳转场景
        placeId = doorinfo.get('nextmap')
        position = (doorinfo.get('init_x'),doorinfo.get('init_y'))
        player.baseInfo.setTown( placeId)
        player.baseInfo.setState(0)
        PlayersManager().addPlayer(player)
        defencelog_app.isReward(player.baseInfo.id, player.getDynamicId())
        scene = MapManager().getMapId(placeId)
        scenename = scene.getSceneName()
        chatnoderemote.callRemote('JoinRoom',characterid,placeId,scenename)
        scene.addPlayer(characterid)
        player.quest.setNpcList(scene._npclist)
        player.baseInfo.initPosition(position)
        scene.pushEnterPlace([dynamicId])
        result = {'result':True}
    else:
        instanceId = doorinfo.get('famID')
        result = instance_app.enterInstance1(player,dynamicId, characterid, instanceId,0)
    if result.get('result'):
        lastscene.dropPlayer(characterid)