本文整理汇总了Python中Character.Character.setPlayerId方法的典型用法代码示例。如果您正苦于以下问题:Python Character.setPlayerId方法的具体用法?Python Character.setPlayerId怎么用?Python Character.setPlayerId使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Character.Character
的用法示例。
在下文中一共展示了Character.setPlayerId方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: execute
# 需要导入模块: from Character import Character [as 别名]
# 或者: from Character.Character import setPlayerId [as 别名]
def execute(self, data):
try:
self.playerId = data.getString()
self.type = data.getUint16()
self.x = data.getFloat32()
self.y = data.getFloat32()
self.z = data.getFloat32()
#print "q"
char = Character(self.world, self.type)
char.actor.setPos(self.x,self.y,0)
char.setPlayerId(self.playerId)
charPresent = False
for charTemp in self.world.characters:
if charTemp.getPlayerId() == char.playerId:
charPresent = True
break
if not charPresent:
self.world.characters.append(char)
print "ResponseCreateCharacter - ", self.playerId, " x:", self.x, " y:", self.y," z:", self.z
#self.log('Received [' + str(Constants.RAND_STRING) + '] String Response')
except:
self.log('Bad [' + str(Constants.RAND_STRING) + '] String Response')
print_exc()
示例2: World
# 需要导入模块: from Character import Character [as 别名]
# 或者: from Character.Character import setPlayerId [as 别名]
class World(DirectObject):
currentTime = 0
idleTime = 0
mySequence = None
pandaPace = None
jumpState = False
isWalk = False
previousPos = None #used to store the mainChar pos from one frame to another
host = ""
port = 0
characters = [] #Stores the list of all the others players characters
def __init__(self):
# Network Setup
print "Object Created"
self.characters = []
def setConnectionManager(self, connectionManager):
self.cManager = connectionManager
def initWorld(self, playerId, chosenCharId, x, y, h):
self.keyMap = {"hello":0, "left":0, "right":0, "forward":0, "backward":0, "cam-left":0, "cam-right":0, "chat":0, "fast":0, "chat0": 0, "chat1": 0, "users": 0}
base.win.setClearColor(Vec4(0,0,0,1))
# chat box
self.chatbox = Chat(self.cManager, self)
self.activeUsers = Users(self.cManager, self)
taskMgr.add(self.message, 'message')
# Post the instructions
self.title = addTitle("Panda3D Tutorial: Roaming Ralph (Walking on the Moon)")
self.inst1 = addInstructions(0.95, "[ESC]: Quit")
self.inst2 = addInstructions(0.90, "[A]: Rotate Ralph Left")
self.inst3 = addInstructions(0.85, "[D]: Rotate Ralph Right")
self.inst4 = addInstructions(0.80, "[W]: Run Ralph Forward")
self.inst4 = addInstructions(0.75, "[S]: Run Ralph Backward")
self.inst6 = addInstructions(0.70, "[Left Arrow]: Rotate Camera Left")
self.inst7 = addInstructions(0.65, "[Right Arrow]: Rotate Camera Right")
self.inst8 = addInstructions(0.60, "[0]: Toggle Chat Broadcast")
self.inst9 = addInstructions(0.55, "[1]: Toggle Private Chat - username/")
self.inst10 = addInstructions(0.50, "[L]: List Connected Users")
# Set up the environment
#
self.environ = loader.loadModel("models/square")
self.environ.reparentTo(render)
self.environ.setPos(0,0,0)
self.environ.setScale(100,100,1)
self.moon_tex = loader.loadTexture("models/moon_1k_tex.jpg")
self.environ.setTexture(self.moon_tex, 1)
#Collision Code
# Initialize the collision traverser.
base.cTrav = CollisionTraverser()
# Initialize the Pusher collision handler.
self.pusher = CollisionHandlerPusher()
self.bTrav = base.cTrav
# Create the main character, Ralph
self.mainCharRef = Character(self, chosenCharId, True)
self.mainCharRef.setPlayerId(playerId)
self.characters.append(self.mainCharRef)
self.mainChar = self.mainCharRef.getActor()
#Create second bike
self.mainCharRef2 = Character(self, 3, True)
self.mainCharRef2.setPlayerId(2)
self.characters.append(self.mainCharRef2)
self.mainChar2 = self.mainCharRef2.getActor()
resetPos = True
if (x == 0 and y == 0):
resetPos = False
if resetPos:
self.mainChar.setPos(x, y, 0)
self.mainChar.setH(h)
self.cManager.sendRequest(Constants.CMSG_CREATE_CHARACTER, [playerId,
chosenCharId,
self.mainChar.getX(),
self.mainChar.getY(),
self.mainChar.getZ()])
self.previousPos = self.mainChar.getPos()
taskMgr.doMethodLater(.1, self.updateMove, 'updateMove')
# Creating Stationary spheres
self.spheres = []
self.sphereCount = 3
for x in range(self.sphereCount):
self.spheres.append(StationarySphere(self))
for sphere in self.spheres:
taskMgr.add(sphere.rotateForAll, "rotateSphere")
#.........这里部分代码省略.........