예제 #1
0
 def on_seed_corruption(self, ev, signal):
     if self.x == ev.x and self.y == ev.y:
         if not self.is_corrupt:
             self.is_corrupt = True
             tween(self, 'color', COLOR_NEARBLACK, 1.0, easing='out_quad')
             tween(self, 'size', 0.8, 1.0, easing='out_quad')
             self.sparkle(1.0, rate=0.1)
             delay(1.0, lambda: signal(SeedCorruptionComplete()))
예제 #2
0
 def attack(self, dmg, signal):
     tween(self, 'position', self.position - V(1, 0), 0.1, easing='in_quad')
     tween(self,
           'position',
           self.position,
           0.1,
           delay=0.1,
           easing='out_quad')
     delay(0.1, lambda: signal(DamageDealt('player', dmg)))
     self.plan_attack()
예제 #3
0
    def spawn_monster(self, monster):
        monster.image = ENEMIES[self.monster_index]['image']
        monster.hp = int(ENEMIES[self.monster_index]['hp'] * self.danger)
        monster.hp_bar.max = monster.hp
        monster.strength = int(ENEMIES[self.monster_index]['strength'] *
                               self.danger)

        monster.position = POS_ENEMY + V(4, 0)
        monster.opacity = 255
        monster.size = ENEMIES[self.monster_index].get('size', 4.0)

        tween(monster, 'position', POS_ENEMY, 1.0)
예제 #4
0
def chime(t, signal):
    global _chime_playing
    if not _chime_playing:
        signal(PlaySound(SOUND_CHIME))
        SOUND_CHIME.volume = 6.0
        tween(SOUND_CHIME, 'volume', 0.0, t, easing='out_quad')
        _chime_playing = True

        def done():
            global _chime_playing
            _chime_playing = False

        delay(t, done)
예제 #5
0
    def swap_seeds(self, x, y, lx, ly):
        # assert not self.tweener.is_tweening
        # swap seed1 and seed2
        try:
            seed1 = GRID[x, y]
            seed2 = GRID[lx, ly]
        except KeyError:
            return
        else:
            GRID[x, y] = seed2
            GRID[lx, ly] = seed1
            seed2.x = x
            seed2.y = y
            seed1.x = lx
            seed1.y = ly
            tween(seed1, 'position', V(lx, ly), 0.25)
            tween(seed2, 'position', V(x, y), 0.25)

            self.last_swap = (x, y, lx, ly)
예제 #6
0
    def on_damage_dealt(self, ev, signal):
        if ev.target == 'monster' and self.hp:
            tween(self,
                  'position',
                  self.position + V(0.25, 0),
                  0.1,
                  easing='in_quad')
            tween(self,
                  'position',
                  self.position,
                  0.1,
                  delay=0.1,
                  easing='out_quad')
            self.hp -= ev.dmg

            if self.hp <= 0:
                signal(MonsterDeath(self))
            else:
                self.plan_attack()
예제 #7
0
    def on_monster_death(self, ev, signal):
        t = ENEMIES[self.monster_index].get('deathtime', 2.0)

        delay(0.5, lambda: setattr(ev.monster, 'smoke_enabled', False))
        delay(
            1.0, lambda: tween(ev.monster,
                               'position',
                               POS_ENEMY + V(4, 0),
                               2.0,
                               easing='out_quad'))
        delay(3.0, lambda: setattr(ev.monster, 'smoke_enabled', True))
        delay(3.0, lambda: signal(MonsterSpawn(ev.monster)))
예제 #8
0
    def on_damage_dealt(self, ev, signal):
        if ev.target == 'player':
            self.shield -= ev.dmg
            if self.shield < 0:
                self.hp += self.shield
                self.shield = 0
                if self.hp < 0:
                    self.hp = 0

                if self.hp <= 0:
                    signal(PlayerDeath(self))
                else:
                    tween(self,
                          'position',
                          self.position - V(1, 0),
                          0.1,
                          easing='in_quad')
                    tween(self,
                          'position',
                          self.position,
                          0.2,
                          delay=0.1,
                          easing='out_quad')
                    signal(PlaySound(choice(SOUND_HURT_SET)))
예제 #9
0
 def return_to_cell(self):
     tween(self, 'position', V(self.x, self.y), 0.25, easing='out_quad')