def __init__(self, application, character): self.application = application self.character = character self.listener = CharacterListener(self) self.instance = self.application.maplayer.getInstance( "c:" + self.character.ID) if self.instance: if self.character.coords is None: self.character.coords = self.instance.getLocation( ).getLayerCoordinates() else: location = self.instance.getLocation() location.setLayerCoordinates(self.character.coords) self.instance.setLocation(location) self.instance.setRotation(self.character.rotation) else: if self.character.coords is None: print("Error creating instance for", self.character.ID, self.character.name) else: self.instance = self.application.maplayer.createInstance( self.application.model.getObject(self.character.sprite, "steamfolktales"), self.character.coords) fife.InstanceVisual.create(self.instance) self.instance.setRotation(self.character.rotation) self.instance.addActionListener(self.listener) self.state = self.STATE_IDLE self.combat = None self.sneaking = False #self.application.gui.hud.walk_mode == "sneak" self.application.real_timeline.addTimer( Timer("idle " + self.character.name, action=self.idle)) self.timer = CharacterTimer(self.character) self.application.engine.getTimeManager().registerEvent(self.timer)
def __init__(self, application, instance, text, time, color=""): fife.InstanceDeleteListener.__init__(self) self.application = application self.instance = instance self.timer = Timer("SayBubble" + text, time=time, action=self.destroy, tick_action=self.adjustPosition) self.application.real_timeline.addTimer(self.timer) self.instance.addDeleteListener(self) self.bubble = PyCEGUI.WindowManager.getSingleton().createWindow( "TaharezLook/StaticText", "SayBubble-" + str(self.instance.getFifeId())) self.bubble.setProperty("FrameEnabled", "False") self.bubble.setProperty("BackgroundEnabled", "False") self.bubble.setProperty("MousePassThroughEnabled", "True") self.bubble.setProperty("HorzFormatting", "CentreAligned") self.shadow1 = self.bubble.clone() self.shadow1.setName("SayBubbleShadow1-" + str(self.instance.getFifeId())) self.shadow2 = self.bubble.clone() self.shadow2.setName("SayBubbleShadow2-" + str(self.instance.getFifeId())) self.shadow3 = self.bubble.clone() self.shadow3.setName("SayBubbleShadow3-" + str(self.instance.getFifeId())) self.shadow4 = self.bubble.clone() self.shadow4.setName("SayBubbleShadow4-" + str(self.instance.getFifeId())) self.application.gui.root.addChild(self.shadow1) self.application.gui.root.addChild(self.shadow2) self.application.gui.root.addChild(self.shadow3) self.application.gui.root.addChild(self.shadow4) self.application.gui.root.addChild(self.bubble) self.edit(text, time, color)
def lives(self, new_lives): if self._lives < new_lives <= 8: self.application.view.instance_renderer.addColored( self.player.instance, 0, 255, 0) self.application.real_timeline.addTimer( Timer( "uncolor", 100, lambda: self.application.view. instance_renderer.removeColored(self.player.instance))) elif self._lives > new_lives: self.application.view.instance_renderer.addColored( self.player.instance, 255, 0, 0) self.application.real_timeline.addTimer( Timer( "uncolor", 100, lambda: self.application.view. instance_renderer.removeColored(self.player.instance))) self._lives = min(new_lives, 8) self.application.gui.hud.updateLives(self._lives) self.rest_counter = 0 if self._lives <= 0: #self.application.gui.combat_log.printMessage("GAME OVER") self.application.gui.info_dump.showText( u""" GAME OVER Now you’ll always be remembered as the vampire’s dog...""", self.application.gameOver)
def __init__(self, application, instance, fill, vis_fill, color=""): fife.InstanceDeleteListener.__init__(self) self.application = application self.instance = instance self.timer = Timer("DetectionBar" + str(fill), time=200, action=self.destroy, tick_action=self.adjustPosition) self.application.real_timeline.addTimer(self.timer) self.instance.addDeleteListener(self) self.bar = PyCEGUI.WindowManager.getSingleton().createWindow( "TaharezLook/ProgressBar", "DetectionBar-" + str(self.instance.getFifeId())) self.bar.setProperty("MousePassThroughEnabled", "True") self.bar.setProperty("Size", "{{0,60},{0,10}}") self.application.gui.root.addChild(self.bar) self.fill = 0.0 self.edit(fill, vis_fill, color)
def movePlayer(self, delta_coords): if self.animating: return new_coords = self.player.coords + delta_coords cell = self.application.maplayer.getCellCache().getCell(new_coords) if cell and cell.getCellType() <= 1: self.player.moveInstant(new_coords) #self.player.move(new_coords) self.moveEnemies() self.player.replayMove() self.rest_counter = 0 return #self.application.gui.combat_log.printMessage("Sakuya cannot move in that direction.") facing_location = self.player.instance.getLocation() facing_location.setLayerCoordinates(new_coords) self.player.instance.setFacingLocation(facing_location) # can't move; but maybe we can attack? for wolf in self.wolves: if facing_location == wolf.instance.getLocation(): #self.application.gui.combat_log.printMessage("Sakuya slashes wolf.") self.application.gui.sayBubble(self.player.instance, "Take that!", 1000) self.application.view.instance_renderer.addColored( wolf.instance, 255, 0, 0) self.application.real_timeline.addTimer( Timer( "uncolor", 100, lambda: self.application.view. instance_renderer.removeColored(wolf.instance))) wolf.health -= 1 if wolf.health <= 0: self.wolves.remove(wolf) facing_location.getLayer().deleteInstance(wolf.instance) if wolf.instance.getObject().getId() == "Kagerou": if self.momiji.dead: self.application.gui.info_dump.showText( u""" After calming down both wolf-girls, it appears that the effects of the curse are subsiding.""", self.victory) return else: self.application.gui.info_dump.showText( u""" You were able to calm Kagerou down. However, it seems there is still one more foe you need to face.""" ) elif wolf.instance.getObject().getId() == "Momiji": if self.kagerou.dead: self.application.gui.info_dump.showText( u""" “Awooo~sob...” “Wait, you’re Momiji? I knew it was weird to meet Kagerou again... This curse sure works in mysterious ways.” Thankfully, after calming down both wolf-girls, it appears that the effects of the curse are subsiding.""", self.victory) return else: self.application.gui.info_dump.showText( u""" “Awooo~sob...” “Wait, Momiji? I thought you were Kagerou... This curse sure works in mysterious ways. I guess I’ll have to find the real Kagerou then.”""" ) else: pass #self.application.gui.combat_log.printMessage("Wolf was killed.") self.moveEnemies() self.rest_counter = 0 return
def onInstanceActionFinished(self, instance, action): self.application.real_timeline.addTimer( Timer("destroy effect", action=self.destroy))
def onInstanceActionFinished(self, instance, action): if self.state == self.STATE_RUN1: print("Bird out of control!") self.application.real_timeline.addTimer( Timer("idle bird", action=self.idle))
def onInstanceActionFinished(self, instance, action): self.application.real_timeline.addTimer( Timer("idle animal", action=self.idle))