本文整理汇总了Python中net.ConnectionManager.ConnectionManager.closeConnection方法的典型用法代码示例。如果您正苦于以下问题:Python ConnectionManager.closeConnection方法的具体用法?Python ConnectionManager.closeConnection怎么用?Python ConnectionManager.closeConnection使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类net.ConnectionManager.ConnectionManager
的用法示例。
在下文中一共展示了ConnectionManager.closeConnection方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: World
# 需要导入模块: from net.ConnectionManager import ConnectionManager [as 别名]
# 或者: from net.ConnectionManager.ConnectionManager import closeConnection [as 别名]
#.........这里部分代码省略.........
def usePowerup(self, task):
if self.keyMap["powerup"] == 1:
self.mainCharRef.usePowerup(0)
elif self.keyMap["powerup"] == 2:
self.mainCharRef.usePowerup(1)
elif self.keyMap["powerup"] == 3:
self.mainCharRef.usePowerup(2)
return task.cont
def createPowerups(self):
self.powerups = PowerupManager(self.cManager, self.characters)
def use_powerup3(self):
self.use_powerup(3)
def setTime(self):
self.cManager.sendRequest(Constants.CMSG_TIME)
def use_powerup(self, num):
if self.mainCharRef.power_ups[num - 1] == 0:
print "power-up slot empty"
else:
print "power-up", num, "used"
def doExit(self):
self.cleanup()
sys.exit(1)
def cleanup(self):
self.cManager.sendRequest(Constants.CMSG_DISCONNECT)
self.cManager.closeConnection()
self.world = None
self.outsideWorldRender.removeNode()
def doReset(self):
self.mainCharRef.reset()
def enterGame(self, task):
if self.gameState == self.gameStateDict["Login"]:
#responseValue = 1 indicates that this state has been finished
if self.responseValue == 1:
# Authentication succeeded
self.cManager.sendRequest(Constants.CMSG_CREATE_LOBBY, ["raceroyal","0","1"])
self.gameState = self.gameStateDict["CreateLobby"]
self.responseValue = -1
elif self.gameState == self.gameStateDict["CreateLobby"]:
if self.responseValue == 1:
# Lobby Created and we are already in
self.gameState = self.gameStateDict["EnterGame"]
self.responseValue = -1
elif self.responseValue == 0:
#Game already created, let's join it
self.cManager.sendRequest(Constants.CMSG_ENTER_GAME_NAME, "raceroyal")
self.gameState = self.gameStateDict["EnterGame"]
self.responseValue = -1
elif self.gameState == self.gameStateDict["EnterGame"]:
if self.responseValue == 1:
# When the positions are sent, an acknowledgment is sent and we begin the InitializeGame
self.responseValue = -1
self.gameState = self.gameStateDict["InitializeGame"]
# Everyone is in the game, we send ReqReady, and the server will send positions when every client did
self.cManager.sendRequest(Constants.CMSG_READY)
示例2: World
# 需要导入模块: from net.ConnectionManager import ConnectionManager [as 别名]
# 或者: from net.ConnectionManager.ConnectionManager import closeConnection [as 别名]
#.........这里部分代码省略.........
def usePowerup(self, task):
if self.keyMap["powerup"] == 1:
self.mainCharRef.usePowerup(0)
elif self.keyMap["powerup"] == 2:
self.mainCharRef.usePowerup(1)
elif self.keyMap["powerup"] == 3:
self.mainCharRef.usePowerup(2)
return task.cont
def createPowerups(self):
self.powerups = PowerupManager(self.cManager, self.characters)
def use_powerup3(self):
self.use_powerup(3)
def setTime(self):
self.cManager.sendRequest(Constants.CMSG_TIME)
def use_powerup(self, num):
if self.mainCharRef.power_ups[num - 1] == 0:
print "power-up slot empty"
else:
print "power-up", num, "used"
def doExit(self):
self.cleanup()
sys.exit(1)
def cleanup(self):
self.cManager.sendRequest(Constants.CMSG_DISCONNECT)
self.cManager.closeConnection()
self.world = None
self.outsideWorldRender.removeNode()
def doReset(self):
self.mainCharRef.reset()
def enterGame(self, task):
self.startGameNow()
return task.done
if self.gameState == self.gameStateDict["Login"]:
#responseValue = 1 indicates that this state has been finished
if self.responseValue == 1:
# Authentication succeeded
#self.cManager.sendRequest(Constants.CMSG_CREATE_LOBBY, ["raceroyal","0","1"])
self.gameState = self.gameStateDict["CreateLobby"]
#self.responseValue = -1
elif self.gameState == self.gameStateDict["CreateLobby"]:
if self.responseValue == 1:
print "Lobby Created and we are already in"
# Lobby Created and we are already in
self.gameState = self.gameStateDict["EnterGame"]
self.responseValue = -1
elif self.responseValue == 0:
print "Game already created, let's join it"
#Game already created, let's join it
self.cManager.sendRequest(Constants.CMSG_ENTER_GAME_NAME, "raceroyal")
self.gameState = self.gameStateDict["EnterGame"]
self.responseValue = -1
self.startGameNow()
#self.gameState = self.gameStateDict["InitializeGame"]
# Everyone is in the game, we send ReqReady, and the server will send positions when every client did
#self.cManager.sendRequest(Constants.CMSG_READY)