Beispiel #1
0
    def __init__(self, offset, h_size, v_size, numLines, hugpos):
        self.numLines = numLines
        #if hugpos == "statusbar":
        #    color = (0,0,0,1)
        #else:
        #    color = (0.2, 0.2, 0.2, 0.8)
        color = (0.2, 0.2, 0.2, 0.9)
        self.frame = DirectFrame(   relief = DGG.FLAT
                                  , frameColor = color
                                  , scale = 1
                                  , frameSize = (0, h_size, 0, -v_size) )
        self.v_size = v_size
        self.hugpos = hugpos
        self.offset = offset
        
        if hugpos == "top":
            self.frame.reparentTo(base.a2dTopLeft)#@UndefinedVariable
            self.frame.setPos(self.offset.getX(), 0, self.offset.getZ() - GUI_TOP_OFFSET)
        elif hugpos == "bottom":
            self.frame.reparentTo(base.a2dBottomLeft)#@UndefinedVariable
            self.frame.setPos(self.offset.getX(), 0, self.offset.getZ() + GUI_BOTTOM_OFFSET -0.085)
        elif hugpos == "statusbar":
            self.frame.reparentTo(base.a2dTopLeft)#@UndefinedVariable
            self.frame.setPos(self.offset.getX(), 0, self.offset.getZ())

        fixedWidthFont = loader.loadFont(GUI_FONT)#@UndefinedVariable
        if not fixedWidthFont.isValid():
            print "pandaInteractiveConsole.py :: could not load the defined font %s" % str(self.font)
            fixedWidthFont = DGG.getDefaultFont()
        
        if numLines == 1:
            self.lineHeight = 0.05
        else:
            self.lineHeight = v_size*0.9 / numLines
            
        # output lines
        self.frameOutputList = list()
        for i in xrange( self.numLines ):
            label = OnscreenText( parent = self.frame
                              , text = ""
                              , pos = (0.005, -(i+1)*self.lineHeight)
                              , align=TextNode.ALeft
                              , mayChange=1
                              , scale=0.04
                              , fg = (1,1,1,1)
                              , shadow = (0, 0, 0, 1))
                              #, frame = (200,0,0,1) )
            label.setFont( fixedWidthFont )
            self.frameOutputList.append( label )
Beispiel #2
0
 def __init__( self, parent ):
   self.parent = parent
   
   # line wrapper
   self.linewrap = textwrap.TextWrapper()
   self.linewrap.width = self.linelength
   
   # calculate window size
   left   = (self.h_pos) / self.scale
   right  = (self.h_pos + self.h_size) / self.scale
   bottom = (self.v_pos) / self.scale
   top    = (self.v_pos + self.v_size) /self.scale
   
   # panda3d interface
   self.consoleFrame = DirectFrame ( relief = DGG.GROOVE
                                   , frameColor = (200, 200, 200, 0.5)
                                   , scale=self.scale
                                   , frameSize = (0, self.h_size / self.scale, 0, self.v_size / self.scale) )
   self.windowEvent( base.win )
   
   # try to load the defined font
   try:
     fixedWidthFont = loader.loadFont(self.font)
   except:
     print "pandaInteractiveConsole.py :: could not load the defined font %s" % str(self.font)
     fixedWidthFont = DGG.getDefaultFont()
   # if font is not valid use default font
   if not fixedWidthFont.isValid():
     if self.font is None:
       print "pandaInteractiveConsole.py :: could not load the defined font %s" % str(self.font)
     fixedWidthFont = DGG.getDefaultFont()
   
   # text entry line
   self.consoleEntry = DirectEntry ( self.consoleFrame
                                   , text        = ""
                                   , command     = self.onEnterPress
                                   , width       = self.h_size/self.scale - 2
                                   , pos         = (1, 0, 1.5)
                                   , initialText = ""
                                   , numLines    = 1
                                   , focus       = 1
                                   , entryFont   = fixedWidthFont)
   
   # output lines
   self.consoleOutputList = list()
   for i in xrange( self.numlines ):
     label = OnscreenText( parent = self.consoleFrame
                         , text = ""
                         , pos = (1, -i+3+self.numlines)
                         , align=TextNode.ALeft
                         , mayChange=1
                         , scale=1.0
                         , fg = self.defaultTextColor )
     label.setFont( fixedWidthFont )
     self.consoleOutputList.append( label )
   
   # list of the last commands of the user
   self.userCommandList = list()
   self.userCommandListLength = 100
   for i in xrange(self.userCommandListLength):
     self.userCommandList.append('')
   self.userCommandPos = 0
   
   # buffer for data
   self.textBuffer = list()
   self.textBufferLength = 1000
   for i in xrange(self.textBufferLength):
     self.textBuffer.append(['', DEFAULT_COLOR])
   self.textBufferPos = self.textBufferLength-self.numlines
   
   # toggle the window at least once to activate the events
   self.toggleConsole()
   self.toggleConsole()
   
   # call the help-command on start
   self.onEnterPress("help")
Beispiel #3
0
class MyApp(ShowBase):

    def __init__(self):
        ShowBase.__init__(self)
        self.base = self
        self.font = loader.loadFont('1.ttf')
        self.buttonget= base.loader.loadSfx("buttonget.mp3")
        self.buttondown= base.loader.loadSfx("buttondown.mp3")
        self.victorymusic= base.loader.loadSfx("victory.mp3")
        self.falsemusic= base.loader.loadSfx("false.mp3")
        self.jiechu1 = 0
        self.jiechu2 = 0
        self.down = 0
        self.menuon = 0
        # ESC退出
        self.accept("escape", self.caidan)
        self.accept("q", self.victory)
        self.accept("w", self.false)
        # 背景
        self.beijing = OnscreenImage(
            image='1.jpg', pos=(0, 0, 0.02), scale=(1.4, 1, 1.02))
        # 开始游戏碰之前图片
        self.a1 = OnscreenImage(image='buttontemp2.png',
                                pos=(0.8, 0, -0.5), scale=(0.2, 0.1, 0.065))
        self.a1.setTransparency(TransparencyAttrib.MAlpha)
        # 碰到开始游戏后显示的按钮
        self.zjmkaishi = DirectButton(text=('', '', '', 'disabled'), image='button2.png', frameColor=(255, 255, 255, 0),
                                      image_scale=(1.8, 1, 0.6), pos=(0.8, 0, -0.5), scale=0.1,
                                      rolloverSound=self.buttonget,clickSound=self.buttondown,
                                      command=self.putdown)
                                      #(2, 1, 0.7)
        self.zjmkaishi.hide()
        self.b1 = OnscreenImage(image='buttontemp1.png',
                                pos=(0.8, 0, -0.5), scale=(0.25, 0.1, 0.13))
        self.b1.setTransparency(TransparencyAttrib.MAlpha)
        self.b1.hide()
        # 点击开始游戏后图片
        self.c1 = OnscreenImage(image='buttontemp3.png',
                                pos=(0.8, 0, -0.5), scale=(0.2, 0.1, 0.065))
        self.c1.setTransparency(TransparencyAttrib.MAlpha)
        self.c1.hide()
        # 开始游戏显示的文字
        self.textObjectstart1 = OnscreenText(
            text='开始游戏', pos=(0.8, -0.51, 0), scale=0.05, fg=(255, 255, 255, 1))
        self.textObjectstart2 = OnscreenText(
            text='开始游戏', pos=(0.8, -0.51, 0), scale=0.055, fg=(255, 255, 255, 1))
        self.textObjectstart2.hide()
        self.textObjectstart3 = OnscreenText(
            text='开始游戏', pos=(0.8, -0.51, 0), scale=0.06, fg=(255, 255, 255, 1))
        self.textObjectstart3.hide()
        self.textObjectstart1.setFont(self.font)
        self.textObjectstart2.setFont(self.font)
        self.textObjectstart3.setFont(self.font)

        # 退出游戏碰之前图片
        self.a2 = OnscreenImage(image='buttontemp2.png',
                                pos=(0.8, 0, -0.7), scale=(0.2, 0.1, 0.065))
        self.a2.setTransparency(TransparencyAttrib.MAlpha)
        # 碰到退出游戏后显示的按钮
        self.zjmkaishi2 = DirectButton(text=('', '', '', 'disabled'), image='button2.png', frameColor=(255, 255, 255, 0),
                                       image_scale=(1.8, 1, 0.6), pos=(0.8, 0, -0.7), scale=0.1, command=self.quit,
                                       rolloverSound=self.buttonget,clickSound=self.buttondown)
        self.zjmkaishi2.hide()
        self.b2 = OnscreenImage(image='buttontemp1.png',
                                pos=(0.8, 0, -0.7), scale=(0.25, 0.1, 0.13))
        self.b2.setTransparency(TransparencyAttrib.MAlpha)
        self.b2.hide()
        # 点击退出游戏后图片
        self.c2 = OnscreenImage(image='buttontemp3.png',
                                pos=(0.8, 0, -0.7), scale=(0.2, 0.1, 0.071))
        self.c2.setTransparency(TransparencyAttrib.MAlpha)
        self.c2.hide()
        # 退出游戏显示的文字
        self.textObjectstart4 = OnscreenText(
            text='退出', pos=(0.8, -0.71, 0), scale=0.05, fg=(255, 255, 255, 1))
        self.textObjectstart5 = OnscreenText(
            text='退出', pos=(0.8, -0.71, 0), scale=0.055, fg=(255, 255, 255, 1))
        self.textObjectstart5.hide()
        self.textObjectstart6 = OnscreenText(
            text='退出', pos=(0.8, -0.71, 0), scale=0.06, fg=(255, 255, 255, 1))
        self.textObjectstart6.hide()
        self.textObjectstart4.setFont(self.font)
        self.textObjectstart5.setFont(self.font)
        self.textObjectstart6.setFont(self.font)

        # ESC菜单
        self.caidanjiemian = OnscreenImage(
            image='caidan.jpg', pos=(0, 0, 0), scale=(0.5, 0.1, 0.41))
        self.caidanjiemian.hide()

        self.bangzhu1button = DirectButton(text=('', '', '', 'disabled'), image='button1.png', frameColor=(255, 255, 255, 0),
                                           image_scale=(2.2, 1, 0.7), pos=(0, 0, 0.23), scale=0.1, command=self.putdown1,
                                           rolloverSound=self.buttonget,clickSound=self.buttondown)
        self.bangzhu1button.hide()
        self.bangzhu1 = OnscreenText(text='游戏帮助', pos=(
            0, 0.21, 0), scale=0.05, fg=(255, 255, 255, 1))
        self.bangzhu1.setFont(self.font)
        self.bangzhu1.hide()

        self.bangzhu2button = DirectButton(text=('', '', '', 'disabled'), image='button1.png', frameColor=(255, 255, 255, 0),
                                           image_scale=(2.2, 1, 0.7), pos=(0, 0, 0.03), scale=0.1, command=self.putdown2,
                                           rolloverSound=self.buttonget,clickSound=self.buttondown)
        self.bangzhu2button.hide()
        self.bangzhu2 = OnscreenText(text='继续游戏', pos=(
            0, 0.01, 0), scale=0.05, fg=(255, 255, 255, 1))
        self.bangzhu2.setFont(self.font)
        self.bangzhu2.hide()

        self.bangzhu3button = DirectButton(text=('', '', '', 'disabled'), image='button1.png', frameColor=(255, 255, 255, 0),
                                           image_scale=(2.2, 1, 0.7), pos=(0, 0, -0.18), scale=0.1, command=self.putdown3,
                                           rolloverSound=self.buttonget,clickSound=self.buttondown)
        self.bangzhu3button.hide()
        self.bangzhu3 = OnscreenText(text='退出游戏', pos=(
            0, -0.2, 0), scale=0.05, fg=(255, 255, 255, 1))
        self.bangzhu3.setFont(self.font)
        self.bangzhu3.hide()

        self.bangzhujiemian = OnscreenImage(
            image='caidan.jpg', pos=(-0, 0, 0), scale=(1, 0.1, 0.81))
        self.bangzhujiemian.hide()
        self.bangzhuxinxi = OnscreenText(
            text='coooooooooooooooool', pos=(0, 0, 0), scale=0.1)
        self.bangzhuxinxi.hide()
        self.bangzhuxinxibutton = DirectButton(text=('', '', '', 'disabled'), image='button1.png', frameColor=(255, 255, 255, 0),
                                               image_scale=(2.2, 1, 0.7), pos=(0.55, 0, -0.55), scale=0.1, command=self.help1,
                                               rolloverSound=self.buttonget,clickSound=self.buttondown)
        self.bangzhuxinxibutton.hide()
        self.bangzhuxinxi1 = OnscreenText(
            text='返回', pos=(0.55, -0.56, 0), scale=0.05, fg=(255, 255, 255, 1))
        self.bangzhuxinxi1.setFont(self.font)
        self.bangzhuxinxi1.hide()

        # 游戏胜利
        self.victorypic = OnscreenImage(
            image='victory.jpg', pos=(0, 0, 0.02), scale=(1.4, 1, 1.02))
        self.victorypic.hide()
        # 游戏失败
        self.falsepic = OnscreenImage(
            image='false.jpg', pos=(0, 0, 0.02), scale=(1.4, 1, 1.02))
        self.falsepic.hide()
        self.rebornbutton = DirectButton(text=('', '', '', 'disabled'), image='button1.png', frameColor=(255, 255, 255, 0),
                                         image_scale=(2.2, 1, 0.7), pos=(0.75, 0, -0.75), scale=0.1, command=self.reborn,
                                         rolloverSound=self.buttonget,clickSound=self.buttondown)
        self.rebornbutton.hide()
        self.reborntext = OnscreenText(
            text='返回主菜单', pos=(0.75, -0.76, 0), scale=0.05, fg=(255, 255, 255, 1))
        self.reborntext.setFont(self.font)
        self.reborntext.hide()

        #事件队列
        taskMgr.add(self.example, 'MyTaskName')

# 按下ESC触发
    def caidan(self):
        if(self.menuon == 0):
            self.menuon = 1
            self.caidanjiemian.show()
            self.bangzhu1button.show()
            self.bangzhu2button.show()
            self.bangzhu3button.show()
            self.bangzhu1.show()
            self.bangzhu2.show()
            self.bangzhu3.show()
        else:
            self.menuon = 0
            self.caidanjiemian.hide()
            self.bangzhu1button.hide()
            self.bangzhu2button.hide()
            self.bangzhu3button.hide()
            self.bangzhu1.hide()
            self.bangzhu2.hide()
            self.bangzhu3.hide()
            self.bangzhujiemian.hide()
            self.bangzhuxinxi.hide()
            self.bangzhuxinxi1.hide()
            self.bangzhuxinxibutton.hide()

# 无限循环
    def example(self, task):
        mpos = base.mouseWatcherNode.getMouse()
        if mpos.getY() < -0.42 and mpos.getY() > -0.55 and mpos.getX() > 0.45 and mpos.getX() < 0.75:
            #print(mpos.getY())
            self.jiechu1 = 1
        elif mpos.getY() < -0.62 and mpos.getY() > -0.75 and mpos.getX() > 0.45 and mpos.getX() < 0.75:
            # print(mpos.getY())
            self.jiechu2 = 1
        else:
            self.jiechu1 = 0
            self.jiechu2 = 0
        if(self.jiechu1 == 1 and self.down == 0):
            self.zjmkaishi.show()
            # self.textObjectstart1.hide()
            self.textObjectstart2.show()
            self.b1.show()
        elif(self.jiechu2 == 1 and self.down == 0):
            self.zjmkaishi2.show()
            # self.textObjectstart4.hide()
            self.textObjectstart5.show()
            self.b2.show()
        elif(self.down == 0):
            self.c1.hide()
            self.c2.hide()
            self.b1.hide()
            self.b2.hide()
            self.a1.show()
            self.a2.show()
            self.zjmkaishi.hide()
            self.textObjectstart3.hide()
            self.textObjectstart2.hide()
            self.textObjectstart1.show()
            self.zjmkaishi2.hide()
            self.textObjectstart6.hide()
            self.textObjectstart5.hide()
            self.textObjectstart4.show()
        else:
            self.b1.hide()
            self.b2.hide()
            self.zjmkaishi.hide()
            self.textObjectstart2.hide()
            self.zjmkaishi2.hide()
            self.textObjectstart5.hide()
        return task.cont
        # return task.done
# 按下开始游戏触发

    def putdown(self):
        print('start')
        self.down = 1
        self.a1.hide()
        self.b1.hide()
        self.zjmkaishi.hide()
        self.c1.show()
        self.textObjectstart1.hide()
        self.textObjectstart2.hide()
        self.textObjectstart3.show()

        self.beijing.hide()
        self.textObjectstart1.hide()
        self.textObjectstart2.hide()
        self.textObjectstart3.hide()
        self.textObjectstart4.hide()
        self.textObjectstart5.hide()
        self.textObjectstart6.hide()
        self.a1.hide()
        self.a2.hide()
        self.b1.hide()
        self.b2.hide()
        self.c1.hide()
        self.c2.hide()

# 按下退出游戏触发

    def quit(self):
        print('exit')
        self.down = 1
        self.a2.hide()
        self.zjmkaishi2.hide()
        self.c2.show()
        self.textObjectstart4.hide()
        self.textObjectstart5.hide()
        self.textObjectstart6.show()
        sys.exit()
# 按下菜单界面按钮触发

    def putdown1(self):
        self.caidanjiemian.hide()
        self.bangzhu1button.hide()
        self.bangzhu2button.hide()
        self.bangzhu3button.hide()
        self.bangzhu1.hide()
        self.bangzhu2.hide()
        self.bangzhu3.hide()
        self.bangzhujiemian.show()
        self.bangzhuxinxi.show()
        self.bangzhuxinxibutton.show()
        self.bangzhuxinxi1.show()

    def putdown2(self):
        self.menuon = 0
        self.caidanjiemian.hide()
        self.bangzhu1button.hide()
        self.bangzhu2button.hide()
        self.bangzhu3button.hide()
        self.bangzhu1.hide()
        self.bangzhu2.hide()
        self.bangzhu3.hide()
        self.bangzhujiemian.hide()
        self.bangzhuxinxi.hide()
        self.bangzhuxinxi1.hide()
        self.bangzhuxinxibutton.hide()


    def putdown3(self):
        sys.exit()
        # self.b.show()
# 按下帮助界面的返回触发

    def help1(self):
        self.caidanjiemian.show()
        self.bangzhu1button.show()
        self.bangzhu2button.show()
        self.bangzhu3button.show()
        self.bangzhu1.show()
        self.bangzhu2.show()
        self.bangzhu3.show()
        self.bangzhujiemian.hide()
        self.bangzhuxinxi.hide()
        self.bangzhuxinxibutton.hide()
        self.bangzhuxinxi1.hide()
# 胜利和失败触发

    def victory(self):
        self.victorypic.show()
        self.rebornbutton.show()
        self.reborntext.show()
        self.victorymusic.play()

    def false(self):
        self.falsepic.show()
        self.rebornbutton.show()
        self.reborntext.show()
        self.falsemusic.play()
    def reborn(self):
        print("reborn")
        self.rebornbutton.hide()
        self.reborntext.hide()
        self.victorypic.hide()
        self.falsepic.hide()
        self.down=0
        self.beijing.show()
Beispiel #4
0
    def __init__(self, class_parent, parent, h_size, v_size, aspect, hugpos):
        self.h_size = h_size
        self.v_size = v_size
        self.scale = 0.04
        self.parent = class_parent
        self.numlines = int(v_size / self.scale - 2)

        self.pos_min_x = 0
        self.pos_min_y = 0
        self.pos_max_x = self.h_size
        self.pos_max_y = 0.7

        if aspect > 0:
            self.pos_max_x /= aspect
        else:
            self.pos_max_y *= aspect

        self.consoleFrame = DirectFrame(relief=DGG.RIDGE,
                                        frameColor=(0, 0, 0, 0),
                                        scale=self.scale,
                                        frameSize=(0, self.h_size / self.scale,
                                                   0,
                                                   self.v_size / self.scale))

        if parent == base.a2dBottomLeft:  #@UndefinedVariable
            self.pos_min_x -= 1
            self.pos_min_y -= 1
            self.pos_max_x -= 1
            self.pos_max_y -= 1

        if hugpos == "bottom":
            self.consoleFrame.setPos(0, 0, GUI_BOTTOM_OFFSET - 0.085)
            self.pos_min_x = 0
            self.pos_min_y = GUI_BOTTOM_OFFSET - 0.085 - 0.07
            self.pos_max_x = self.h_size
            self.pos_max_y = GUI_BOTTOM_OFFSET - 0.085

        fixedWidthFont = loader.loadFont(GUI_FONT)  #@UndefinedVariable
        #fixedWidthFont.setPixelsPerUnit(60)
        #fixedWidthFont.setRenderMode(fixedWidthFont.RMSolid)
        if not fixedWidthFont.isValid():
            print "pandaInteractiveConsole.py :: could not load the defined font %s" % str(
                self.font)
            fixedWidthFont = DGG.getDefaultFont()

        #fixedWidthFont.setPageSize(512,512)
        #fixedWidthFont.setPixelsPerUnit(60)

        self.consoleEntry = DirectEntry(
            self.consoleFrame,
            text="",
            command=self.onEnterPress
            #, width       = self.h_size/self.scale -2
            ,
            pos=(0.01, 0, 0.02),
            initialText="Enter text...",
            numLines=1,
            focus=0,
            entryFont=fixedWidthFont,
            scale=1,
            frameColor=(0, 0, 0, 0.2),
            text_fg=(0, 1, 0, 1),
            text_shadow=(0, 0, 0, 1))

        #self.consoleEntry = DirectEntry(self.consoleFrame)

        self.consoleEntry["frameSize"] = (0, self.h_size / self.scale, 0, 1)
        self.consoleEntry["width"] = self.h_size / self.scale
        self.consoleEntry["focusInCommand"] = self.focusInCallback
        self.consoleEntry["focusOutCommand"] = self.focusOutCallback

        self.consoleFrame.reparentTo(parent)

        self.textBuffer = list()
        self.textBufferLength = 100
        for i in xrange(self.textBufferLength):
            self.textBuffer.append(['', (100, 100, 100, 1)])
        self.textBufferPos = self.textBufferLength - self.numlines

        # output lines
        self.consoleOutputList = list()
        for i in xrange(self.numlines):
            label = OnscreenText(parent=self.consoleFrame,
                                 text="",
                                 pos=(0, i + 1.5),
                                 align=TextNode.ALeft,
                                 mayChange=1,
                                 scale=1.0,
                                 fg=(100, 100, 100, 1),
                                 shadow=(0, 0, 0, 1))
            # , frame = (200,0,0,1) )
            label.setFont(fixedWidthFont)
            self.consoleOutputList.append(label)

        self.linelength = 57
        self.linewrap = textwrap.TextWrapper()
        self.linewrap.width = self.linelength
        self.toggleConsole()
Beispiel #5
0
class MyApp(ShowBase):
    def __init__(self):
        ShowBase.__init__(self)
        self.base = self
        self.font = loader.loadFont('1.ttf')
        self.jiechu1 = 0
        self.jiechu2 = 0
        self.down = 0
        self.menuon = 0
        # ESC退出
        self.accept("escape", self.caidan)
        # 背景
        self.beijing = OnscreenImage(image='1.jpg',
                                     pos=(0, 0, 0.02),
                                     scale=(1.4, 1, 1))
        # 开始游戏碰之前图片
        self.a1 = OnscreenImage(image='button3.png',
                                pos=(-0.8, 0, 0.7),
                                scale=(0.2, 0.1, 0.071))
        # 碰到开始游戏后显示的按钮
        self.zjmkaishi = DirectButton(text=('', '', '', 'disabled'),
                                      image='button2.png',
                                      frameColor=(255, 255, 255, 0),
                                      image_scale=(2, 1, 0.7),
                                      pos=(-0.8, 0, 0.7),
                                      scale=0.1,
                                      command=self.putdown)
        self.zjmkaishi.hide()
        # 点击开始游戏后图片
        self.c1 = OnscreenImage(image='button1.png',
                                pos=(-0.8, 0, 0.7),
                                scale=(0.2, 0.1, 0.071))
        self.c1.hide()
        # 开始游戏显示的文字
        self.textObjectstart1 = OnscreenText(text='开始游戏',
                                             pos=(-0.8, 0.68, 0),
                                             scale=0.05,
                                             fg=(255, 255, 255, 1))
        self.textObjectstart2 = OnscreenText(text='开始游戏',
                                             pos=(-0.8, 0.68, 0),
                                             scale=0.055,
                                             fg=(255, 255, 255, 1))
        self.textObjectstart2.hide()
        self.textObjectstart3 = OnscreenText(text='开始游戏',
                                             pos=(-0.8, 0.68, 0),
                                             scale=0.06,
                                             fg=(255, 255, 255, 1))
        self.textObjectstart3.hide()
        self.textObjectstart1.setFont(self.font)
        self.textObjectstart2.setFont(self.font)
        self.textObjectstart3.setFont(self.font)

        # 退出游戏碰之前图片
        self.a2 = OnscreenImage(image='button3.png',
                                pos=(-0.8, 0, 0.5),
                                scale=(0.2, 0.1, 0.071))
        # 碰到退出游戏后显示的按钮
        self.zjmkaishi2 = DirectButton(text=('', '', '', 'disabled'),
                                       image='button2.png',
                                       frameColor=(255, 255, 255, 0),
                                       image_scale=(2, 1, 0.7),
                                       pos=(-0.8, 0, 0.5),
                                       scale=0.1,
                                       command=self.quit)
        self.zjmkaishi2.hide()
        # 点击退出游戏后图片
        self.c2 = OnscreenImage(image='button1.png',
                                pos=(-0.8, 0, 0.5),
                                scale=(0.2, 0.1, 0.071))
        self.c2.hide()
        # 退出游戏显示的文字
        self.textObjectstart4 = OnscreenText(text='退出',
                                             pos=(-0.8, 0.48, 0),
                                             scale=0.05,
                                             fg=(255, 255, 255, 1))
        self.textObjectstart5 = OnscreenText(text='退出',
                                             pos=(-0.8, 0.48, 0),
                                             scale=0.055,
                                             fg=(255, 255, 255, 1))
        self.textObjectstart5.hide()
        self.textObjectstart6 = OnscreenText(text='退出',
                                             pos=(-0.8, 0.48, 0),
                                             scale=0.06,
                                             fg=(255, 255, 255, 1))
        self.textObjectstart6.hide()
        self.textObjectstart4.setFont(self.font)
        self.textObjectstart5.setFont(self.font)
        self.textObjectstart6.setFont(self.font)

        # ESC菜单
        self.caidanjiemian = OnscreenImage(image='caidan.jpg',
                                           pos=(0, 0, 0),
                                           scale=(0.5, 0.1, 0.41))
        self.caidanjiemian.hide()

        self.bangzhu1button = DirectButton(text=('', '', '', 'disabled'),
                                           image='button1.png',
                                           frameColor=(255, 255, 255, 0),
                                           image_scale=(2.2, 1, 0.7),
                                           pos=(0, 0, 0.23),
                                           scale=0.1,
                                           command=self.putdown1)
        self.bangzhu1button.hide()
        self.bangzhu1 = OnscreenText(text='游戏帮助',
                                     pos=(0, 0.21, 0),
                                     scale=0.05,
                                     fg=(255, 255, 255, 1))
        self.bangzhu1.setFont(self.font)
        self.bangzhu1.hide()

        self.bangzhu2button = DirectButton(text=('', '', '', 'disabled'),
                                           image='button1.png',
                                           frameColor=(255, 255, 255, 0),
                                           image_scale=(2.2, 1, 0.7),
                                           pos=(0, 0, 0.03),
                                           scale=0.1,
                                           command=self.putdown2)
        self.bangzhu2button.hide()
        self.bangzhu2 = OnscreenText(text='继续游戏',
                                     pos=(0, 0.01, 0),
                                     scale=0.05,
                                     fg=(255, 255, 255, 1))
        self.bangzhu2.setFont(self.font)
        self.bangzhu2.hide()

        self.bangzhu3button = DirectButton(text=('', '', '', 'disabled'),
                                           image='button1.png',
                                           frameColor=(255, 255, 255, 0),
                                           image_scale=(2.2, 1, 0.7),
                                           pos=(0, 0, -0.18),
                                           scale=0.1,
                                           command=self.putdown3)
        self.bangzhu3button.hide()
        self.bangzhu3 = OnscreenText(text='退出游戏',
                                     pos=(0, -0.2, 0),
                                     scale=0.05,
                                     fg=(255, 255, 255, 1))
        self.bangzhu3.setFont(self.font)
        self.bangzhu3.hide()

        self.bangzhujiemian = OnscreenImage(image='caidan.jpg',
                                            pos=(-0, 0, 0),
                                            scale=(1, 0.1, 0.81))
        self.bangzhujiemian.hide()
        self.bangzhuxinxi = OnscreenText(text='coooooooooooooooool',
                                         pos=(0, 0, 0),
                                         scale=0.1)
        self.bangzhuxinxi.hide()
        self.bangzhuxinxibutton = DirectButton(text=('', '', '', 'disabled'),
                                               image='button1.png',
                                               frameColor=(255, 255, 255, 0),
                                               image_scale=(2.2, 1, 0.7),
                                               pos=(0.55, 0, -0.55),
                                               scale=0.1,
                                               command=self.help1)
        self.bangzhuxinxibutton.hide()
        self.bangzhuxinxi1 = OnscreenText(text='返回',
                                          pos=(0.55, -0.56, 0),
                                          scale=0.05,
                                          fg=(255, 255, 255, 1))
        self.bangzhuxinxi1.setFont(self.font)
        self.bangzhuxinxi1.hide()

        taskMgr.add(self.example, 'MyTaskName')

# 按下ESC触发

    def caidan(self):
        if (self.menuon == 0):
            self.menuon = 1
            self.caidanjiemian.show()
            self.bangzhu1button.show()
            self.bangzhu2button.show()
            self.bangzhu3button.show()
            self.bangzhu1.show()
            self.bangzhu2.show()
            self.bangzhu3.show()
        else:
            self.menuon = 0
            self.caidanjiemian.hide()
            self.bangzhu1button.hide()
            self.bangzhu2button.hide()
            self.bangzhu3button.hide()
            self.bangzhu1.hide()
            self.bangzhu2.hide()
            self.bangzhu3.hide()
            self.bangzhujiemian.hide()
            self.bangzhuxinxi.hide()
            self.bangzhuxinxi1.hide()
            self.bangzhuxinxibutton.hide()

# 无限循环

    def example(self, task):
        mpos = base.mouseWatcherNode.getMouse()
        if mpos.getY() < 0.77 and mpos.getY() > 0.63 and mpos.getX(
        ) > -0.75 and mpos.getX() < -0.45:
            # print(mpos.getX())
            self.jiechu1 = 1
        elif mpos.getY() < 0.57 and mpos.getY() > 0.43 and mpos.getX(
        ) > -0.75 and mpos.getX() < -0.45:
            self.jiechu2 = 1
        else:
            self.jiechu1 = 0
            self.jiechu2 = 0
        if (self.jiechu1 == 1 and self.down == 0):
            self.zjmkaishi.show()
            #self.textObjectstart1.hide()
            self.textObjectstart2.show()
        elif (self.jiechu2 == 1 and self.down == 0):
            self.zjmkaishi2.show()
            #self.textObjectstart4.hide()
            self.textObjectstart5.show()
        else:
            self.zjmkaishi.hide()
            self.textObjectstart2.hide()
            self.textObjectstart1.show()
            self.zjmkaishi2.hide()
            self.textObjectstart5.hide()
            self.textObjectstart4.show()
        return task.cont
        # return task.done
# 按下开始游戏触发

    def putdown(self):
        print('start')
        self.down = 1
        self.a1.hide()
        self.zjmkaishi.hide()
        self.c1.show()
        self.textObjectstart1.hide()
        self.textObjectstart2.hide()
        self.textObjectstart3.show()
# 按下退出游戏触发

    def quit(self):
        print('exit')
        self.down = 1
        self.a2.hide()
        self.zjmkaishi2.hide()
        self.c2.show()
        self.textObjectstart4.hide()
        self.textObjectstart5.hide()
        self.textObjectstart6.show()
# 按下菜单界面按钮触发

    def putdown1(self):
        self.caidanjiemian.hide()
        self.bangzhu1button.hide()
        self.bangzhu2button.hide()
        self.bangzhu3button.hide()
        self.bangzhu1.hide()
        self.bangzhu2.hide()
        self.bangzhu3.hide()
        self.bangzhujiemian.show()
        self.bangzhuxinxi.show()
        self.bangzhuxinxibutton.show()
        self.bangzhuxinxi1.show()

    def putdown2(self):
        print(2)

    def putdown3(self):
        print(3)
        # self.b.show()


#按下帮助界面的返回触发

    def help1(self):
        self.caidanjiemian.show()
        self.bangzhu1button.show()
        self.bangzhu2button.show()
        self.bangzhu3button.show()
        self.bangzhu1.show()
        self.bangzhu2.show()
        self.bangzhu3.show()
        self.bangzhujiemian.hide()
        self.bangzhuxinxi.hide()
        self.bangzhuxinxibutton.hide()
Beispiel #6
0
 def __init__( self, parent ):
   self.parent = parent
   
   # line wrapper
   self.linewrap = textwrap.TextWrapper()
   self.linewrap.width = self.linelength
   
   # calculate window size
   left   = (self.h_pos) / self.scale
   right  = (self.h_pos + self.h_size) / self.scale
   bottom = (self.v_pos) / self.scale
   top    = (self.v_pos + self.v_size) /self.scale
   
   # panda3d interface
   self.consoleFrame = DirectFrame ( relief = DGG.GROOVE
                                   , frameColor = (200, 200, 200, 0.5)
                                   , scale=self.scale
                                   , frameSize = (0, self.h_size / self.scale, 0, self.v_size / self.scale) )
   
   # vardis 27-02-2009: Added special cull bin in order to render on top of everything
   CullBinManager.getGlobalPtr().addBin(PanoConstants.CONSOLE_CULL_BIN_NAME, CullBinManager.BTUnsorted, PanoConstants.CONSOLE_CULL_BIN_VAL)
   self.consoleFrame.setBin("fixed", PanoConstants.RENDER_ORDER_CONSOLE)
   
   self.windowEvent( base.win )
   
   # try to load the defined font
   fixedWidthFont = loader.loadFont(parent.game.getResources().getResourceFullPath(PanoConstants.RES_TYPE_FONTS, self.font))
   # if font is not valid use default font
   if not fixedWidthFont.isValid():
     if self.font is None:
       print "pandaInteractiveConsole.py :: could not load the defined font %s" % str(self.font)
     fixedWidthFont = DGG.getDefaultFont()
   
   # text entry line
   self.consoleEntry = DirectEntry ( self.consoleFrame
                                   , text        = ""
                                   , command     = self.onEnterPress
                                   , width       = self.h_size/self.scale - 2
                                   , pos         = (1, 0, 1.5)
                                   , initialText = ""
                                   , numLines    = 1
                                   , focus       = 1
                                   , entryFont   = fixedWidthFont)
   
   # output lines
   self.consoleOutputList = list()
   for i in xrange( self.numlines ):
     label = OnscreenText( parent = self.consoleFrame
                         , text = ""
                         , pos = (1, -i+3+self.numlines)
                         , align=TextNode.ALeft
                         , mayChange=1
                         , scale=1.0
                         , fg = self.defaultTextColor )
     label.setFont( fixedWidthFont )
     self.consoleOutputList.append( label )
   
   # list of the last commands of the user
   self.userCommandList = list()
   self.userCommandListLength = 100
   for i in xrange(self.userCommandListLength):
     self.userCommandList.append('')
   self.userCommandPos = 0
   
   # buffer for data
   self.textBuffer = list()
   self.textBufferLength = 1000
   for i in xrange(self.textBufferLength):
     self.textBuffer.append(['', DEFAULT_COLOR])
   self.textBufferPos = self.textBufferLength-self.numlines
   
   # toggle the window at least once to activate the events
   self.toggleConsole()
   self.toggleConsole()
   
   self.help()
Beispiel #7
0
    def __init__(self):
        ShowBase.__init__(self)

        base.disableMouse()

        self.makeAcog = loader.loadModel("phase_5/models/cogdominium/tt_m_ara_cbr_barrelRoom.bam")
        self.makeAcog.reparentTo(render)
        self.stomper1 = (self.makeAcog.find('**/stomper_GRP_01'))
        self.stomper2 = (self.makeAcog.find('**/stomper_GRP_02'))
        self.stomper3 = (self.makeAcog.find('**/stomper_GRP_03'))
        self.stomper4 = (self.makeAcog.find('**/stomper_GRP_04'))
        self.stomper5 = (self.makeAcog.find('**/stomper_GRP_05'))
        self.stomper6 = (self.makeAcog.find('**/stomper_GRP_06'))
        self.stomper7 = (self.makeAcog.find('**/stomper_GRP_07'))
        self.stomper8 = (self.makeAcog.find('**/stomper_GRP_08'))
        self.stomper9 = (self.makeAcog.find('**/stomper_GRP_09'))
        self.stomper10 = (self.makeAcog.find('**/stomper_GRP_10'))
        self.stomper11 = (self.makeAcog.find('**/stomper_GRP_11'))
        self.stomper12 = (self.makeAcog.find('**/stomper_GRP_12'))
        self.stomper3.setPos(0, 0, 18.00)
        self.stomper5.setPos(0, 0, 10.00)
        self.stomper4.setPos(0, 0, 22.00)
        self.stomper2.setPos(0, 0, 7.00)
        self.stomper7.setPos(0, 0, 0)
        self.stomper8.setPos(0, 0, 5.00)
        self.stomper9.setPos(0, 0, 13.00)
        self.stomper10.setPos(0, 0, 10.00)
        self.stomper11.setPos(0, 0, 22.00)
        self.stomper12.setPos(0, 0, 7.00)


        self.music = loader.loadMusic("phase_3/audio/bgm/cco_make_a_cog.wav")
        self.music.play()
        self.music.setLoop(True)

        self.elevator = loader.loadModel("phase_5/models/cogdominium/cogdominiumElevator.bam")
        self.elevator.reparentTo(self.render)
        self.elevator.setY(25.37)
        self.elevator.find('**/floor_light_buttons').removeNode()
        self.rightDoor = (self.elevator.find('**/right_door'))
        self.leftDoor = (self.elevator.find('**/left_door'))
        self.leftDoor.setX(3.50)
        self.rightDoor.setX(-3.50)

        self.skelCog = Actor("phase_5/models/char/cogC_robot-lose-mod.bam", {'neutral': 'phase_3.5/models/char/suitC-neutral.bam',
                                                                             'victory': 'phase_4/models/char/suitC-victory.bam',
                                                                             'walk': 'phase_3.5/models/char/suitC-walk.bam'})
        self.skelCog.reparentTo(self.render)
        self.skelCog.setPos(-16, 0, -4.76)
        self.skelCog.setH(180)




        self.Lawbot = Actor('phase_3.5/models/char/suitC-mod.bam', {'neutral': 'phase_3.5/models/char/suitC-neutral.bam',
                                                                    'victory': 'phase_4/models/char/suitC-victory.bam',
                                                                    'walk': 'phase_3.5/models/char/suitC-walk.bam'})
        self.Lawbot.reparentTo(render)
        self.Lawbot.loop('neutral')
        self.TorsoTex = loader.loadTexture('phase_3.5/maps/l_blazer.jpg')
        self.Lawbot.find('**/torso').setTexture(self.TorsoTex, 1)
        self.ArmTex = loader.loadTexture('phase_3.5/maps/l_sleeve.jpg')
        self.Lawbot.find('**/arms').setTexture(self.ArmTex, 1)
        self.LegTex = loader.loadTexture('phase_3.5/maps/l_leg.jpg')
        self.Lawbot.find('**/legs').setTexture(self.LegTex, 1)
        self.Head = loader.loadModel('phase_3.5/models/char/suitC-heads.bam').find('**/flunky')
        self.headTexture = loader.loadTexture("phase_3.5/maps/bottom-feeder.jpg")
        self.Head.reparentTo(self.Lawbot.find('**/joint_head'))
        self.Lawbot.findAllMatches('**/joint_head').setTexture(self.headTexture, 1)
        self.icon = loader.loadModel('phase_3/models/gui/cog_icons.bam')
        self.icon.reparentTo(render)
        self.icon.reparentTo(self.Lawbot.find('**/joint_attachMeter'))
        self.icon.find('**/MoneyIcon').removeNode()
        self.icon.find('**/cog').removeNode()
        self.icon.find('**/SalesIcon').removeNode()
        self.icon.find('**/CorpIcon').removeNode()
        self.icon.setH(180)
        self.icon.setScale(0.70)
        self.Lawbot.setH(180.00)
        self.Lawbot.hide()


        self.Cashbot = Actor('phase_3.5/models/char/suitC-mod.bam', {'neutral': 'phase_3.5/models/char/suitC-neutral.bam',
                                                                    'victory': 'phase_4/models/char/suitC-victory.bam',
                                                                    'walk': 'phase_3.5/models/char/suitC-walk.bam'})
        self.Cashbot.reparentTo(render)
        self.Cashbot.loop('neutral')
        self.TorsoTex = loader.loadTexture('phase_3.5/maps/m_blazer.jpg')
        self.Cashbot.find('**/torso').setTexture(self.TorsoTex, 1)
        self.ArmTex = loader.loadTexture('phase_3.5/maps/m_sleeve.jpg')
        self.Cashbot.find('**/arms').setTexture(self.ArmTex, 1)
        self.LegTex = loader.loadTexture('phase_3.5/maps/m_leg.jpg')
        self.Cashbot.find('**/legs').setTexture(self.LegTex, 1)
        self.Head = loader.loadModel('phase_3.5/models/char/suitC-heads.bam').find('**/coldcaller')
        self.Head.reparentTo(self.Cashbot.find('**/joint_head'))
        self.icon = loader.loadModel('phase_3/models/gui/cog_icons.bam')
        self.icon.reparentTo(render)
        self.icon.reparentTo(self.Cashbot.find('**/joint_attachMeter'))
        self.icon.find('**/SalesIcon').removeNode()
        self.icon.find('**/cog').removeNode()
        self.icon.find('**/LegalIcon').removeNode()
        self.icon.find('**/CorpIcon').removeNode()
        self.icon.setH(180)
        self.icon.setScale(0.70)
        self.Cashbot.setH(180.00)
        self.Cashbot.hide()

        self.Sellbot = Actor('phase_3.5/models/char/suitC-mod.bam', {'neutral': 'phase_3.5/models/char/suitC-neutral.bam',
                                                                    'victory': 'phase_4/models/char/suitC-victory.bam',
                                                                    'walk': 'phase_3.5/models/char/suitC-walk.bam'})
        self.Sellbot.reparentTo(render)
        self.Sellbot.loop('neutral')
        self.TorsoTex = loader.loadTexture('phase_3.5/maps/s_blazer.jpg')
        self.Sellbot.find('**/torso').setTexture(self.TorsoTex, 1)
        self.ArmTex = loader.loadTexture('phase_3.5/maps/s_sleeve.jpg')
        self.Sellbot.find('**/arms').setTexture(self.ArmTex, 1)
        self.LegTex = loader.loadTexture('phase_3.5/maps/s_leg.jpg')
        self.Sellbot.find('**/legs').setTexture(self.LegTex, 1)
        self.Head = loader.loadModel('phase_3.5/models/char/suitC-heads.bam').find('**/coldcaller')
        self.Head.reparentTo(self.Sellbot.find('**/joint_head'))
        self.Head.reparentTo(self.Sellbot.find('**/joint_head'))
        self.icon = loader.loadModel('phase_3/models/gui/cog_icons.bam')
        self.icon.reparentTo(render)
        self.icon.reparentTo(self.Sellbot.find('**/joint_attachMeter'))
        self.icon.find('**/MoneyIcon').removeNode()
        self.icon.find('**/cog').removeNode()
        self.icon.find('**/LegalIcon').removeNode()
        self.icon.find('**/CorpIcon').removeNode()
        self.icon.setH(180)
        self.icon.setScale(0.70)
        self.Sellbot.setH(180.00)
        self.Sellbot.hide()

        self.Bossbot = Actor('phase_3.5/models/char/suitC-mod.bam',
                             {'neutral': 'phase_3.5/models/char/suitC-neutral.bam',
                              'victory': 'phase_4/models/char/suitC-victory.bam',
                              'walk': 'phase_3.5/models/char/suitC-walk.bam'})
        self.Bossbot.reparentTo(render)
        self.Bossbot.loop('neutral')
        self.TorsoTex = loader.loadTexture('phase_3.5/maps/c_blazer.jpg')
        self.Bossbot.find('**/torso').setTexture(self.TorsoTex, 1)
        self.ArmTex = loader.loadTexture('phase_3.5/maps/c_sleeve.jpg')
        self.Bossbot.find('**/arms').setTexture(self.ArmTex, 1)
        self.LegTex = loader.loadTexture('phase_3.5/maps/c_leg.jpg')
        self.Bossbot.find('**/legs').setTexture(self.LegTex, 1)
        self.Head = loader.loadModel('phase_3.5/models/char/suitC-heads.bam')
        self.Head.find('**/coldcaller').hide()
        self.Head.find('**/gladhander').hide()
        self.Head.find('**/micromanager').hide()
        self.Head.find('**/moneybags').hide()
        self.Head.find('**/tightwad').hide()
        self.Head.reparentTo(self.Bossbot.find('**/joint_head'))
        self.icon = loader.loadModel('phase_3/models/gui/cog_icons.bam')
        self.icon.reparentTo(render)
        self.icon.reparentTo(self.Bossbot.find('**/joint_attachMeter'))
        self.icon.find('**/MoneyIcon').removeNode()
        self.icon.find('**/cog').removeNode()
        self.icon.find('**/LegalIcon').removeNode()
        self.icon.find('**/SalesIcon').removeNode()
        self.icon.setH(180)
        self.icon.setScale(0.70)
        self.Bossbot.setH(180.00)
        self.Bossbot.hide()


        self.Sourcebot = Actor('phase_3.5/models/char/suitC-mod.bam',
                             {'neutral': 'phase_3.5/models/char/suitC-neutral.bam',
                              'victory': 'phase_4/models/char/suitC-victory.bam',
                              'walk': 'phase_3.5/models/char/suitC-walk.bam'})

        self.Sourcebot.reparentTo(render)
        self.Sourcebot.loop('neutral')
        self.TorsoTex = loader.loadTexture('phase_3.5/maps/t_blazer.jpg')
        self.Sourcebot.find('**/torso').setTexture(self.TorsoTex, 1)
        self.ArmTex = loader.loadTexture('phase_3.5/maps/t_sleeve.jpg')
        self.Sourcebot.find('**/arms').setTexture(self.ArmTex, 1)
        self.LegTex = loader.loadTexture('phase_3.5/maps/t_leg.jpg')
        self.Sourcebot.find('**/legs').setTexture(self.LegTex, 1)
        self.Head = loader.loadModel('phase_3.5/models/char/FlairDirector.egg')
        self.headTexture = loader.loadTexture("phase_3.5/maps/flair-director.jpg")
        self.Head.reparentTo(self.Sourcebot.find('**/joint_head'))
        self.Sourcebot.findAllMatches('**/joint_head').setTexture(self.headTexture, 1)
        self.Sourcebot.setH(180.00)
        self.Sourcebot.hide()

        self.Techbot = Actor('phase_3.5/models/char/suitC-mod.bam',
                               {'neutral': 'phase_3.5/models/char/suitC-neutral.bam',
                                'victory': 'phase_4/models/char/suitC-victory.bam',
                                'walk': 'phase_3.5/models/char/suitC-walk.bam'})

        self.Techbot.reparentTo(render)
        self.Techbot.loop('neutral')
        self.TorsoTex = loader.loadTexture('phase_3.5/maps/t_blazer.jpg')
        self.Techbot.find('**/torso').setTexture(self.TorsoTex, 1)
        self.ArmTex = loader.loadTexture('phase_3.5/maps/t_sleeve.jpg')
        self.Techbot.find('**/arms').setTexture(self.ArmTex, 1)
        self.LegTex = loader.loadTexture('phase_3.5/maps/t_leg.jpg')
        self.Techbot.find('**/legs').setTexture(self.LegTex, 1)
        self.Head = loader.loadModel('phase_3.5/models/char/PayrollConvertor.egg')
        self.headTexture = loader.loadTexture("phase_3.5/maps/PayrollConvertor.png")
        self.Head.reparentTo(self.Techbot.find('**/joint_head'))
        self.Head.setPos(0, 0, -0.15)
        self.Head.setScale(0.93)
        self.Techbot.findAllMatches('**/joint_head').setTexture(self.headTexture, 1)
        self.Techbot.setH(180.00)
        self.Techbot.hide()

        self.Pilotbots = Actor('phase_3.5/models/char/suitC-mod.bam',
                             {'neutral': 'phase_3.5/models/char/suitC-neutral.bam',
                              'victory': 'phase_4/models/char/suitC-victory.bam',
                              'walk': 'phase_3.5/models/char/suitC-walk.bam'})

        self.Pilotbots.reparentTo(render)
        self.Pilotbots.loop('neutral')
        self.TorsoTex = loader.loadTexture('phase_3.5/maps/t_blazer.jpg')
        self.Pilotbots.find('**/torso').setTexture(self.TorsoTex, 1)
        self.ArmTex = loader.loadTexture('phase_3.5/maps/t_sleeve.jpg')
        self.Pilotbots.find('**/arms').setTexture(self.ArmTex, 1)
        self.LegTex = loader.loadTexture('phase_3.5/maps/t_leg.jpg')
        self.Pilotbots.find('**/legs').setTexture(self.LegTex, 1)
        self.Head = loader.loadModel('phase_3.5/models/char/ConstructionBot.egg')
        self.headTexture = loader.loadTexture("phase_3.5/maps/Buildbot.png")
        self.Head.reparentTo(self.Pilotbots.find('**/joint_head'))
        self.Head.setPos(0, 0, -0.15)
        self.icon.setH(180)
        self.Pilotbots.findAllMatches('**/joint_head').setTexture(self.headTexture, 1)
        self.Pilotbots.setH(180.00)
        self.Pilotbots.hide()



        #-----Sequences------#

        Walk1 = self.stomper1.posInterval(9.50, Point3(0, 0, 18.00))
        Walk2 = self.stomper1.posInterval(9.50, Point3(0, 0, 0))
        self.stomperPound1 = Sequence(Walk1, Walk2)
        self.stomperPound1.loop()

        Walk1 = self.stomper6.posInterval(9.50, Point3(0, 0, 18.00))
        Walk2 = self.stomper6.posInterval(9.50, Point3(0, 0, 0))
        self.stomperPound2 = Sequence(Walk1, Walk2)
        self.stomperPound2.loop()



        Walk1 = self.stomper3.posInterval(9.50, Point3(0, 0, 0))
        Walk2 = self.stomper3.posInterval(9.50, Point3(0, 0, 18.00))
        self.stomperPound3 = Sequence(Walk1, Walk2)
        self.stomperPound3.loop()

        Walk1 = self.stomper5.posInterval(5.50, Point3(0, 0, 0))
        Walk2 = self.stomper5.posInterval(5.50, Point3(0, 0, 10.00))
        self.stomperPound4 = Sequence(Walk1, Walk2)
        self.stomperPound4.loop()

        Walk1 = self.stomper4.posInterval(5.50, Point3(0, 0, 0))
        Walk2 = self.stomper4.posInterval(5.50, Point3(0, 0, 22.00))
        self.stomperPound5 = Sequence(Walk1, Walk2)
        self.stomperPound5.loop()

        Walk1 = self.stomper2.posInterval(3.50, Point3(0, 0, 0))
        Walk2 = self.stomper2.posInterval(3.50, Point3(0, 0, 7.00))
        self.stomperPound6 = Sequence(Walk1, Walk2)
        self.stomperPound6.loop()

        Walk1 = self.stomper7.posInterval(9.50, Point3(0, 0, 18.00))
        Walk2 = self.stomper7.posInterval(9.50, Point3(0, 0, 0))
        self.stomperPound7 = Sequence(Walk1, Walk2)
        self.stomperPound7.loop()

        Walk1 = self.stomper8.posInterval(5.50, Point3(0, 0, 5.00))
        Walk2 = self.stomper8.posInterval(9.50, Point3(0, 0, 0))
        self.stomperPound8 = Sequence(Walk1, Walk2)
        self.stomperPound8.loop()

        Walk1 = self.stomper9.posInterval(6.50, Point3(0, 0, 0))
        Walk2 = self.stomper9.posInterval(6.50, Point3(0, 0, 13.00))
        self.stomperPound9 = Sequence(Walk1, Walk2)
        self.stomperPound9.loop()

        Walk1 = self.stomper10.posInterval(5.50, Point3(0, 0, 0))
        Walk2 = self.stomper10.posInterval(5.50, Point3(0, 0, 10.00))
        self.stomperPound10 = Sequence(Walk1, Walk2)
        self.stomperPound10.loop()

        Walk1 = self.stomper11.posInterval(5.50, Point3(0, 0, 0))
        Walk2 = self.stomper11.posInterval(5.50, Point3(0, 0, 22.00))
        self.stomperPound11 = Sequence(Walk1, Walk2)
        self.stomperPound11.loop()

        Walk1 = self.stomper12.posInterval(3.50, Point3(0, 0, 0))
        Walk2 = self.stomper12.posInterval(3.50, Point3(0, 0, 7.00))
        self.stomperPound12 = Sequence(Walk1, Walk2)
        self.stomperPound12.loop()



        Walk1 = self.camera.posInterval(2.50, Point3(-20.98, -14.61, 9.74))
        Spin1 = self.camera.hprInterval(1.00, Vec3(321.34, 348.11, 0))
        cogSpin = self.Sellbot.hprInterval(1.50, Vec3(0, 0, 0))
        Walk2 = self.camera.posInterval(5.0, Point3(-20.98, -14.61, 9.74))
        Walk3 = self.camera.posInterval(1.50, Point3(-20.98, 1.40, 7.97))
        Spin2 = self.camera.hprInterval(1.00, Vec3(281.31, 348.11, 0))
        Walk4 = self.camera.posInterval(8.50, Point3(-20.98, 1.40, 7.97))
        Walk5 = self.camera.posInterval(2.50, Point3(0, -19.61, 2.61))
        Spin3 = self.camera.hprInterval(1.00, Vec3(0, 0, 0))
        self.cameraMove = Sequence(Walk1, Spin1, cogSpin, Walk2, Walk3, Spin2, Walk4, Walk5, Spin3)

        Walk1 = self.camera.posInterval(1.50, Point3(0, -77.48, 3.42))
        Spin1 = self.camera.hprInterval(1.00, Vec3(0, 0, 0))
        Walk2 = self.camera.posInterval(2.50, Point3(0, -77.48, 3.42))
        Walk3 = self.camera.posInterval(3.00, Point3(0, -22.48, 3.42))
        Walk4 = self.camera.posInterval(2.00, Point3(0, -22.48, 3.42))
        skelMove1 = self.skelCog.posInterval(0.50, Point3(-16, -0, 0))
        skelMove2 = self.skelCog.posInterval(2.00, Point3(0, -0, 0))
        self.cameraStart = Sequence(Walk1, Spin1, Walk2, Walk3, Walk4, skelMove1, skelMove2)

        Walk1 = self.camera.posInterval(15.50, Point3(6.31, -45.31, 9.27))
        Spin1 = self.camera.hprInterval(0.00, Vec3(337.52, 0, 0))
        Walk2 = self.camera.posInterval(0.00, Point3(6.08, -100.53, 9.27))
        Walk3 = self.camera.posInterval(12.00, Point3(14.07, -77.33, 9.27))
        Walk4 = self.camera.posInterval(0.00, Point3(18.93, -82.36, 25.51))
        Spin2 = self.camera.hprInterval(0.00, Vec3(30.26, 347.91, 0))
        Walk5 = self.camera.posInterval(15.00, Point3(0.44, -51.38, 21.411))
        Spin3 = self.camera.hprInterval(0.00, Vec3(337.52, 0, 0))
        self.cameraIntro = Sequence(Walk1, Spin1, Walk2, Walk3, Walk4, Spin2, Walk5, Spin3)
        self.cameraIntro.loop()



        #----camera---#

        self.camera.setPos(6.31, -82.36, 9.27)
        self.camera.setHpr(35.71, 0, 0)

        #--------Start-up-Menu--------#

        #-----buttons-------#

        #-----texts-------#
        self.logoLeft = OnscreenImage(image='phase_3/maps/cogcitycodeaffix-logo-hor-left[OLD].png', pos=(-0.46, 0, 0.2), scale=(0.7))
        self.logoLeft.setTransparency(TransparencyAttrib.MAlpha)

        self.logoRight = OnscreenImage(image='phase_3/maps/cogcitycodeaffix-logo-hor-right[OLD].png', pos=(0.56, 0, 0.18), scale=(0.7))
        self.logoRight.setTransparency(TransparencyAttrib.MAlpha)

        font = self.loader.loadFont("phase_3/models/fonts/vtRemingtonPortable.ttf")


        text = TextNode("play")
        text.setText("Press F1 to play")
        text.setFont(font)

        self.textNodePath = aspect2d.attachNewNode(text)
        self.textNodePath.setScale(0.09)
        self.textNodePath.setPos(-0.5, 0, -0.7)

        #-----optionText-----------#

        fps = "Show FPS: f2"
        self.textObject1 = OnscreenText(text=fps, pos=(-1.4, -0.97),
        scale=0.09, fg=(1, 0.5, 0.5, 1), align=TextNode.ACenter, mayChange=1)
        self.textObject1.setFont(font)

        fullscreen = "Fullscreen: f2"
        self.textObject2 = OnscreenText(text=fullscreen, pos=(-1.34, -0.88),
                                  scale=0.09, fg=(1, 0.5, 0.5, 1), align=TextNode.ACenter, mayChange=1)
        self.textObject2.setFont(font)

        audio = "Audio: f4"
        self.textObject3 = OnscreenText(text=audio, pos=(-1.48, -0.78),
                                   scale=0.09, fg=(1, 0.5, 0.5, 1), align=TextNode.ACenter, mayChange=1)
        self.textObject3.setFont(font)


        #------doneButton--------#

        font = self.loader.loadFont("phase_3/models/fonts/vtRemingtonPortable.ttf")

        bk_text = ""
        textObject = OnscreenText(text=bk_text, pos=(0.00, 0.73),
                                  scale=0.16, fg=(1, 0.5, 0.5, 1), align=TextNode.ACenter, mayChange=1)
        textObject.setFont(font)
        textObject.setColor(0.3, 0.3, 0.35, 1.0)

        def setText(status):
            if (status):
                bk_text = "Do you want to continue?"
            else:
                bk_text = ""
            textObject.setText(bk_text)


        self.DoneButton = DirectCheckButton(text="Continue", scale=0.12, pos=(0, 0, -0.80), command=setText)
        self.DoneButton.hide()

        #----------key/click-events-------#

        self.acceptOnce("f1-up", self.play)
        self.accept("f2-up", self.frameRate)
Beispiel #8
0
class GuiUnitInfo:
    def __init__(self, offset, parent, unit_type, default_hp, hp, default_ap, ap):
            
        self.offset = offset
        self.frame = DirectFrame(   relief = DGG.FLAT
                                  , scale = 1
                                  , frameSize = (-0.5, 0.5, 0, -0.5)
                                  , parent = parent )
        self.frame.setBillboardPointEye()
        self.frame.setLightOff()
        self.frame.setBin("fixed", 40)
        self.frame.setDepthTest(False)
        self.frame.setDepthWrite(False)
        
        fixedWidthFont = loader.loadFont(GUI_FONT)#@UndefinedVariable        
        #fixedWidthFont.setPixelsPerUnit(60)
        #fixedWidthFont.setRenderMode(fontt.RMSolid)
        if not fixedWidthFont.isValid():
            print "pandaInteractiveConsole.py :: could not load the defined font %s" % str(self.font)
            fixedWidthFont = DGG.getDefaultFont()
        
        self.label = OnscreenText( parent = self.frame
                              , text = ""
                              , pos = (offset.getX(),offset.getZ()+0.1)
                              , align=TextNode.ACenter
                              , mayChange=True
                              , scale=0.1
                              , fg = (1,0,0,1)
                              #, shadow = (0, 0, 0, 1)
                              #, frame = (200,0,0,1) 
                              )
        self.label.setFont( fixedWidthFont )
        #self.label.setLightOff()

        self.all_icons = {}
        self.visible_icons = {}
        self.addIcon("overwatch")
        self.addIcon("set_up")
        
        self.ap_bar = DirectWaitBar(parent = self.frame
                                  , text = ""
                                  , range = default_ap
                                  , value = ap
                                  , pos = (offset.getX()+0.08,0,offset.getZ()-0.27)
                                  , barColor = (0,0,1,1)
                                  , frameColor = (0,0,0.5,0.2)
                                  , scale = (0.3,0.5,0.3))
        
        self.hp_bar = DirectWaitBar(parent = self.frame
                                  , text = ""
                                  , range = default_hp
                                  , value = hp
                                  , pos = (offset.getX()+0.08,0,offset.getZ()-0.2)
                                  , barColor = (0,1,0,1)
                                  , frameColor = (1,0,0,0.9)
                                  , scale = (0.3,0.5,0.3))
        
        self.insignia = OnscreenImage(parent = self.frame
                                            ,image = "unit_" + unit_type + "_big_transparent_32.png"
                                            #,pos = (offset.getX(),0,offset.getZ()+0.14)
                                            , pos = (offset.getX() - 0.31,0,offset.getZ()-0.23)
                                            ,scale = 0.09)
        self.insignia.setTransparency(TransparencyAttrib.MAlpha)

    def addIcon(self, name):
        self.all_icons[name] = OnscreenImage(parent = self.frame
                                            ,image = name + "_icon.png"
                                           #,pos = offset + (0,0,-0.1)
                                            ,scale = 0.08)
        
        self.all_icons[name].setTransparency(TransparencyAttrib.MAlpha)
        self.all_icons[name].hide()
        
    def write(self, text):
        text = ""
        self.label.setText(text)
        
    def redraw(self):
        return

    def remove(self):
        self.frame.remove()
        
    def reparentTo(self, parent):
        self.frame.reparentTo(parent)
        
    def hide(self):
        self.label.hide()
        
    def show(self):
        self.label.show()
    
    def refreshBars(self, hp, ap):
        self.ap_bar['value'] = ap
        self.hp_bar['value'] = hp
        self.ap_bar.setValue()
        self.hp_bar.setValue()
        
    def refreshIcons(self):
        count = len(self.visible_icons)
        start_pos =  (1 - count) * 0.25 / 2
        for icon in self.all_icons:
            if icon in self.visible_icons:
                self.visible_icons[icon].setPos(self.offset + (start_pos, 0, -0.08))
                self.visible_icons[icon].show()
                start_pos += 0.21
            else:
                self.all_icons[icon].hide()
            
    def hideOverwatch(self):
        if "overwatch" in self.visible_icons:
            self.visible_icons.pop("overwatch")
        self.refreshIcons()

    def showOverwatch(self):
        self.visible_icons["overwatch"] = self.all_icons["overwatch"]
        self.refreshIcons()
    
    def hideSetUp(self):
        if "set_up" in self.visible_icons:
            self.visible_icons.pop("set_up")
        self.refreshIcons()

    def showSetUp(self):
        self.visible_icons["set_up"] = self.all_icons["set_up"]
        self.refreshIcons()