Пример #1
0
    def deathState(self, recoilSpeed, recoilDir):
        sound.enemyDie.Play()
        self.invincible = True
        self.interruptable = False
        if recoilDir is None:
            recoilDir = self.direction  # bleh
        # do the hurt animation
        dummy = self.hurtState(recoilSpeed, recoilDir)
        # let it go for a moment
        yield dummy.next()
        self.stats.hp = 0
        # take over the animation, then finish the hurt state

        fullWidth = (self.ent.hotwidth + self.ent.hotx) * 2
        fullHeight = (self.ent.hotheight + self.ent.hoty) * 2

        fullHeight = fullWidth = max(fullWidth, fullHeight)

        smokeX = self.ent.x + self.ent.hotwidth / 2 - fullWidth / 2
        smokeY = self.ent.y + self.ent.hotheight / 2 - fullHeight / 2
        engine.addThing(SmokeCloud(smokeX, smokeY, fullWidth, fullHeight,
                                   self))

        while True:
            yield None
Пример #2
0
    def hurt(self, amount, recoilSpeed=0, recoilDir=None):
        if self.invincible:
            return
        if recoilDir is None:
            recoilDir = dir.invert[self.direction]
        if self.stats.hp <= amount:
            self.stats.hp = 0
            self.die()
        else:
            self.stats.hp -= amount
            self.state = self.hurtState(recoilSpeed, recoilDir)

        x = self.ent.x + self.ent.hotwidth / 2 - engine.font.StringWidth(
            str(amount)) / 2
        y = self.ent.y
        engine.addThing(DamageCaption(str(amount), x, y, 40, 250, 0, 0))
Пример #3
0
 def hurt(self, amount, recoilSpeed=0, recoilDir=None):
     p = engine.player
     if self.invincible:
         engine.addThing(Quake(duration=25, x=50, y=50))
         p.recoil(175, dir.invert[p.direction])
         return
     else:
         engine.addThing(Quake(duration=100, x=30, y=30))
     if recoilDir is None:
         recoilDir = dir.invert[self.direction]
     if self.stats.hp <= 1:
         self.stats.hp = 0
         self.die()
         p.recoil(175, dir.invert[p.direction])
     else:
         sound.maneaterHit.Play()
         super(Maneater, self).hurt(1, recoilSpeed, recoilDir)
Пример #4
0
    def spawnMood(self):
        p = system.engine.player
        self.anim = 'wait_in'
        while True:

            # ---- PHASE 1 - Spores ---- #

            self.anim = 'spawnspores'
            yield self.idleState(100)

            for r in range(4):
                engine.addThing(Quake(duration=50, x=5, y=5))
                yield self.spawnSporeState(7 - r)
                while self.numSpores:
                    yield self.idleState()

            self.anim = 'wait_in'
            yield self.idleState(200)

            # ---- PHASE 2 - Spears ---- #

            self.anim = 'spawnspears'
            yield self.idleState(100)

            for r in range(8):
                yield self.spawnSpearState()
                engine.addThing(Quake(duration=25, x=10, y=10))
                while self.numSpears:
                    yield self.idleState()
                yield self.idleState(10)

            self.anim = 'wait_in'
            yield self.idleState(500)

            # ---- PHASE 3 - Summon Tentacles ---- #

            yield self.submergeState()

            engine.addThing(Quake(duration=150, x=4, y=4))
            yield self.spawnTentacleState()

            self.anim = 'idle'
            yield self.idleState(100)

            # ---- PHASE 4 - Wait ---- #

            yield self.passiveState()

            # ---- PHASE 5 - Show ---- #

            yield self.growState()
            yield self.showState()
            yield self.idleState(1000)
            yield self.hideState()

            # ---- PHASE 6 - Warmup ---- #

            yield self.idleState(400)
Пример #5
0
 def apply(self):    
     self.sound = sound.NullSound() #prevent normal powerup sound from playing        
     engine.saveData['grapple'] = True
     engine.addThing(DamageCaption('Got Grapple', self.ent.x, self.ent.y, 80, 241, 156, 73))     
     sound.fader.playandresume(sound.music['victory'], 250000)        
     
Пример #6
0
 def apply(self):
     if self.flagName.startswith('perm'):
         engine.saveData[self.flagName] = 'True'    
     engine.player.stats.pres += 1
     engine.addThing(DamageCaption('Def +1', self.ent.x, self.ent.y, 80, 241, 156, 73))     
Пример #7
0
    def spawnSporeState(self, freq=7):

        cx = 9.5 * ika.Tileset.width
        cy = 10.5 * ika.Tileset.height
        rad = ika.Tileset.width * 7
        cosDeg = lambda n: math.cos(n * math.pi / 180.0)
        sinDeg = lambda n: math.sin(n * math.pi / 180.0)

        forRange = lambda: range(0, 360, 90 / (rad / ika.Tileset.width))
        backRange = lambda: range(360, 0, -90 / (rad / ika.Tileset.width))
        ranges = [forRange, backRange]
        pos = 0

        mode = ika.Random(0, 2)  # 2 different modes

        # MODE 1 - closing circles
        if mode == 0:

            while rad > 0:

                cnt = 0
                sound.fall.Play()
                play = True
                rng = ranges[pos]()
                for deg in rng:
                    x = cx + cosDeg(deg) * rad - 4
                    y = cy + sinDeg(deg) * rad - 4
                    engine.addEntity(
                        ManeaterSpore(ika.Entity(x, y, ika.Map.layercount - 1,
                                                 'maneater_spore.ika-sprite'),
                                      play=play))
                    for time in range(2):
                        yield None
                    if play:
                        play = False
                    elif cnt < 4:
                        cnt += 1
                    else:
                        cnt = 0
                        play = True
                pos ^= 1
                for time in range(40):
                    yield None
                rad -= ika.Tileset.width * 2

                engine.addThing(Quake(duration=25, x=10, y=10))

        # MODE 2 - random bombardment
        elif mode == 1:

            rng = ranges[0]()

            sound.fall.Play()

            play = True
            while rad > 0:
                for deg in rng:
                    if not ika.Random(
                            0, freq):  # half chance of bombarding this one
                        x = cx + cosDeg(deg) * rad - 4
                        y = cy + sinDeg(deg) * rad - 4
                        engine.addEntity(
                            ManeaterSpore(ika.Entity(
                                x, y, ika.Map.layercount - 1,
                                'maneater_spore.ika-sprite'),
                                          play=play))
                        play = False
                rad -= ika.Tileset.width

        yield None
Пример #8
0
 def growMood(self):
     engine.addThing(Quake(duration=25, x=8, y=8))
     yield self.growState()
     self.mood = self.spawnMood
     yield self.passiveState()