def __init__(self, trackGroup, ringModel, posScale, colorIndices): NodePath.__init__(self) self.assign(hidden.attachNewNode(\ base.localAvatar.uniqueName('ring-group'))) self.__period = trackGroup.period self.__reverseFlag = trackGroup.reverseFlag self.__tOffset = trackGroup.tOffset self.__numRings = len(trackGroup.tracks) self.__rings = [] self.__ringModels = [] for i in range(0,self.__numRings): track = trackGroup.tracks[i] tOffset = trackGroup.trackTOffsets[i] ring = Ring.Ring(track, tOffset, posScale) ring.reparentTo(self) model = ringModel.copyTo(ring) model.setColor(RingGameGlobals.ringColors[colorIndices[i]][1]) self.__rings.append(ring) self.__ringModels.append(model)
def _optimize(self): lightCones = NodePath('lightCones') for np in self._platformsRoot.findAllMatches('**/*lightCone*'): np.wrtReparentTo(lightCones) lightCones.reparentTo(self._model) node = self._model.find('**/ducts') if not node.isEmpty(): node.flattenStrong() for np in node.getChildren(): np.wrtReparentTo(self._model) node = self._model.find('**/nests') if not node.isEmpty(): for np in node.getChildren(): np.flattenStrong() np.wrtReparentTo(self._model) for np in self._model.findAllMatches('**/*LayerStack*'): np.wrtReparentTo(self._model) for np in self._model.find('**/static').getChildren(): np.wrtReparentTo(self._model) self._model.flattenMedium()
def loadModels( self ): self.tramp = self.root.attachNewNode(self.uniqueName("tramp")) self.screenPlaneElements = NodePath(self.uniqueName("screenPlane")) self.trampActor = Actor( "phase_13/models/parties/trampoline_model", {"emptyAnim" : "phase_13/models/parties/trampoline_anim"}, ) self.trampActor.reparentTo( self.tramp ) # Allow reskinning. if self.texture: reskinNode = self.tramp.find("**/trampoline/__Actor_modelRoot/-GeomNode") reskinNode.setTexture(loader.loadTexture(self.texture), 100) self.surface = NodePath(self.uniqueName("trampSurface")) self.surface.reparentTo(self.tramp) self.surface.setZ(self.trampHeight) self.trampActor.controlJoint(self.surface, "modelRoot", "trampoline_joint1") self.sign.setPos(PartyGlobals.TrampolineSignOffset) self.beans = [loader.loadModelCopy("phase_4/models/props/jellybean4") for i in range( self.numJellyBeans )] for bean in self.beans: bean.find( "**/jellybean" ).setP(-35.0) bean.setScale(3.0) bean.setTransparency(True) bean.reparentTo(self.tramp) bean.stash() self.beans[-1].setScale(8.0)
def _initModel(self): baseName = '**/tt_t_gui_cmg_miniMap_' cardModel = CogdoUtil.loadMazeModel('miniMap_cards', group='gui') cm = CardMaker('bg') cm.setFrame(-1.1, 1.1, -1.1, 1.1) bg = self.attachNewNode(cm.generate()) bg.setColor(*self._bgColor) bg.setBin('fixed', 0) frame = cardModel.find(baseName + 'frame') frame.reparentTo(self) frame.setScale(2.5) frame.setPos(0.01, 0, -0.01) self._entrance = cardModel.find(baseName + 'entrance') self._entrance.reparentTo(self) self._entrance.setScale(0.35) self._entrance.hide() self._exit = NodePath('exit') self._exit.setScale(0.35) self._exit.reparentTo(self) self._exitOpen = cardModel.find(baseName + 'exitOpen') self._exitOpen.reparentTo(self._exit) self._exitClosed = cardModel.find(baseName + 'exitClosed') self._exitClosed.reparentTo(self._exit) self._suitMarkerTemplate = cardModel.find(baseName + 'cogIcon') self._suitMarkerTemplate.detachNode() self._suitMarkerTemplate.setScale(0.225) self._waterCoolerTemplate = cardModel.find(baseName + 'waterDrop') self._waterCoolerTemplate.detachNode() self._waterCoolerTemplate.setScale(0.225) self._exit.hide() cardModel.removeNode()
def __init__(self, game, id, x, y): NodePath.__init__(self, 'dropNode%s' % id) self.game = game self.id = id self.reparentTo(hidden) self.setPos(x, y, 0) shadow = loader.loadModel('phase_3/models/props/square_drop_shadow') shadow.setZ(0.2) shadow.setBin('ground', 10) shadow.setColor(1, 1, 1, 1) shadow.reparentTo(self) self.shadow = shadow drop = CogdoUtil.loadMazeModel('cabinetSmFalling') roll = random.randint(-15, 15) drop.setHpr(0, 0, roll) drop.setZ(Globals.DropHeight) self.collTube = CollisionTube(0, 0, 0, 0, 0, 4, Globals.DropCollisionRadius) self.collTube.setTangible(0) name = Globals.DropCollisionName self.collNode = CollisionNode(name) self.collNode.addSolid(self.collTube) self.collNodePath = drop.attachNewNode(self.collNode) self.collNodePath.hide() self.collNodePath.setTag('isFalling', str('True')) drop.reparentTo(self) self.drop = drop self._dropSfx = base.cogdoGameAudioMgr.createSfxIval('drop', volume=0.6)
def __init__(self, serialNum, model, triggerRadius, triggerOffset=(0, 0, 0), animate=True, animDuration=0.2, instanceModel=True, name='CogdoGameGatherable'): NodePath.__init__(self, '%s-%d' % (name, serialNum)) self.serialNum = serialNum self._animate = animate if instanceModel: model.instanceTo(self) self._model = self else: self._model = model self._model.reparentTo(self) self._model.setPosHpr(0, 0, 0, 0, 0, 0) self._animDuration = animDuration self._animSeq = None self._initCollisions(triggerRadius, triggerOffset) self._update = None self._wasPickedUp = False return
def setupRightTexture(self): cm = CardMaker('quadMaker') cm.setColor(1.0, 1.0, 1.0, 1.0) aspect = base.camLens.getAspectRatio() htmlWidth = 2.0 * aspect * WEB_WIDTH / float(WIN_WIDTH) htmlHeight = 2.0 * float(WEB_HEIGHT) / float(WIN_HEIGHT) # the html area will be center aligned and vertically top aligned #cm.setFrame(-htmlWidth/2.0, htmlWidth/2.0, 1.0 - htmlHeight, 1.0) cm.setFrame(0, htmlWidth / 2.0, -htmlHeight / 2.0, htmlHeight / 2.0) card = cm.generate() self.rightQuad = NodePath(card) self.rightQuad.reparentTo(self.parent) self.rightGuiTex = Texture("guiTex") self.rightGuiTex.setupTexture(Texture.TT2dTexture, WEB_HALF_WIDTH, WEB_HEIGHT, 1, Texture.TUnsignedByte, Texture.FRgba) self.rightGuiTex.setKeepRamImage(True) self.rightGuiTex.makeRamImage() self.rightGuiTex.setWrapU(Texture.WMClamp) self.rightGuiTex.setWrapV(Texture.WMClamp) ts = TextureStage('rightWebTS') self.rightQuad.setTexture(ts, self.rightGuiTex) self.rightQuad.setTexScale(ts, 1.0, -1.0) self.rightQuad.setTransparency(0) self.rightQuad.setTwoSided(True) self.rightQuad.setColor(1.0, 1.0, 1.0, 1.0)
def enable(self): if self._enabled: return self._toon.detachCamera() self._prevToonY = 0.0 levelBounds = self._level.getBounds() l = Globals.Camera.LevelBoundsFactor self._bounds = ( (levelBounds[0][0] * l[0], levelBounds[0][1] * l[0]), (levelBounds[1][0] * l[1], levelBounds[1][1] * l[1]), (levelBounds[2][0] * l[2], levelBounds[2][1] * l[2]), ) self._lookAtZ = self._toon.getHeight( ) + Globals.Camera.LookAtToonHeightOffset self._camParent = NodePath('CamParent') self._camParent.reparentTo(self._parent) self._camParent.setPos(self._toon, 0, 0, 0) self._camParent.setHpr(180, Globals.Camera.Angle, 0) self._camera.reparentTo(self._camParent) self._camera.setPos(0, Globals.Camera.Distance, 0) self._camera.lookAt(self._toon, 0, 0, self._lookAtZ) self._cameraLookAtNP = NodePath('CameraLookAt') self._cameraLookAtNP.reparentTo(self._camera.getParent()) self._cameraLookAtNP.setPosHpr(self._camera.getPos(), self._camera.getHpr()) self._levelBounds = self._level.getBounds() self._enabled = True self._frozen = False self._initCollisions()
def __init__(self, player): self.player = player self.root = NodePath("CogdoFlyingGui") self.root.reparentTo(aspect2d) self.fuelMeter = NodePath("scrubMeter") self.fuelMeter.reparentTo(self.root) self.fuelMeter.setPos(1.1, 0.0, -0.7) self.fuelMeter.setSz(2.0) cm = CardMaker('card') cm.setFrame(-0.07, 0.07, 0.0, 0.75) self.fuelMeterBar = self.fuelMeter.attachNewNode(cm.generate()) self.fuelMeterBar.setColor(0.95, 0.95, 0.0, 1.0) self.fuelLabel = DirectLabel( parent=self.root, relief=None, pos=(1.1, 0, -0.8), scale=0.075, text="Fuel", text_fg=(0.95, 0.95, 0, 1), text_shadow=(0, 0, 0, 1), text_font=ToontownGlobals.getInterfaceFont(), ) self.messageLabel = DirectLabel( parent=self.root, relief=None, pos=(0.0, 0.0, -0.9), scale=0.1, text=" ", text_align=TextNode.ACenter, text_fg=(0.95, 0.95, 0, 1), text_shadow=(0, 0, 0, 1), text_font=ToontownGlobals.getInterfaceFont(), textMayChange=1, ) self.messageLabel.stash() self.winLabel = DirectLabel( parent=self.root, relief=None, pos=(0.0, 0.0, 0.0), scale=0.25, text="You win!", text_align=TextNode.ACenter, text_fg=(0.95, 0.95, 0, 1), text_shadow=(0, 0, 0, 1), text_font=ToontownGlobals.getInterfaceFont(), ) self.winLabel.stash() self.refuelLerp = LerpFunctionInterval(self.fuelMeterBar.setSz, fromData=0.0, toData=1.0, duration=2.0)
class DistributedGardenBox(DistributedLawnDecor.DistributedLawnDecor): notify = DirectNotifyGlobal.directNotify.newCategory( 'DistributedGardenPlot') def __init__(self, cr): DistributedLawnDecor.DistributedLawnDecor.__init__(self, cr) #self.defaultModel = "phase_8/models/props/flower_treasure.bam" self.plantPath = NodePath('plantPath') self.plantPath.reparentTo(self) self.plotScale = 1.0 self.plantingGuiDoneEvent = "plantingGuiDone" self.defaultModel = "phase_5.5/models/estate/planterC" def announceGenerate(self): #print("box announceGenerate!!!!") self.notify.debug('announceGenerate') DistributedLawnDecor.DistributedLawnDecor.announceGenerate(self) def doModelSetup(self): if self.typeIndex == GardenGlobals.BOX_THREE: self.defaultModel = "phase_5.5/models/estate/planterA" elif self.typeIndex == GardenGlobals.BOX_TWO: self.defaultModel = "phase_5.5/models/estate/planterC" else: self.defaultModel = "phase_5.5/models/estate/planterD" self.collSphereOffset = 0.0 self.collSphereRadius = self.collSphereRadius * 1.41 self.plotScale = Vec3(1.0, 1.0, 1.0) def setupShadow(self): #we don't want the shadow pass def loadModel(self): self.rotateNode = self.plantPath.attachNewNode('rotate') self.model = None self.model = loader.loadModel(self.defaultModel) self.model.setScale(self.plotScale) self.model.reparentTo(self.rotateNode) self.stick2Ground() #uncomment line below if we want the toons to walk on top of the planter #self.model.find("**/collision").stash() def handleEnterPlot(self, entry=None): #print("Box entered") pass def handleExitPlot(self, entry=None): DistributedLawnDecor.DistributedLawnDecor.handleExitPlot(self, entry) pass def setTypeIndex(self, typeIndex): #print("box setting type index!!!!") self.typeIndex = typeIndex
def __init__(self, cr, activityId, activityType, wantLever=False, wantRewardGui=False): DistributedObject.DistributedObject.__init__(self, cr) self.activityId = activityId self.activityName = PartyGlobals.ActivityIds.getString(self.activityId) self.activityType = activityType self.wantLever = wantLever self.wantRewardGui = wantRewardGui self.messageGui = None self.rewardGui = None self.toonIds = [] # list of doIds of toons in this activity # related-object requests self._toonId2ror = {} # Put a reference to this activity on base, for easy debugging # access, this will get cleaned up in DistributedPartyActivity childName = "%s" % self childName = childName[childName.rfind(".DistributedParty") + len(".DistributedParty"):childName. rfind("Activity instance")] if not hasattr(base, "partyActivityDict"): base.partyActivityDict = {} base.partyActivityDict[childName] = self self.root = NodePath('root') # This label is used to give status of the activity to the player # self.activityStatusLabel = DirectLabel( # text = TTLocalizer.PartyActivityWaitingForOtherPlayers, # text_fg = VBase4(1,1,1,1), # relief = None, # pos = (-0.6, 0, -0.75), # scale = 0.075) # self.activityStatusLabel.hide() # Play Activity's party activity state data throws this when the local toon # is done reading the rules self.rulesDoneEvent = "rulesDone" # for the load bar self.modelCount = 500 self.cleanupActions = [] # these are flags that the subclass can manipulate to keep # this base class from messing with the toons as the activity # starts up; see setUsesSmoothing and setUsesLookAround below self.usesSmoothing = 0 self.usesLookAround = 0 # difficulty debug overrides self.difficultyOverride = None self.trolleyZoneOverride = None self._localToonRequestStatus = None
def loadFlatQuad(self, fullFilename): """Load the flat jpg into a quad.""" assert self.notify.debugStateCall(self) #Texture.setTexturesPower2(AutoTextureScale.ATSUp) #Texture.setTexturesPower2(2) cm = CardMaker('cm-%s' % fullFilename) cm.setColor(1.0, 1.0, 1.0, 1.0) aspect = base.camLens.getAspectRatio() htmlWidth = 2.0 * aspect * WEB_WIDTH_PIXELS / float(WIN_WIDTH) htmlHeight = 2.0 * float(WEB_HEIGHT_PIXELS) / float(WIN_HEIGHT) # the html area will be center aligned and vertically top aligned #cm.setFrame(-htmlWidth/2.0, htmlWidth/2.0, 1.0 - htmlHeight, 1.0) cm.setFrame(-htmlWidth / 2.0, htmlWidth / 2.0, -htmlHeight / 2.0, htmlHeight / 2.0) bottomRightX = (WEB_WIDTH_PIXELS) / float(WEB_WIDTH + 1) bottomRightY = WEB_HEIGHT_PIXELS / float(WEB_HEIGHT + 1) #cm.setUvRange(Point2(0,0), Point2(bottomRightX, bottomRightY)) cm.setUvRange(Point2(0, 1 - bottomRightY), Point2(bottomRightX, 1)) card = cm.generate() quad = NodePath(card) #quad.reparentTo(self.parent) jpgFile = PNMImage(WEB_WIDTH, WEB_HEIGHT) smallerJpgFile = PNMImage() readFile = smallerJpgFile.read(Filename(fullFilename)) if readFile: jpgFile.copySubImage(smallerJpgFile, 0, 0) guiTex = Texture("guiTex") guiTex.setupTexture(Texture.TT2dTexture, WEB_WIDTH, WEB_HEIGHT, 1, Texture.TUnsignedByte, Texture.FRgba) guiTex.setMinfilter(Texture.FTLinear) guiTex.load(jpgFile) #guiTex.setKeepRamImage(True) #guiTex.makeRamImage() guiTex.setWrapU(Texture.WMClamp) guiTex.setWrapV(Texture.WMClamp) ts = TextureStage('webTS') quad.setTexture(ts, guiTex) #quad.setTexScale(ts, 1.0, -1.0) quad.setTransparency(0) quad.setTwoSided(True) quad.setColor(1.0, 1.0, 1.0, 1.0) result = quad else: # if we have an error loading the file, return None to signify an error result = None #Texture.setTexturesPower2(AutoTextureScale.ATSDown) Texture.setTexturesPower2(1) return result
def __init__(self, moveTrack, tOffset, posScale=1.): NodePath.__init__(self) self.assign(hidden.attachNewNode(\ base.localAvatar.uniqueName('ring'))) self.setMoveTrack(moveTrack) self.setTOffset(tOffset) self.setPosScale(posScale) self.setT(0.)
def __init__(self, cr): DistributedLawnDecor.DistributedLawnDecor.__init__(self, cr) #self.defaultModel = "phase_8/models/props/flower_treasure.bam" self.plantPath = NodePath('plantPath') self.plantPath.reparentTo(self) self.plotScale = 1.0 self.plantingGuiDoneEvent = "plantingGuiDone" self.defaultModel = "phase_5.5/models/estate/planterC"
def __init__(self, level): self._level = level self.root = NodePath('CogdoFlyingGui') self.root.reparentTo(aspect2d) self.root.stash() self._initTimer() self._initHud() self._initMessageDisplay() self.sentTimeRunningOutMessage = False self._refuelGui = CogdoFlyingFuelGui(self.root) self._progressGui = CogdoFlyingProgressGui(self.root, self._level)
def __init__(self, serialNum, model): NodePath.__init__(self, 'CogdoMazeWaterCooler-%i' % serialNum) self.serialNum = serialNum self._model = model self._model.reparentTo(self) self._model.setPosHpr(0, 0, 0, 0, 0, 0) self._initCollisions() self._initArrow() self._update = None self.__startUpdateTask() return
def __init__(self, parent, pos=None, scale =None): """Create a new indicator object.""" NodePath.__init__(self, 'DinerStatusIndicator') if parent: self.reparentTo(parent) if pos: self.setPos(pos) if scale: self.setScale(scale) self.loadAssets() FSM.FSM.__init__(self,'DinerStatusIndicator') self.activeIval = None
def _initQuestArrow(self): matchingGameGui = loader.loadModel( 'phase_3.5/models/gui/matching_game_gui') arrow = matchingGameGui.find('**/minnieArrow') arrow.setScale(Globals.QuestArrowScale) arrow.setColor(*Globals.QuestArrowColor) arrow.setHpr(90, -90, 0) self._questArrow = NodePath('Arrow') arrow.reparentTo(self._questArrow) self._questArrow.reparentTo(render) self.hideQuestArrow() matchingGameGui.removeNode()
def entersActivity(self): base.cr.playGame.getPlace().setState("activity") PartyCogActivityPlayer.entersActivity(self) self.gui.disableToontownHUD() self.cameraManager = CameraManager(camera) self.tempNP = NodePath("temp") self.lookAtMyTeam() self.control = StrafingControl(self)
def startBallPlayback(self, power, angle, sequenceNum): """Start the ball flying in the air.""" assert self.notify.debugStateCall(self) # duplicate our current ball model flyBall = self.ballModel.copyTo(NodePath()) flyBall.setScale(1.0) flyBallBubble = self.getFlyBallBubble().instanceTo(NodePath()) flyBallBubble.reparentTo(flyBall) flyBall.setTag('pieSequence', str(sequenceNum)) flyBall.setTag('throwerId', str(self.avId)) # First, create a ProjectileInterval to compute the relative # velocity. t = power / 100.0 # make the ball travel farther, the longer you press the bar t = 1.0 - t # Distance ranges from 300 - 100 ft, time ranges from 1.5 - 2 s. dist = 300 - 200 * t time = 1.5 + 0.5 * t proj = ProjectileInterval( None, startPos=Point3(0, 0, 0), endPos=Point3(0, dist, 0), duration=time, ) relVel = proj.startVel def getVelocity(root=self.root, relVel=relVel): return render.getRelativeVector(root, relVel) fly = Sequence( #Func(self.ballModel.hide), Func(flyBall.reparentTo, render), Func(flyBall.setPosHpr, self.root, 0, 0, 0, 0, 0, 0), Func(base.cTrav.addCollider, flyBallBubble, self.flyBallHandler), ProjectileInterval(flyBall, startVel=getVelocity, duration=3), Func(flyBall.detachNode), Func(base.cTrav.removeCollider, flyBallBubble), Func(self.notify.debug, "removed collider"), Func(self.flyBallFinishedFlying, sequenceNum)) flyWithSound = Parallel(fly, SoundInterval(self.hitBallSfx, node=self.root), name='flyWithSound') self.notify.debug('starting flyball track') flyWithSound.start() self.flyBallTracks[sequenceNum] = flyWithSound pass
def __init__(self, x, y, z, moleField, index): """Construct the mole hill.""" NodePath.__init__(self, 'MoleHill-%d' % index) self.moleField= moleField self.index = index self.loadModel() self.setPos(x, y, z) self.schedule = [] self.popIval = None self.downIval = None self.popupNum = 0 # how many times has this hill popped up self.hillType = None self.isUp = 0
def __init__(self, cr): DistributedLawnDecor.DistributedLawnDecor.__init__(self, cr) #self.defaultModel = "phase_8/models/props/flower_treasure.bam" self.plantPath = NodePath('plantPath') self.plantPath.reparentTo(self) self.plotScale = 1.0 self.plantingGuiDoneEvent = "plantingGuiDone" self.toonStatueSelectionDoneEvent = "toonStatueSelectionDone" self.defaultModel = "phase_5.5/models/estate/dirt_mound" self.colorScaler = Vec4(1, 1, 1, 1) self.plantingGui = None
def __init__(self, cameraNP): self.cameraNP = cameraNP self.id = CameraManager.nextID CameraManager.nextID += 1 self.otherNP = render self.lookAtNP = NodePath("CameraManager%d.lookAtNP" % self.id) self.lookAtEnabled = False self.targetPos = Point3(0.0, 0.0, 0.0) self.targetLookAtPos = Point3(0.0, 1.0, 0.0) self.enabled = False self.rate = 10.0
def loadAssets(self): """Load and setup the assets for the food belt.""" # later on this will become a loadModel call self.beltModel = NodePath('beltModel') self.beltModel.reparentTo(self.boss.geom) self.startLocator = self.boss.geom.find( '**/conveyer_belt_start_%d' % (self.index+1)) self.endLocator = self.boss.geom.find('**/conveyer_belt_end_%d' % (self.index+1)) center = (self.startLocator.getPos() + self.endLocator.getPos())/2.0 self.beltHeight = center.getZ() self.beltHeight += 0.1 center.setZ(0) self.beltLength = (self.endLocator.getPos() - self.startLocator.getPos()).length() self.distBetweenFoodNodes = self.beltLength / self.NumFoodNodes self.notify.debug('setting beltModelPos to %s' % center) self.beltModel.setPos(center) self.setupFoodNodes() self.setupFoodIvals() self.setupToonupIvals() if self.index == 0: self.beltActorModel = loader.loadModel("phase_12/models/bossbotHQ/food_belt1_model") else: self.beltActorModel = loader.loadModel("phase_12/models/bossbotHQ/food_belt2_model") if (self.beltActorModel): self.beltActor = Actor.Actor(self.beltActorModel) if self.index == 0: self.beltActor.loadAnims({'idle': "phase_12/models/bossbotHQ/food_belt1"}) else: self.beltActor.loadAnims({'idle': "phase_12/models/bossbotHQ/food_belt2"}) self.beltActor.reparentTo(render) # adjust this number as necessary to match up with the food intervals self.beltActor.setPlayRate(self.BeltActorPlayRate, 'idle') #self.beltActor.loop('idle') # 1st uv animation mesh = self.beltActor.find('**/mesh_tide1') joint = self.beltActor.find('**/uvj_WakeWhiteTide1') mesh.setTexProjector(mesh.findTextureStage('default'), joint, self.beltActor) self.beltActor.setPos(self.startLocator.getPos()) self.beltSound = base.loader.loadSfx("phase_12/audio/sfx/CHQ_FACT_conveyor_belt.wav") self.beltSound.setLoop(1) self.beltSoundInterval = SoundInterval(self.beltSound, node=self.beltModel, listenerNode = base.localAvatar, seamlessLoop = True, volume = 0.25, cutOff = 100)
def stick2Ground(self, taskfooler=0): if self.isEmpty(): return Task.done testPath = NodePath('testPath') testPath.reparentTo(render) # This is a ray cast down to detect floor polygons cRay = CollisionRay(0.0, 0.0, 40000.0, 0.0, 0.0, -1.0) cRayNode = CollisionNode(self.uniqueName('estate-FloorRay')) cRayNode.addSolid(cRay) cRayNode.setFromCollideMask(OTPGlobals.FloorBitmask) cRayNode.setIntoCollideMask(BitMask32.allOff()) cRayNodePath = testPath.attachNewNode(cRayNode) queue = CollisionHandlerQueue() picker = CollisionTraverser() picker.addCollider(cRayNodePath, queue) # fix the movie node if self.movieNode: testPath.setPos(self.movieNode.getX(render), self.movieNode.getY(render), 0) picker.traverse(render) if queue.getNumEntries() > 0: queue.sortEntries() for index in range(queue.getNumEntries()): entry = queue.getEntry(index) if recurseParent(entry.getIntoNode(), 'terrain_DNARoot'): self.movieNode.setZ(entry.getSurfacePoint(self)[2]) #testPath.setPos(self.plantPath.getX(),self.plantPath.getY(),0) # fix the main model testPath.setPos(self.getX(), self.getY(), 0) picker.traverse(render) if queue.getNumEntries() > 0: #print("Sticking") queue.sortEntries() for index in range(queue.getNumEntries()): entry = queue.getEntry(index) #TODO clean up this next bit to be more generic #if entry.getIntoNode().getParent(0).getParent(0).getParent(0).getName() == 'terrain_DNARoot': if recurseParent(entry.getIntoNode(), 'terrain_DNARoot'): #if str(entry.getIntoNodePath()) == "render/Estate/30000:estate/terrain_DNARoot/-PandaNode/group3/collision1": self.setZ( entry.getSurfacePoint(render)[2] + self.stickUp + 0.1) #print("Stickup %s" % (self.stickUp)) #print("Stick Height %s %s %s" % (entry.getSurfacePoint(render)[2],self.getX(),self.getY())) self.stickParts() return Task.done taskMgr.doMethodLater(1.0, self.stick2Ground, uniqueName("groundsticker")) #print("Not Sticking") return Task.done
def loadGrass(self): self.grassRoot = NodePath("GrassRoot") self.grassRoot.reparentTo(base.cr.playGame.hood.loader.geom) grass = loader.loadModel("phase_13/models/parties/grass") clearPositions = self.getClearSquarePositions() # Create up to 3 tufts of grass per clear square (avg) or up to PartyGlobals.TuftsOfGrass. numTufts = min(len(clearPositions) * 3, PartyGlobals.TuftsOfGrass) for i in range(numTufts): g = grass.copyTo(self.grassRoot) pos = random.choice(clearPositions) g.setPos(pos[0] + random.randint(-8, 8), pos[1] + random.randint(-8, 8), 0.0)
def _initArrow(self): matchingGameGui = loader.loadModel('phase_3.5/models/gui/matching_game_gui') arrow = matchingGameGui.find('**/minnieArrow') arrow.setScale(Globals.CoolerArrowScale) arrow.setColor(*Globals.CoolerArrowColor) arrow.setPos(0, 0, Globals.CoolerArrowZ) arrow.setHpr(0, 0, 90) arrow.setBillboardAxis() self._arrow = NodePath('Arrow') arrow.reparentTo(self._arrow) self._arrow.reparentTo(self) self._arrowTime = 0 self.accept(Globals.WaterCoolerShowEventName, self.showArrow) self.accept(Globals.WaterCoolerHideEventName, self.hideArrow) matchingGameGui.removeNode()
def __init__(self, maze, bossCode): self.maze = maze self.root = NodePath('CogdoMazeGui') self.root.reparentTo(aspect2d) self.mazeMapGui = CogdoMazeMapGui(self.maze.collisionTable) if bossCode is not None: self._bossGui = CogdoMazeBossGui(bossCode) else: self._bossGui = None self._memoGui = CogdoMemoGui(self.root) self._memoGui.posNextToLaffMeter() self._presentGuiIval = None self._presentTimerIval = None self._hud = CogdoMazeHud() self._timer = None self._initMessageDisplay() return
def __init__(self, closedDoorModel, openDoorModel): self.model = NodePath("CogdoMazeDoor") self.model.setPos(0, 0, 0) self.model.reparentTo(render) self.closedDoorModel = closedDoorModel self.closedDoorModel.reparentTo(self.model) self.openDoorModel = openDoorModel self.openDoorModel.reparentTo(self.model) self.openDoorModel.stash() self.lockId2lock = {} self._open = False self.revealed = False self.players = [] self._initCollisions()
def __init__(self, parent, frameModel, startPlatformModel, endPlatformModel, quadLengthUnits, quadVisibilityAhead, quadVisibiltyBehind): self.parent = parent self.quadLengthUnits = quadLengthUnits self._halfQuadLengthUnits = quadLengthUnits / 2.0 self.quadVisibiltyAhead = quadVisibilityAhead self.quadVisibiltyBehind = quadVisibiltyBehind self._frameModel = frameModel self.root = NodePath('CogdoFlyingLevel') self.quadrantRoot = NodePath('QuadrantsRoot') self.quadrantRoot.reparentTo(self.root) self._startPlatformModel = startPlatformModel self._startPlatformModel.reparentTo(self.root) self._startPlatformModel.setZ(Globals.Level.StartPlatformHeight) self._endPlatformModel = endPlatformModel self._endPlatformModel.reparentTo(self.root) self._endPlatformModel.setZ(Globals.Level.EndPlatformHeight) self.wallR = self._frameModel.find('**/wallR') self.wallL = self._frameModel.find('**/wallL') self._exit = CogdoGameExit() self._exit.reparentTo(self._endPlatformModel) loc = self._endPlatformModel.find('**/exit_loc') offset = loc.getPos(render) self._exit.setPos(render, offset) self.quadrants = [] self.visibleQuadIndices = [] self._numQuads = 0 self._currentQuadNum = -1 self._camera = None self._initCollisions() self.upLimit = self._frameModel.find('**/limit_up').getZ(render) self.downLimit = self._frameModel.find('**/limit_down').getZ(render) self.leftLimit = self._frameModel.find('**/limit_left').getX( render) - 30.0 self.rightLimit = self._frameModel.find('**/limit_right').getX( render) + 30.0 self.backLimit = -self.quadLengthUnits self.forwardLimit = self.quadLengthUnits * 20 self._frameModel.flattenStrong() self.gatherableFactory = CogdoFlyingGatherableFactory() self.obstacleFactory = CogdoFlyingObtacleFactory() return