Exemple #1
0
    def standState(self):
        self.stop()
        self.anim = 'stand'
        while True:
            if controls.attack1() or controls.joy_attack1():
                self.state = self.weapon.attack1(self)

            elif controls.attack2() or controls.joy_attack2():
                self.state = self.weapon.attack2(self)

            elif (controls.tool1()
                  or controls.joy_tool1()) and 'grapple' in engine.saveData:
                self.state = self.grapple.activate(self)

            elif (controls.left() or controls.right() or controls.up()
                  or controls.down() or controls.joy_left()
                  or controls.joy_right() or controls.joy_up()
                  or controls.joy_down()):
                self.state = self.walkState()

            #elif (controls.left() or controls.right() or
            #     controls.up() or controls.down()
            #):
            #    self.state = self.walkState()
            #    self._state()  # get the walk state started right now.

            if not self.stats.mp:
                self.invincible = False
                self.ent.visible = 1
                self.speed = 100
            yield None
Exemple #2
0
    def slashState(self):
        self.stop()
        self.anim = 'slash'
        r = slashRange[self.direction]
        backslash = False
        backthrust = False

        # when we hit an entity, we append it here so that
        # we know not to hurt it again.
        hitList = []

        sound.slash1.Play()

        while not self._animator.kill:
            rect = list(r[self._animator.index]) + [self.layer]
            rect[0] += self.x
            rect[1] += self.y
            ents = ika.EntitiesAt(*rect)
            for e in ents:
                x = system.engine.entFromEnt[e]
                if isinstance(x, Enemy) and not x.invincible and x not in hitList:
                    hitList.append(x)
                    x.hurt( int(self.stats.att + ika.Random(0, 3)), 120, self.direction)
                    self.giveMPforHit()
            if self.stats.level >= BACK_LEVEL: 
                if (controls.up() or controls.joy_up()) and self.direction == dir.DOWN:  backthrust = True
                elif (controls.down()  or controls.joy_down()) and self.direction == dir.UP:  backthrust = True
                elif (controls.left() or controls.joy_left()) and self.direction in [dir.RIGHT, dir.UPRIGHT, dir.DOWNRIGHT]:  backthrust = True
                elif (controls.right() or controls.joy_right()) and self.direction in [dir.LEFT, dir.UPLEFT, dir.DOWNLEFT]:  backthrust = True

            if (controls.attack() or controls.joy_attack()) and self.stats.level >= SLASH_LEVEL: 
                backslash = True

            yield None

        if backthrust:
            self.state = self.backThrustState()
            yield None
        elif backslash:
            self.state = self.backSlashState()
            yield None
        else:
            # Stall:
            count = 10
            while count > 0:
                count -= 1
                if self.stats.level >= THRUST_LEVEL and (controls.attack() or controls.joy_attack()):
                    self.state = self.thrustState()
                yield None
Exemple #3
0
    def walkState(self):
        oldDir = self.direction
        self.anim = 'walk'
        while True:
            self.regenMP()                
            if controls.attack() or controls.joy_attack():
                self.state = self.slashState()
            elif controls.rend() or controls.joy_rend():
                self.state = self.hearthRendState()
                yield None
            elif controls.gale() or controls.joy_gale():
                self.state = self.crushingGaleState()
                yield None
            elif controls.heal() or controls.joy_heal():
                self.state = self.healingRainState()
                yield None
            elif controls.bolt() or controls.joy_bolt():
                self.state = self.boltState()
                yield None                
            elif controls.left() or controls.joy_left():
                if controls.up()  or controls.joy_up():
                    d = dir.UPLEFT
                elif controls.down()  or controls.joy_down():
                    d = dir.DOWNLEFT
                else:
                    d = dir.LEFT
            elif controls.right() or controls.joy_right():
                if controls.up() or controls.joy_up():
                    d = dir.UPRIGHT
                elif controls.down() or controls.joy_down():
                    d = dir.DOWNRIGHT
                else:
                    d = dir.RIGHT
            elif controls.up() or controls.joy_up():
                d = dir.UP
            elif controls.down() or controls.joy_down():
                d = dir.DOWN
            else:
                self.state = self.standState()
                yield None

            self.move(d)

            # handle animation and junk
            if d != oldDir:
                self.anim = 'walk'
                self.direction = d
                oldDir = d
            yield None           
Exemple #4
0
    def walkState(self):
        oldDir = self.direction
        self.anim = 'walk'
        while True:
            if controls.attack1() or controls.joy_attack1():
                self.state = self.weapon.attack1(self)
                yield None

            elif controls.attack2() or controls.joy_attack2():
                self.state = self.weapon.attack2(self)
                yield None

            elif controls.left() or controls.joy_left():
                if controls.up() or controls.joy_up():
                    d = dir.UPLEFT
                elif controls.down() or controls.joy_down():
                    d = dir.DOWNLEFT
                else:
                    d = dir.LEFT
            elif controls.right() or controls.joy_right():
                if controls.up() or controls.joy_up():
                    d = dir.UPRIGHT
                elif controls.down() or controls.joy_down():
                    d = dir.DOWNRIGHT
                else:
                    d = dir.RIGHT
            elif controls.up() or controls.joy_up():
                d = dir.UP
            elif controls.down() or controls.joy_down():
                d = dir.DOWN
            else:
                self.state = self.standState()
                yield None

            self.move(d)
            # handle animation and junk
            if d != oldDir:
                self.anim = 'walk'
                self.direction = d
                oldDir = d
            yield None
Exemple #5
0
    def slashState(self, me):
        if 0: me.overlay.renderscript = self.drawRect

        me.stop()
        me.anim = 'slash'
        r = slashRange[me.direction]
        thrust = False
        backslash = False
        backthrust = False
        # when we hit an entity, we append it here so that
        # we know not to hurt it again.
        hitList = set([])
        sound.sword1.Play()
        while not me._animator.kill:
            rect = list(r[me._animator.index]) + [me.layer]
            rect[0] += me.x
            rect[1] += me.y
            ents = ika.EntitiesAt(*rect)
            for e in ents:
                if e is me.overlay or e in hitList: continue
                if e in engine.entFromEnt:
                    x = engine.entFromEnt[e]

                    if isinstance(
                            x,
                            Enemy) and not x.invincible and x not in hitList:
                        hitList.add(x)
                        x.hurt(int(me.stats.att), 120, me.direction)
                        me.giveMPforHit()

                    elif isinstance(x, Arrow):
                        hitList.add(x)
                        sound.deflect.Play()
                        engine.destroyEntity(x)

                    elif isinstance(x, _Powerup):
                        x.touch()

            self.cutBush(me, rect)

            if (controls.up()
                    or controls.joy_up()) and me.direction == dir.DOWN:
                backthrust = True
            elif (controls.down()
                  or controls.joy_down()) and me.direction == dir.UP:
                backthrust = True
            elif (controls.left() or controls.joy_left()) and me.direction in [
                    dir.RIGHT, dir.UPRIGHT, dir.DOWNRIGHT
            ]:
                backthrust = True
            elif (controls.right()
                  or controls.joy_right()) and me.direction in [
                      dir.LEFT, dir.UPLEFT, dir.DOWNLEFT
                  ]:
                backthrust = True
            elif (controls.attack1() or controls.joy_attack1()) and not thrust:
                backslash = True
            elif (controls.attack2()
                  or controls.joy_attack2()) and not backslash:
                thrust = True
            yield None

        if 0: me.overlay.renderscript = None

        if thrust:
            me.state = self.thrustState(me)
        elif backslash:
            me.state = self.backSlashState(me)
        else:
            # Stall:
            count = 8
            while count > 0:
                count -= 1
                #if controls.attack2():
                #    me.state = me.thrustState()
                yield None

        yield None
Exemple #6
0
 def standState(self):
     self.stop()
     self.anim = 'stand'
         
     while True:
         self.regenMP()        
         if controls.attack() or controls.joy_attack():
             self.state = self.slashState()
         elif controls.rend() or controls.joy_rend():
             self.state = self.hearthRendState()
             yield None
         elif controls.gale() or controls.joy_gale():
             self.state = self.crushingGaleState()
             yield None
         elif controls.heal() or controls.joy_heal():
             self.state = self.healingRainState()
             yield None
         elif controls.bolt() or controls.joy_bolt():
             self.state = self.boltState()
             yield None
         elif controls.left() or controls.right() or controls.up() or controls.down() or controls.joy_left() or controls.joy_right() or controls.joy_up() or controls.joy_down():
             self.state = self.walkState()
             self._state() # get the walk state started right now.
         yield None