本文整理汇总了Python中unit.Unit.__init__方法的典型用法代码示例。如果您正苦于以下问题:Python Unit.__init__方法的具体用法?Python Unit.__init__怎么用?Python Unit.__init__使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类unit.Unit
的用法示例。
在下文中一共展示了Unit.__init__方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
# 需要导入模块: from unit import Unit [as 别名]
# 或者: from unit.Unit import __init__ [as 别名]
def __init__(self, player, sig, model, skeleton, animations, inventory):
'''
Constructor
'''
Unit.__init__(player, sig, numControllers = 1)
self.player = player
self.enabled = False
示例2: __init__
# 需要导入模块: from unit import Unit [as 别名]
# 或者: from unit.Unit import __init__ [as 别名]
def __init__(self, mainObj, position, yon=4, layer=0, attrDict={}):
self.type = 'Kurt'
Unit.__init__(self, mainObj, position, yon, attrDict)
self.image = self.changeImage('Kurt', yon) # Oyunun başında ilk yüklenen unit resim dosyasi
self.rect = self.image.get_rect()
self.rect.topleft = position
self.layer = layer # LayeredUpdates grubu için gerekiyor
self.colRect = copy(Kurt.colRect[self.yon])
self.colRect.topleft = (self.colRect.topleft[0] + self.rect.topleft[0], self.colRect.topleft[1] + self.rect.topleft[1])
# çarpışmalarda kullanılan noktalar
self.colPoints = None
self.tolerans = 0
self.speed = 4
if self.player.type == Player.human_player:
self.ai = KurtFSM(self, human=True)
else:
self.ai = KurtFSM(self)
# unit'in gerçek pozisyonunu (reel sayılarla) tutar. rect'e atılırken int'e dönüştürülür.
self.yer = Vector2(*self.colRect.center)
示例3: __init__
# 需要导入模块: from unit import Unit [as 别名]
# 或者: from unit.Unit import __init__ [as 别名]
def __init__(self, mainRef, attributes):
print("Enemy instantiated")
Unit.__init__(self)
FSM.__init__(self, 'playerFSM')
self._mainRef = mainRef
self._playerRef = mainRef.player
self._AIworldRef = mainRef.AIworld
self._enemyListRef = mainRef.enemyList
self._ddaHandlerRef = mainRef.DDAHandler
self._stateHandlerRef = mainRef.stateHandler
self._scenarioHandlerRef = mainRef.scenarioHandler
#self.topEnemyNode = mainRef.mainNode.attachNewNode('topEnemyNode')
self.initEnemyNode(mainRef.mainNode)
utils.enemyDictionary[self.enemyNode.getName()] = self
self.loadEnemyModel(attributes.modelName)
self.initAttributes(attributes)
self.initEnemyAi()
self.initEnemyDDA()
self.initEnemyCollisionHandlers()
self.initEnemyCollisionSolids()
#self.request('Idle')
self.request('Disabled')
# Start enemy updater task
self.enemyUpdaterTask = taskMgr.add(self.enemyUpdater, 'enemyUpdaterTask')
示例4: __init__
# 需要导入模块: from unit import Unit [as 别名]
# 或者: from unit.Unit import __init__ [as 别名]
def __init__(self, constraint, x=0, y=0, direction=(1, 0), kind=0):
Unit.__init__(self, constraint, x, y, direction, 160, 65)
if kind:
self.kind = 'lion'
self.health = 200
else:
self.kind = 'blue'
self.health = 100
示例5: __init__
# 需要导入模块: from unit import Unit [as 别名]
# 或者: from unit.Unit import __init__ [as 别名]
def __init__(self, models = None, anims = None, sphereString = None, game = None, xStart = 0, yStart = 0, zStart = 0):
Unit.__init__(self, models, anims, sphereString, game, xStart, yStart, zStart)
#set up sounds
self.deathSound = game.loader.loadSfx(SFX_PATH + "enemy_death.wav")
self.randomMovement = 0
self.randomMovementMax = 30 * 7
self.minRandomVel = 1000
self.maxRandomVel = 2000
示例6: __init__
# 需要导入模块: from unit import Unit [as 别名]
# 或者: from unit.Unit import __init__ [as 别名]
def __init__(self, name, title, health, mana, mana_regen):
self.name = name
self.title = title
self.mana_regen = mana_regen
Unit.__init__(self, health, mana, name)
self.phisical_damage = 0
self.magic_damage = 0
self.max_equiped_weapons = 0
self.max_learned_spells = 0
示例7: __init__
# 需要导入模块: from unit import Unit [as 别名]
# 或者: from unit.Unit import __init__ [as 别名]
def __init__(self, team, sig, model, numControllers, keyinput):
'''
Constructor
'''
self.input = keyinput
self.model = loader.loadModel(model)
tankNode = render.attachNewNode(ActorNode("tank-physics"))
tankNode.detachNode()
self.tankNode = tankNode
actorNode = tankNode.node()
base.physicsMgr.attachPhysicalNode(actorNode)
actorNode.getPhysicsObject().setMass(1000)
fromObject = tankNode.attachNewNode(CollisionNode('tank-coll'))
fromObject.node().addSolid(CollisionSphere(0, 0, 0, 1))
self.model.reparentTo(tankNode)
pusher = PhysicsCollisionHandler()
pusher.addCollider(fromObject,tankNode)
base.cTrav.addCollider(fromObject, pusher)
fromObject.show()
Unit.__init__(self, sig, numControllers)
self.enabled = False
self.camera = VehicleCamera(self.tankNode, Vec3(0,-10,5))
self.rotation = Rotation(self.tankNode, self.camera.camNode)
self.engineFN=ForceNode('tank-hover-engine-front-left')
self.engineFNP=tankNode.attachNewNode(self.engineFN)
self.engineNodes = [NodePath("front-left-engine") ,
NodePath("front-right-engine"),
NodePath("back-left-engine") ,
NodePath("back-right-engine") ]
for i in range(0,4):
self.engineNodes[i].reparentTo(tankNode)
self.engineNodes[i].setPos(tankNode, ENGINELIST[i])
blah = loader.loadModel(model)
blah.reparentTo(self.engineNodes[i])
blah.setScale(0.1)
self.linearForce = None
self.rotateForce = None
self.movement = Movement(tankNode)
self.movement.enable()
示例8: __init__
# 需要导入模块: from unit import Unit [as 别名]
# 或者: from unit.Unit import __init__ [as 别名]
def __init__(self, constraint, x=0, y=0, direction=(1, 0), size=0):
radius = (size * 15 + 41) / 2
Unit.__init__(self, constraint, x, y, direction, 80, radius)
SinkingItem.__init__(self, constraint, x, y, 80, radius)
self.hungry = False
self.growth = 0
# Fish size: 0 - small, 1 - normal, 2 - big
self.size = size
self.last_fed = int(time())
self.grow_time = int(time())
self.drop_coin = False
# Prevents multiple coin drops in the same second.
self.coin_drop_time = time()
示例9: __init__
# 需要导入模块: from unit import Unit [as 别名]
# 或者: from unit.Unit import __init__ [as 别名]
def __init__(self, team, sig, model, numControllers, keyinput):
'''
Constructor
'''
self.input = keyinput
self.model = loader.loadModel(model)
tankNode = render.attachNewNode(ActorNode("tank-physics"))
tankNode.detachNode()
self.tankNode = tankNode
actorNode = tankNode.node()
base.physicsMgr.attachPhysicalNode(actorNode)
actorNode.getPhysicsObject().setMass(1000)
fromObject = tankNode.attachNewNode(CollisionNode('tank-coll'))
fromObject.node().addSolid(CollisionSphere(0, 0, 0, 1))
self.model.reparentTo(tankNode)
pusher = PhysicsCollisionHandler()
pusher.addCollider(fromObject,tankNode)
base.cTrav.addCollider(fromObject, pusher)
fromObject.show()
Unit.__init__(self, sig, numControllers)
self.enabled = False
self.camera = VehicleCamera(self.tankNode, Vec3(0,-10,5))
self.rotation = Rotation(self.tankNode, self.camera.camNode)
self.engineFN=ForceNode('tank-engine')
self.engineFNP=tankNode.attachNewNode(self.engineFN)
self.upForce=LinearVectorForce(0,0,20000)
self.upForce.setMassDependent(1)
self.engineFN.addForce(self.upForce)
base.physicsMgr.addLinearForce(self.upForce)
示例10: __init__
# 需要导入模块: from unit import Unit [as 别名]
# 或者: from unit.Unit import __init__ [as 别名]
def __init__(self, mainRef):
print("Player instantiated")
Unit.__init__(self)
FSM.__init__(self, 'playerFSM')
self._hudRef = None
self._mainRef = mainRef
self._enemyListRef = mainRef.enemyList
self._ddaHandlerRef = mainRef.DDAHandler
self._mapHandlerRef = mainRef.mapHandler
self._stateHandlerRef = mainRef.stateHandler
self._scenarioHandlerRef = mainRef.scenarioHandler
self.playerNode = mainRef.mainNode.attachNewNode('playerNode')
self.initPlayerAttributes()
self.initPlayerModel()
self.initPlayerCamera()
self.initPlayerAbilities()
self.initPlayerCollisionHandlers()
self.initPlayerCollisionSolids()
self.initPlayerDDA()
# Start mouse picking and movement
self.mouseHandler = utils.MouseHandler(self)
# Start player update task
playerUpdateTask = taskMgr.add(self.playerUpdate, 'playerUpdateTask')
# Initialize player FSM state
self.request('Idle')
DO = DirectObject()
DO.accept('shift-mouse1', self.onShiftDown)
DO.accept('shift-up', self.onShiftUp)
self._shiftButtonDown = False
示例11: __init__
# 需要导入模块: from unit import Unit [as 别名]
# 或者: from unit.Unit import __init__ [as 别名]
def __init__(self, uid, pos, images):
Unit.__init__(self, pos, images, 400, 15, 15, uid, CPCB, CORB, 10)
示例12: __init__
# 需要导入模块: from unit import Unit [as 别名]
# 或者: from unit.Unit import __init__ [as 别名]
def __init__(self, xmldoc):
Unit.__init__(self)
# This is a combat vehicle
self.type = "CV"
# Get top-level structure data
for cveh in xmldoc.getElementsByTagName('combatvehicle'):
self.model = cveh.attributes["model"].value
self.name = cveh.attributes["name"].value
self.motive = cveh.attributes["motive"].value
self.omni = cveh.attributes["omni"].value
self.weight = int(cveh.attributes["tons"].value)
# Get BV. Should give prime variant BV for Omni-vehicles
# get first instance only to avoid problems with Omni-vehicles
self.batt_val = int(get_child_data(cveh, 'battle_value'))
# Motive
for mot in cveh.getElementsByTagName('motive'):
self.mot_type = mot.attributes["type"].value
self.cruise = int(mot.attributes["cruise"].value)
self.turret = mot.attributes["turret"].value
# Get Cost.
cost = float(get_child_data(cveh, 'cost'))
# Get production era
self.prod_era = int(get_child_data(cveh, 'productionera'))
# Get techbase (IS, Clan)
# get first instance only to avoid problems with Omni-vehicles
self.techbase = get_child_data(cveh, 'techbase')
# Get year
self.year = int(get_child_data(cveh, 'year'))
# Sanity check for year
year_era_test(self.year, self.prod_era,
self.name + " " + self.model)
if (self.year < 2470):
print self.name, self.model
print "Combat Vehicles not available before 2470!"
sys.exit(1)
if (self.year < 2854 and self.omni == "TRUE"):
print self.name, self.model
print "OmniVehicles not available before 2854!"
sys.exit(1)
### Components starts here ###
self.structure = VehicleStructure(get_child(cveh, 'structure'),
self.weight,
self.mot_type, self.turret)
self.engine = Engine(get_child(cveh, 'engine'), self)
self.lift = LiftEquipment(self.weight, self.mot_type)
if self.engine.etype == "No Engine":
self.control = ControlSystems(0.0)
else:
self.control = ControlSystems(self.weight)
self.armor = VehicleArmor(get_child(cveh, 'armor'),
self.weight)
### Loadout stuff starts here ###
# Get baseloadout
blo = cveh.getElementsByTagName('baseloadout')[0]
# Construct current loadout, empty name for base loadout
self.load = Baseloadout(blo, self, self.batt_val,
self.prod_era, cost)
# Get omni loadouts
self.loads = []
for load in cveh.getElementsByTagName('loadout'):
# Construct current loadout
current = Loadout(load, self.load, self)
self.loads.append(current)
示例13: __init__
# 需要导入模块: from unit import Unit [as 别名]
# 或者: from unit.Unit import __init__ [as 别名]
def __init__(self):
WEAPONS = [FireBall(self)]
Unit.__init__(self, "Dragon", HP = 9999, ATK = 9999, DEF = 9999, MAG = 9999, RES = 9999, ACC = 9999, EVA = 9999, SPD = 9999, weapons = WEAPONS)
return
示例14: __init__
# 需要导入模块: from unit import Unit [as 别名]
# 或者: from unit.Unit import __init__ [as 别名]
def __init__(self, xmldoc):
Unit.__init__(self)
# This is a mech
self.type = "BM"
# Set some data to zero that sometimes will not get set otherwise
self.multi = Multi()
# Get top-level structure data
for mmech in xmldoc.getElementsByTagName('mech'):
self.model = mmech.attributes["model"].value
self.name = mmech.attributes["name"].value
self.omni = mmech.attributes["omnimech"].value
self.weight = int(mmech.attributes["tons"].value)
# Get BV. Should give prime variant BV for Omni-mechs
# get first instance only to avoid problems with Omni-mechs
self.batt_val = int(get_child_data(mmech, 'battle_value'))
# Get Cost.
cost = float(get_child_data(mmech, 'cost'))
# Get production era
self.prod_era = int(get_child_data(mmech, 'productionera'))
# Get mech type (battle, industrial)
self.mechtype = get_child_data(mmech, 'mech_type')
# Only support battlemechs
if (self.mechtype != "BattleMech" and
self.mechtype != "PrimitiveBattleMech"):
print self.name, self.model
print "Industrial Mechs not supported!"
sys.exit(1)
# Get techbase (IS, Clan)
# get first instance only to avoid problems with Omni-mechs
self.techbase = get_child_data(mmech, 'techbase')
# Get year
self.year = int(get_child_data(mmech, 'year'))
# Sanity check for year
year_era_test(self.year, self.prod_era,
self.name + " " + self.model)
if (self.year < 2439):
print self.name, self.model
print "Battlemech older than Mackie!"
sys.exit(1)
if (self.year < 2470 and self.mechtype == "BattleMech"):
print self.name, self.model
print "Non-primitive BattleMechs not available before 2470!"
sys.exit(1)
if (self.year < 2854 and self.omni == "TRUE"):
print self.name, self.model
print "OmniMechs not available before 2854!"
sys.exit(1)
# Get motive type (biped, quad)
self.motive = get_child_data(mmech, 'motive_type')
### Components starts here ###
# Get internal structure type
self.structure = MechStructure(get_child(mmech, 'structure'),
self.weight, self.motive)
# Get engine data
self.engine = Engine(get_child(mmech, 'engine'), self)
# Get gyro
self.gyro = Gyro(get_child(mmech, 'gyro'),
self.engine.etype, self.engine.erating)
# Get cockpit
self.cockpit = Cockpit(get_child(mmech, 'cockpit'), self)
# Get enhancement, needs for loop
self.enhancement = Enhancement(None, self.weight,
self.engine.erating)
for enh in mmech.getElementsByTagName('enhancement'):
self.enhancement = Enhancement(enh, self.weight,
self.engine.erating)
# Get armor.
self.armor = MechArmor(get_child(mmech, 'armor'),
self.weight, self.motive)
### Loadout stuff starts here ###
# Get baseloadout
blo = mmech.getElementsByTagName('baseloadout')[0]
# Get multi-slot stuff
for mlts in blo.getElementsByTagName('multislot'):
slot = mlts.attributes["name"].value
#.........这里部分代码省略.........
示例15: __init__
# 需要导入模块: from unit import Unit [as 别名]
# 或者: from unit.Unit import __init__ [as 别名]
def __init__(self,player):
Unit.__init__(self,player)