Esempio n. 1
0
 def do_connect (self):
     # Buttons task assigment
     self.sound ["command"] = lambda: self.state.tasks.add (task.parallel (
         self.state.do_smile (),
         task.run (lambda: self.do_show ('sound'))
         ))
     self.keyboard ["command"] = lambda: self.state.tasks.add (task.parallel (
         self.state.do_smile (),
         task.run (lambda: self.do_show ('keyboard'))
         ))
     self.screen ["command"] = lambda: self.state.tasks.add (task.parallel (
         self.state.do_smile (),
         task.run (lambda: self.do_show ('screen'))
         ))
     self.back ["command"] = lambda: self.state.tasks.add (task.parallel (
         self.state.do_smile(),
         self.do_destroy()
         ))
Esempio n. 2
0
 def restore_transforms (self):
     sx, sy = self.GetCenter ()
     dx, dy = 1024./2 * self.model.map.zoom, 768/2. * self.model.map.zoom
     rot = self.GetRotation ()
     return task.parallel (task.sinusoid (lambda x: self.SetScale (x, x),
                                          self.GetScale () [0],
                                          1./self.model.map.zoom),
                           task.sinusoid (self.SetRotation,
                                          rot, shortest_angle (rot, 0)),
                           task.sinusoid (lambda x: self.set_center (
                               util.linear (sx, dx, x),
                               util.linear (sy, dy, x))))
Esempio n. 3
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
Esempio n. 4
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
Esempio n. 5
0
    def do_connect (self):
        # Buttons task assigment
        if self.type == 'main':
            self.start["command"] = lambda: self.state.tasks.add( task.sequence(
                task.run (self.do_disable_this),
                task.parallel (
                    self.options_menu.do_destroy (),
                    self.credits_menu.do_destroy (),
                    task.run (self.state.to_smile),
                ),
                task.run (lambda: self.state.manager.leave_state ('game'))
            ))
            self.exit["command"] = lambda: self.state.tasks.add (task.sequence(
                task.run (self.do_disable_this),
                task.parallel(
                    self.options_menu.do_destroy (),
                    self.credits_menu.do_destroy (),
                    task.run (self.state.to_smile),
                ),
                task.run (self.state.manager.leave_state)
            ))
            self.state.events.event ('panda-escape').connect (lambda:
                self.state.tasks.add (task.sequence (
                    task.delay (),
                    task.run (self.exit["command"]))))

        if self.type == 'ingame':
            self.start["command"] = lambda: self.state.tasks.add( task.sequence(
                task.run (self.do_disable_this),
                task.parallel (
                    self.options_menu.do_destroy (),
                    self.credits_menu.do_destroy (),
                    task.run (self.state.to_smile),
                ),
                task.run (lambda: self.state.manager.leave_state ('continue'))
            ))
            self.exit["command"] = lambda: self.state.tasks.add (task.sequence(
                task.run (self.do_disable_this),
                task.parallel (
                    self.options_menu.do_destroy (),
                    self.credits_menu.do_destroy (),
                    task.run (self.state.to_smile),
                ),
                task.run (lambda: self.state.manager.leave_state ('quit'))
            ))
            self.state.events.event ('panda-escape').connect (lambda:
                self.state.tasks.add (task.sequence (
                    task.delay (),
                    task.run (self.start["command"]))))

        self.credits["command"] = lambda: self.state.tasks.add (
            self.do_show_credits ())

        self.options["command"] = lambda: self.state.tasks.add (task.sequence (
            task.run (lambda: self.options.setProp ('state', DGG.DISABLED)),
            task.parallel(
                self.state.do_smile (),
                self.do_show_options (),
            ),
            task.run (lambda: self.options.setProp ('state', DGG.NORMAL))
            ))
Esempio n. 6
0
 def rotate_to_owner (self):
     return task.parallel (* [ self.rotate_sth_to_player (r, r.model.owner)
                               for r in self._regions if r.model.owner ])
Esempio n. 7
0
 def rotate_to_player (self, player):
     return task.parallel (* [ self.rotate_sth_to_player (s, player)
                               for s in (self._regions + self._continents )])
Esempio n. 8
0
    def do_paint (self):
        # Option-Buttons inicialitation
        self.sound = DirectButton(geom = self.state.bt_yellow,
            geom_scale = (4.5, 2, 2),
            geom_pos = (.4, 0, 0.3),
            text = "Sound",
            text_font = self.state.font,
            text_scale = (0.8, 0.9),
            scale = .1,
            pos = (-0.1, 0, 0.55),
            relief = None,
            state = DGG.DISABLED
            )
        self.sound.setAlphaScale (0)

        self.keyboard = DirectButton(geom = self.state.bt_yellow,
            geom_scale = (6.8, 2, 2.2),
            geom_pos = (.6, 0, 0.3),
            text = "Keyboard",
            text_font = self.state.font,
            text_scale = (0.8, 0.9),
            scale = .1,
            pos = (-0.1, 0, 0.55),
            relief = None,
            state = DGG.DISABLED
            )
        self.keyboard.setAlphaScale (0)
                    
        self.screen = DirectButton(geom = self.state.bt_yellow,
            geom_scale = (4.7, 2, 2),
            geom_pos = (.4, 0, 0.3),
            text = "Screen",
            text_font = self.state.font,
            text_scale = (0.8, 0.9),
            scale = .1,
            pos = (-0.1, 0, 0.55),
            relief = None,
            state = DGG.DISABLED
            )
        self.screen.setAlphaScale (0)
                    
        self.back = DirectButton(geom = self.state.bt_yellow,
            geom_scale = (4, 2, 2),
            geom_pos = (.4, 0, 0.3),
            text = "Back",
            text_font = self.state.font,
            text_scale = (0.8, 0.9),
            scale = .1,
            pos = (-0.1, 0, 0.55),
            relief = None,
            state = DGG.DISABLED
            )
        self.back.setAlphaScale (0)
        
        #Movement task creation
        self.move_task = task.sequence(
            task.parallel(
                task.sinusoid (lambda x: 
                    self.sound.setPos ((x*0.55)-0.1, 0, 0.55+(x*0.25))),
                task.sinusoid (lambda x: self.sound.setAlphaScale (x)),
                
                task.sinusoid (lambda x: 
                    self.keyboard.setPos ((x*0.7)-0.1, 0, 0.55)),
                task.sinusoid (lambda x: self.keyboard.setAlphaScale (x)),

                task.sinusoid (lambda x: 
                    self.screen.setPos ((x*0.65)-0.1, 0, 0.55-(x*0.25))),
                task.sinusoid (lambda x: self.screen.setAlphaScale (x)),

                task.sinusoid (lambda x:
                    self.back.setPos ((x*0.65)-0.1, 0, 0.55-(x*0.5))),
                task.sinusoid (lambda x: self.back.setAlphaScale (x))
            ),
            task.run (lambda: self.do_enable ())
            )
        
        self.do_connect ()
        
        #The option_menu is set as active
        self.active = True
        
        return self.move_task
Esempio n. 9
0
    def do_connect(self):
        # Buttons task assigment
        if self.type == 'main':
            self.start["command"] = lambda: self.state.tasks.add(
                task.sequence(
                    task.run(self.do_disable_this),
                    task.parallel(
                        self.options_menu.do_destroy(),
                        self.credits_menu.do_destroy(),
                        task.run(self.state.to_smile),
                    ), task.run(lambda: self.state.manager.leave_state('game'))
                ))
            self.exit["command"] = lambda: self.state.tasks.add(
                task.sequence(
                    task.run(self.do_disable_this),
                    task.parallel(
                        self.options_menu.do_destroy(),
                        self.credits_menu.do_destroy(),
                        task.run(self.state.to_smile),
                    ), task.run(self.state.manager.leave_state)))
            self.state.events.event('panda-escape').connect(
                lambda: self.state.tasks.add(
                    task.sequence(task.delay(), task.run(self.exit["command"]))
                ))

        if self.type == 'ingame':
            self.start["command"] = lambda: self.state.tasks.add(
                task.sequence(
                    task.run(self.do_disable_this),
                    task.parallel(
                        self.options_menu.do_destroy(),
                        self.credits_menu.do_destroy(),
                        task.run(self.state.to_smile),
                    ),
                    task.run(lambda: self.state.manager.leave_state('continue')
                             )))
            self.exit["command"] = lambda: self.state.tasks.add(
                task.sequence(
                    task.run(self.do_disable_this),
                    task.parallel(
                        self.options_menu.do_destroy(),
                        self.credits_menu.do_destroy(),
                        task.run(self.state.to_smile),
                    ), task.run(lambda: self.state.manager.leave_state('quit'))
                ))
            self.state.events.event('panda-escape').connect(
                lambda: self.state.tasks.add(
                    task.sequence(task.delay(), task.run(self.start["command"])
                                  )))

        self.credits["command"] = lambda: self.state.tasks.add(
            self.do_show_credits())

        self.options["command"] = lambda: self.state.tasks.add(
            task.sequence(
                task.run(lambda: self.options.setProp('state', DGG.DISABLED)),
                task.parallel(
                    self.state.do_smile(),
                    self.do_show_options(),
                ), task.run(lambda: self.options.setProp('state', DGG.NORMAL)))
        )