示例#1
0
    def fuck_me (self, pos = None):
        if not pos:
            pos = self.position

        self._model.detachNode ()
            
        node = self.entities.render
        self._smoke_particles.start (node)
        self._smoke_particles.setPos (pos + Vec3 (0, 0, 2))
        self._fire_particles.start (node)
        self._fire_particles.setPos (pos)
            
        self.entities.tasks.add (task.sequence (
            task.wait (2.),
            task.run (self._fire_particles.softStop),
            task.wait (2.),
            task.run (self._smoke_particles.softStop),
            task.wait (2.),
            task.run (self.dispose)))

        self.disable_physics ()
        random.choice (self.death_sounds).play ()
            
        self.on_death ()
        self.is_dead = True
示例#2
0
    def do_paint(self):
        tx_scale = (0.6, 0.6)
        init = -0.25
        dif = -0.06

        self.prog_lab = []
        self.arts_lab = []
        self.mus_lab = []

        i = 0
        self.prog_tab = OnscreenText(text='Programmers',
                                     font=self.state.font,
                                     align=TextNode.ALeft,
                                     pos=(-0.2, init + dif * i),
                                     scale=0.05)
        for n in self.PROGRAMMERS:
            self.prog_lab.append(
                OnscreenText(text=n,
                             font=self.state.font,
                             align=TextNode.ALeft,
                             pos=(0.4, init + dif * i),
                             scale=0.04))
            i += 1

        i += 2
        self.arts_tab = OnscreenText(text='Artists',
                                     font=self.state.font,
                                     align=TextNode.ALeft,
                                     pos=(-0.2, init + dif * i),
                                     scale=0.05)
        for n in self.ARTISTS:
            self.arts_lab.append(
                OnscreenText(text=n,
                             font=self.state.font,
                             align=TextNode.ALeft,
                             pos=(0.4, init + dif * i),
                             scale=0.04))
            i += 1

        i += 2
        self.mus_tab = OnscreenText(text='Music by',
                                    font=self.state.font,
                                    align=TextNode.ALeft,
                                    pos=(-0.2, init + dif * i),
                                    scale=0.05)
        for n in self.SOUND:
            self.mus_lab.append(
                OnscreenText(text=n,
                             font=self.state.font,
                             align=TextNode.ALeft,
                             pos=(0.4, init + dif * i),
                             scale=0.04))
            i += 1
        self.active = True

        return task.wait(0)
示例#3
0
 def do_show_credits(self):
     if self.options_menu.active:
         self.move_task = self.options_menu.do_destroy()
     else:
         self.move_task = task.wait(0)
     if not self.credits_menu.active:
         self.credits_menu.do_paint()
     else:
         self.credits_menu.do_destroy()
     return self.move_task
示例#4
0
 def do_show_credits (self):
     if self.options_menu.active:
         self.move_task = self.options_menu.do_destroy ()
     else:
         self.move_task = task.wait (0)
     if not self.credits_menu.active:
         self.credits_menu.do_paint()
     else:
         self.credits_menu.do_destroy()
     return self.move_task
示例#5
0
 def _make_roll_dice_task (self, dice_iter):
     def roll_dice_fn ():
         try:
             dice = dice_iter.next ()
             dice.roll ()
             self.manager.system.audio.play_sound (random.choice (map (
                 lambda i: 'data/sfx/canon/canon-%i.wav' % i, range (1, 4))))
             self.tasks.add (self._make_roll_dice_task (dice_iter))
         except StopIteration:
             self._evaluate_dices ()
     return task.sequence (task.wait (.5), task.run (roll_dice_fn))
示例#6
0
    def do_destroy(self):
        if self.active:
            for n in self.prog_lab:
                n.destroy()
            for n in self.arts_lab:
                n.destroy()
            for n in self.mus_lab:
                n.destroy()
            self.prog_tab.destroy()
            self.arts_tab.destroy()
            self.mus_tab.destroy()

            self.active = False

        return task.wait(0)
示例#7
0
    def do_destroy (self):
        if self.active:
            for n in self.prog_lab:
                n.destroy ()
            for n in self.arts_lab:
                n.destroy ()
            for n in self.mus_lab:
                n.destroy ()
            self.prog_tab.destroy ()
            self.arts_tab.destroy ()
            self.mus_tab.destroy ()
        
            self.active = False

        return task.wait(0)
示例#8
0
    def _soft_move (self, dst):
        if self._move_task:
            self._move_task.kill ()
        
        next_time = 0
        group = task.parallel ()

        for n in self._counter_nodes:
            group.add (task.sequence (
                task.wait (next_time),
                task.linear (n.setPos, n.getPos (), dst, init = True)))
            next_time += .5

        self.entities.tasks.add (group)
        self._move_task = group
        return group
示例#9
0
    def do_destroy (self):
        if self.active:
            #Buttons destroy
            self.do_disable ()
    
            #Movement task creation
            self.move_task = task.sequence (
                task.parallel(
                    task.sinusoid (lambda x: 
                        self.sound.setPos (0.45-(x*0.55), 0, .8-(x*0.25))),
                    task.sinusoid (lambda x: self.sound.setAlphaScale (1-x)),
                    
                    task.sinusoid (lambda x: 
                        self.keyboard.setPos (0.6-(x*0.7), 0, 0.55)),
                    task.sinusoid (lambda x: self.keyboard.setAlphaScale (1-x)),

                    task.sinusoid (lambda x: 
                        self.screen.setPos (0.55-(x*0.65), 0, 0.3+(x*0.25))),
                    task.sinusoid (lambda x: self.screen.setAlphaScale (1-x)),
                    
                    task.sinusoid (lambda x: 
                        self.back.setPos (0.55-(x*0.65), 0, 0.05+(x*0.5))),
                    task.sinusoid (lambda x: self.back.setAlphaScale (1-x))
                ),
                task.run (self.sound.destroy),
                task.run (self.back.destroy),
                task.run (self.keyboard.destroy),
                task.run (self.screen.destroy)
                )
            
            for n in self.sub_menus.keys():
                if self.sub_menus[n].active:
                    self.sub_menus[n].do_destroy ()
                
            #The option_menu is set as inactive 
            self.active = False
        else:
            self.move_task = task.wait(0)
            
        return self.move_task
示例#10
0
 def _make_dice_eval_task (self, dice_iter):
     use_on_attack = self.game.world.use_on_attack
     def eval_dice_fn ():
         try:
             attack_dice, defend_dice = dice_iter.next ()
             if attack_dice.value > defend_dice.value:
                 attack_dice.win ()
                 defend_dice.fail ()
                 self.defender.model.troops -= 1
             else:
                 attack_dice.fail ()
                 defend_dice.win ()
                 if use_on_attack:
                     self.attacker.model.used -= 1
                 else:
                     self.attacker.model.troops -= 1
             self.manager.system.audio.play_sound (random.choice (map (
                 lambda i: 'data/sfx/swords/sword_%i.wav'%i, range (1,7))))
             self.tasks.add (self._make_dice_eval_task (dice_iter))
         except StopIteration:
             self.ui_attack.enable_continue ()
     return task.sequence (task.wait (.5), task.run (eval_dice_fn))
示例#11
0
    def __init__ (self,
                  model = pigeon_model,
                  anims = pigeon_anims,
                  boys  = [],
                  *a, **k):
        super (Pigeon, self).__init__ (
            geometry = geom.capsule (2, 1),
            #mass     = mass.sphere (1, 2),
            model    = model,
            anims    = anims,
            category = pigeon_category,
            *a, **k)

        self.on_is_on_floor_change += self.on_pigeon_is_on_floor
        self.on_hit   += self.on_pigeon_hit
        self.on_death += self.on_pigeon_death
        for boy in boys:
            boy.on_boy_noise += self.on_boy_noise
            boy.on_entity_set_position  += self.on_boy_move
        
        self.physical_hpr = Vec3 (90, 0, 0)
        self.params = BoidParams ()
        
        self.model_position = Vec3 (0, 0, -2)
        self.model_scale    = Vec3 (0.08, 0.08, 0.08)
        self.model_hpr      = Vec3 (180, 0, 0)

        self.add_state ('fly',    FlyState)
        self.add_state ('walk',   WalkState)
        self.add_state ('follow', FollowState)
        self.add_state ('fear',   FearState)
        self.add_state ('eat',    EatState)
        self.add_state ('hit',    HitState)
        self.add_state ('land',   LandState)
        self.add_state ('return', ReturnState)
        self.add_state ('attack', AttackState)
        
        self.model.loop ('fly')
        self.curr_animation = 'fly'
        self.anim_speed = 50

        # Hack: 3D audio seems very slow, so only some pigeons emit
        # some kinds of sounds.
        
        if random.uniform (0, 10) < 2.:
            self._coo_sounds = map (self.load_sound,
                                    map (lambda x: "snd/pigeon-coo-%i.wav" % x,
                                         range (1, 5)))
            self.tasks.add (task.sequence (
                task.wait (random.uniform (0, 20)),
                task.loop (
                    task.func_wait (partial (random.uniform, 10, 30)),
                    task.run (lambda: random.choice (self._coo_sounds).play ()
                              ))))

        else:
            self._coo_sounds = []

        if random.uniform (0, 10) < 2.:
            self._fly_sound = self.load_sound ('snd/pigeon-start.wav')
        else:
            self._fly_sound = None
            
        if random.uniform (0, 10) < 2.:
            self._fear_sound = self.load_sound ('snd/pigeon-flap.wav')  
        else:
            self._fear_sound = None
            
        self.start ('land')
示例#12
0
 def do_pigeon_setup (self):
     self.tasks.add (task.sequence (task.wait (2.), task.run (self.kill)))
     self.manager.pigeon_sweeping = False
示例#13
0
    def do_paint (self):
        tx_scale = (0.6, 0.6)
        init = -0.25
        dif = -0.06
        
        self.prog_lab = []
        self.arts_lab = []
        self.mus_lab = [] 

        i = 0
        self.prog_tab = OnscreenText(
            text = 'Programmers',
            font = self.state.font,
            align = TextNode.ALeft,
            pos = (-0.2, init+dif*i),
            scale = 0.05
            )
        for n in self.PROGRAMMERS:
            self.prog_lab.append (OnscreenText(
                text = n,
                font = self.state.font,
                align = TextNode.ALeft,
                pos = (0.4, init+dif*i),
                scale = 0.04
            ))
            i += 1
        
        i += 2
        self.arts_tab = OnscreenText(
            text = 'Artists',
            font = self.state.font,
            align = TextNode.ALeft,
            pos = (-0.2, init+dif*i),
            scale = 0.05
            )
        for n in self.ARTISTS:
            self.arts_lab.append (OnscreenText(
                text = n,
                font = self.state.font,
                align = TextNode.ALeft,
                pos = (0.4, init+dif*i),
                scale = 0.04
            ))
            i += 1
        
        i += 2
        self.mus_tab = OnscreenText(
            text = 'Music by',
            font = self.state.font,
            align = TextNode.ALeft,
            pos = (-0.2, init+dif*i),
            scale = 0.05
            )
        for n in self.SOUND:
            self.mus_lab.append (OnscreenText(
                text = n,
                font = self.state.font,
                align = TextNode.ALeft,
                pos = (0.4, init+dif*i),
                scale = 0.04
            ))
            i += 1
        self.active = True

        return task.wait(0)
示例#14
0
 def do_smile(self, time=0.2):
     return task.sequence(task.run(self.to_smile), task.wait(time),
                          task.run(self.to_normal))
示例#15
0
文件: menu.py 项目: arximboldi/jagsat
 def _on_click_quit (self, ev = None):
     self.manager.enter_state ('dialog', mk_dialog = CreditsDialog)
     self.parent_state.tasks.add (task.sequence (
         task.wait (5.),
         task.run (self.manager.leave_state),
         task.run (self.manager.leave_state)))
示例#16
0
 def _on_click_quit(self, ev=None):
     self.manager.enter_state('dialog', mk_dialog=CreditsDialog)
     self.parent_state.tasks.add(
         task.sequence(task.wait(5.), task.run(self.manager.leave_state),
                       task.run(self.manager.leave_state)))
示例#17
0
    def __init__(self,
                 model=pigeon_model,
                 anims=pigeon_anims,
                 boys=[],
                 *a,
                 **k):
        super(Pigeon, self).__init__(
            geometry=geom.capsule(2, 1),
            #mass     = mass.sphere (1, 2),
            model=model,
            anims=anims,
            category=pigeon_category,
            *a,
            **k)

        self.on_is_on_floor_change += self.on_pigeon_is_on_floor
        self.on_hit += self.on_pigeon_hit
        self.on_death += self.on_pigeon_death
        for boy in boys:
            boy.on_boy_noise += self.on_boy_noise
            boy.on_entity_set_position += self.on_boy_move

        self.physical_hpr = Vec3(90, 0, 0)
        self.params = BoidParams()

        self.model_position = Vec3(0, 0, -2)
        self.model_scale = Vec3(0.08, 0.08, 0.08)
        self.model_hpr = Vec3(180, 0, 0)

        self.add_state('fly', FlyState)
        self.add_state('walk', WalkState)
        self.add_state('follow', FollowState)
        self.add_state('fear', FearState)
        self.add_state('eat', EatState)
        self.add_state('hit', HitState)
        self.add_state('land', LandState)
        self.add_state('return', ReturnState)
        self.add_state('attack', AttackState)

        self.model.loop('fly')
        self.curr_animation = 'fly'
        self.anim_speed = 50

        # Hack: 3D audio seems very slow, so only some pigeons emit
        # some kinds of sounds.

        if random.uniform(0, 10) < 2.:
            self._coo_sounds = map(
                self.load_sound,
                map(lambda x: "snd/pigeon-coo-%i.wav" % x, range(1, 5)))
            self.tasks.add(
                task.sequence(
                    task.wait(random.uniform(0, 20)),
                    task.loop(
                        task.func_wait(partial(random.uniform, 10, 30)),
                        task.run(
                            lambda: random.choice(self._coo_sounds).play()))))

        else:
            self._coo_sounds = []

        if random.uniform(0, 10) < 2.:
            self._fly_sound = self.load_sound('snd/pigeon-start.wav')
        else:
            self._fly_sound = None

        if random.uniform(0, 10) < 2.:
            self._fear_sound = self.load_sound('snd/pigeon-flap.wav')
        else:
            self._fear_sound = None

        self.start('land')
示例#18
0
 def do_pigeon_setup(self):
     self.tasks.add(task.sequence(task.wait(2.), task.run(self.kill)))
     self.manager.pigeon_sweeping = False
示例#19
0
 def do_pigeon_setup(self):
     super(PatrolState, self).do_pigeon_setup()
     self.tasks.add(
         task.sequence(task.wait(random.uniform(15, 30)),
                       task.run(self.next_state)))
示例#20
0
 def do_pigeon_setup (self):
     super (PatrolState, self).do_pigeon_setup ()
     self.tasks.add (task.sequence (
         task.wait (random.uniform (15, 30)),
         task.run (self.next_state)))
示例#21
0
 def do_smile (self, time = 0.2):
     return task.sequence(
         task.run (self.to_smile),
         task.wait (time),
         task.run (self.to_normal))