예제 #1
0
def init():
    print "init scene"
    global gVirtualSceneId, gSaveVirtualSceneId
    global gRealSceneKeeper, gSceneProxy, gGreenletLocal, gdSceneModule
    global gbInitScene
    gVirtualSceneId = u.guIdWithPostfix(0, 200,
                                        False)  # 不需要存盘的虚拟场景开始编号, 如2XX01
    gSaveVirtualSceneId = u.guIdWithPostfix(config.ZONE_NO, 200,
                                            False)  # 需要存盘的虚拟场景开始编号, 如2XX+区号
    gRealSceneKeeper = keeper.cKeeper()  # 永久场景实例存放处,临时场景的实例不在这里
    gSceneProxy = u.cKeyMapProxy()  # 永久场景与临时场景都可以在这里查找
    gGreenletLocal = gevent.local.local()

    # 场景类
    gdSceneModule = {
        "默认": scene.object.RealScene,  # 默认实场景
        "活动": scene.scenehd.Scene,  # 活动场景
        "仙盟": scene.sceneguild.Scene,  # 帮派场景
    }

    initScene()
    gbInitScene = True

    initSceneRandMapData()
예제 #2
0
#-*-coding:utf-8-*-
#作者:马昭@曹县闫店楼镇
import u
import c
import keeper
import gevent.event

if 'gbOnce' not in globals():
    gbOnce = True

    if 'sceneService' in SYS_ARGV:
        gEntityKeeper = keeper.cKeeper()  #实体实例存放处
        # gEntityProxy = u.cKeyMapProxy()#用主服务器的实体id关联实体对象
        gEnginerEntityProxy = u.cKeyMapProxy()  #用引擎层的实体id关联实体对象


#实体基类
class cEntity(object):
    def __init__(self, iScriptEttId, iEttType, sBaseSerialized):
        self.handle = zfmPyEx.createEntity(iEttType)
        if not self.handle:
            raise Exception, '实体创建失败'
        self.iScriptEttId = iScriptEttId  #脚本层id
        self.iEngineEttId = self.handle.iEttId  #引擎层的实体id
        self.iEttType = iEttType
        self.sBaseSerialized = sBaseSerialized  #序列化好的外观数据
        self.sEnterSerialized = ""
        self.sLeaveSerialized = ""
        gEnginerEntityProxy.addObj(self, self.iEngineEttId)
        self.iSceneId = 0
        self.x, self.y = 0, 0
예제 #3
0
# -*-coding:utf-8-*-
# 作者:马昭@曹县闫店楼镇
import u
import c
import entity
import keeper

if 'geTriggerNpc' not in globals():
    geTriggerNpc = u.cEvent()

if 'gNPCproxy' not in globals():
    gNPCproxy = u.cKeyMapProxy()


def newByType(iType):
    if iType not in gdNpcModule:
        raise Exception, '类型为{}的npc没有关联到gdNpcModule.'.format(iType)
    obj = gdNpcModule[iType].cNpc()
    return obj


def newByIdx(idx):
    '''根据编号生成固定npc
	'''
    info = npcData.gdData.get(idx)
    if not info:
        raise Exception, "找不到编号为{}的固定npc".format(idx)

    iType = info.get('类型', 100)
    npcObj = newByType(iType)
    npcObj.idx = idx
예제 #4
0
#-*-coding:utf-8-*-
#作者:马昭@曹县闫店楼镇 mail:[email protected]

import doorData
import entity
import u

if 'gDoorProxy' not in globals():
	gDoorProxy=u.cKeyMapProxy()

if 'gdDoorModule' not in globals():
	gdDoorModule={}

if 'gdBuffDoor' not in globals():
	gdBuffDoor={}

def getBuffDoor(iNo):
	return gdBuffDoor.get(iNo)

class cDoor(entity.cEntity):#传送门
	def __init__(self,iNo):
		entity.cEntity.__init__(self)
		self.iNo=iNo
		self.sSerialized1=None
		gDoorProxy.addObj(self,self.id)
		self.iState=1

	def ettType(self):#override
		return entity.ETT_TYPE_DOOR

	def setNo(self, iNo):
예제 #5
0
# -*- coding: utf-8 -*-
'''队伍相关
'''
import u

if "gTeamList" not in globals():
	gTeamList = u.cKeyMapProxy()  # 队伍列表
	
def makeTeam(who):
	'''创建队伍
	'''
	if checkDennyTeam(who, None, "组队"):
		return None

	teamObj = team.object.Team()
	teamObj.setLeader(who)
	team.platformservice.setTeamDefaultTarget(who, teamObj)
	team.service.rpcTeamInfo(teamObj)
	team.service.rpcTeamBroadcastMake(teamObj)
	gTeamList.addObj(teamObj, teamObj.id)
	return teamObj


def checkTeamDennyAdd(who, teamObj, opName, showTips=True):
	'''检查队伍能否加人
	'''
	denyMsg = ""
	roleLeader = getRole(teamObj.leader)
	sceneObj = scene.getScene(roleLeader.sceneId)
	if sceneObj and hasattr(sceneObj, "denyTeamAddMember"):
		if opName in ("自动匹配", "接受申请", "邀请入队"):
예제 #6
0
    oServer = gevent.server.StreamServer(('127.0.0.1', iListenPort),
                                         u.cFunctor(afterAccept, iListenPort))
    print('starting route server for back end on port {}'.format(iListenPort))
    return oServer


import keeper
import u

if 'gbOnce' not in globals():
    gbOnce = True

    if 'routeService' in SYS_ARGV:
        gBackEndKeeper = keeper.cKeeper()  #连接id 映射 连接对象

        gBackEndProxy = u.cKeyMapProxy()

import traceback
import gevent
import gevent.socket
import gevent.queue
import gevent
import gevent.server
import gevent.queue
import gevent.core
import universal.public_pb2

import config
import backEnd

import c
예제 #7
0
#-*-coding:utf-8-*-
#作者:马昭@曹县闫店楼镇
import u
import c
import keeper
import gevent.event

#SEE_AMOUNT=10 #每个人所能看到玩家的个数

if 'gbOnce' not in globals():
    gbOnce = True

    if 'sceneService' in SYS_ARGV:
        gSceneKeeper = keeper.cKeeper()  #场景实例存放处
        # gSceneProxy = u.cKeyMapProxy()#用主服务器的场景id关联场景对象
        gEnginerSceneProxy = u.cKeyMapProxy()  #用引擎层的实体id关联实体对象


#场景
class cScene(object):  #场景基类
    def __init__(self, iScriptSceneId, iWidth, iHeight, iRes, iBroadcastRole):
        self.iWidth, self.iHeight = iWidth, iHeight  #场景可行走区域的宽与高
        self.iRes = iRes
        self.iBroadcastRole = iBroadcastRole  #特殊处理是否能看到其它玩家(0:可以 1:不可以)
        #iPhone 6 Plus:1242*2208 -->49.68*88.32
        #iPad Retina:1546*2048 -->61.84*81.92
        #宽高都取最大-->61.84*88.32 各除以3-->20.6133*29.4399
        # iGridWidth,iGridHeight=30,21
        iGridWidth, iGridHeight = 45, 31  #底层用9宫格iGridWidth,iGridHeight=宽高都取最大-->61.84*88.32 各除以2
        #客户端的位置从1开始计算,所以传入底层的场景iWidth iHeight要加1
        if iGridWidth > self.iWidth + 1:
예제 #8
0
ETT_TYPE_ROLE = scene_pb2.INFO_ROLE  # 玩家
ETT_TYPE_DOOR = scene_pb2.INFO_DOOR  # 传送门
ETT_TYPE_NPC = scene_pb2.INFO_NPC  # npc

if 'gEntityId' not in globals():
    gEntityId = c.MAX_ROLE_ID  # 从最大的角色id之上递增


def newEntityId():
    global gEntityId
    gEntityId += 1
    return gEntityId


if 'gEntityProxy' not in globals():
    gEntityProxy = u.cKeyMapProxy()


# 实体基类(npc,怪物,传送点,血瓶,地上的道具等等场景上的实体)
class cEntity(object):
    shape = 0
    name = ""
    sceneId = 0
    x = 0
    y = 0
    d = 0  # 面向
    title = ""

    def __init__(self, oHolderScene=None):
        self.oHolderScene = weakref.proxy(
            oHolderScene.this()) if oHolderScene else None