示例#1
0
    def _makeKeyboards(self, finishedCB, parent):
        
        self._namesToEnter = len(self._players)
        playerScores = []
        for player in self._players:
            playerScores.append(player.score)
        
        for player in self._players:
 
            
            heading = avg.WordsNode( color="FFFFFF",
                                      fontsize=25,
                                      sensitive=False,
                                      angle=player.angle,
                                      alignment="center",
                                     )
            
            hsen = HighscoreEntryNode(self._highscore, player.score, playerScores, finishedCB, parent=parent, size=(util.WINDOW_SIZE[0]//3,util.WINDOW_SIZE[0]//9))
            hsen.angle = player.angle
            
            hsen.appendChild(heading)
 
            if player in self.remainaingPlayers:
                designation = "WINNER"
            else:
                designation = "LOSER"
            heading.text=  "{}<br/>{} Points".format(designation, player.score)
           
            util.centerNodeOnPosition(hsen, player.pos)
            util.centerNodeOnPosition(heading, util.vectorAdd((0,0), (hsen.size[0]/2, -heading.getMediaSize()[1])))
示例#2
0
 def baseTimeout():
     base.hide()
     circle = self._theme.JoinButton(parent=self)
     util.centerNodeOnPosition(circle, base.position)
     circle.angle = base.angle + math.pi/4
     circle.setEventHandler(avg.CURSORDOWN, avg.TOUCH, lambda event : restoreBase())
     for structure in self.structures:
         structure.framesToGrowth += self._growIncrementPerPlayer
    def _makeInfoElements(self):
        minSize = min(self._parent.size)*0.85
        
        infoButtonSize = self.size[0]/3,self.size[1]/3
        infoButton = self._infoManager.getInfoButton(parent=self._root, size=infoButtonSize)
         
        util.centerNodeOnPosition(infoButton, (0,0))
        
        infoBox = self._infoManager.getInfoBox(parent=self._root, size =(minSize/3, minSize/4) )
        util.centerNodeOnPosition(infoBox, (0,0))

        return infoButton, infoBox
 def _placeInfoElements(self, button, box):
     button.angle = math.pi/4
     box.angle = math.pi/4
     
     angle =   -math.pi/4
     baseDisplacement = math.sqrt(2*(self.size[0]**2)) /2.0
     infoButtonElementAdjustemnt = util.getVectotInDirection(angle ,
                                                         -baseDisplacement + math.sqrt(2*(button.size[1]**2))/2)
     infoBoxElementAdjustemnt = util.getVectotInDirection(angle,
                                                         baseDisplacement + box.size[1]/2)
  
     util.centerNodeOnPosition(button, infoButtonElementAdjustemnt)
     util.centerNodeOnPosition(box, infoBoxElementAdjustemnt)
示例#5
0
  def _scorePoints(self, points):
      
      if points == 0 or self.owner.score is None:
          return
      
      animTime = 1500
      maxTextSize = min((75 + points,500))
      
      scoreNode = avg.WordsNode(text=str(points),
                        fontsize=maxTextSize,
                        parent=self._root.getParent(),
                        alignment="center",
                        color=self.owner.color)
     
      angle = util.getDirOfVector(util.vectorSub(self.owner.pos, self.position,))
      scoreNode.angle =angle
 
      util.centerNodeOnPosition(scoreNode,  self.position)
 
      anim = avg.LinearAnim(scoreNode, "pos",
                            animTime,
                            scoreNode.pos, self.owner.pos,
                            False, None, lambda:scoreNode.unlink(True))
      player = self.owner
      def addPoints():
          player.score+=points
          
      textShrinkAnim = avg.LinearAnim(scoreNode, "fontsize",
                            int(animTime*0.6),
                            maxTextSize, maxTextSize*0.2,
                            False, None, addPoints )
      
      textGrowAnim = avg.LinearAnim(scoreNode, "fontsize",
                            int(animTime*0.4),
                            maxTextSize*0.1, maxTextSize,
                            False, None, textShrinkAnim.start)
      textGrowAnim.start()
      anim.start()
    def _placeInfoElements(self, button, box):
        angle =  math.pi/2
        baseDisplacement = math.sqrt(2*(self.size[0]**2)) /2.0
        infoBoxElementAdjustemnt = util.getVectotInDirection(angle,
                                                            -baseDisplacement - box.size[1]/2)
     
        buttonPos =  (-self.size[0]*0.23, self.size[1]*0.27)
        button.size = util.vectorMult(self.size, 0.20) 
        util.centerNodeOnPosition(button, buttonPos)
        util.centerNodeOnPosition(box, infoBoxElementAdjustemnt)

        util.centerNodeOnPosition(box, infoBoxElementAdjustemnt)
    def __init__(self, crystalManager=None, framesToGrowth=None, startCrystals=20, *args, **kwargs):
        GameElementBase.__init__(self, *args, **kwargs)

        if self.owner is not None:
            self.owner.addStructure(self)

        self._graph = nx.Graph()
        self._elementMapping = {}

        self._fixElements = WeakSet()

        if __debug__:
            print "FRAMESTO GROWTH", framesToGrowth
        self.framesToGrowth = framesToGrowth
        self.growTimer = 0

        self._overDriveCounter = 0
        self._overdrive = False

        self._veil = None

        self._growLock = False
        self._depletedCallback = None
        self._gameOverCallback = None

        self.crystalManager = crystalManager
        if crystalManager is None:
            logging.warn("Structure {!s} has no valid CrystalManager".format(self))
        else:
            self.crystalManager.registerStructure(self)

        self._shadowWidth = util.CRYSTAL_SIZE * StructureElement.shapeOverflowFactor ** 2
        if self.owner is None:
            self._shadowColor = "000000"
        else:
            self._shadowColor = self.owner.color

        player = avg.Player.get()
        self._canvas = player.createCanvas(
            id=str(id(self)),
            size=(max(util.WINDOW_SIZE), max(util.WINDOW_SIZE)),
            handleevents=True,
            multisamplesamples=4,
        )

        self._blackCanvas = player.createCanvas(
            id=str(id(self)) + "Black",
            size=(max(util.WINDOW_SIZE), max(util.WINDOW_SIZE)),
            handleevents=True,
            multisamplesamples=4,
        )

        self._canvasRoot = self._canvas.getRootNode()

        self._blackBackground = self._blackCanvas.getRootNode()
        self._shadowImage = avg.ImageNode(
            href="canvas:{}Black".format(id(self)),
            parent=self._root,
            size=(max(util.WINDOW_SIZE), max(util.WINDOW_SIZE)),
            opacity=0.4,
        )
        util.centerNodeOnPosition(self._shadowImage, (0, 0))
        self._graphVisRoot = avg.DivNode(parent=self._canvasRoot)

        self._image = avg.ImageNode(
            href="canvas:{}".format(id(self)), parent=self._root, size=(max(util.WINDOW_SIZE), max(util.WINDOW_SIZE))
        )
        util.centerNodeOnPosition(self._image, (0, 0))
        self._edgeNodes = dict()
        self._shadowNodes = dict()

        self._initStructureCore()

        assert self.checkSanity()

        while len(self._graph) < startCrystals:
            self.growSimple()

        self.rotationEnabled = True
        self._tickTimer = None
        self._startTickTimer()
示例#8
0
 def size(self, value):
     self.image.size = value
     util.centerNodeOnPosition(self.image, (0, 0))
 def _alignScore(self, scoreNode ):
     self._scorePosition = (-self.size[0]*0.18+self.size[0]*0.01,
                            -self.size[1]*0.18-self.size[1]*0.01)
     util.centerNodeOnPosition(scoreNode, self._scorePosition)
     scoreNode.angle = math.pi/4
示例#10
0
 def _alignScore(self, scoreNode):
     scorePos = (self.size[0]*0, -self.size[1]*0.015)
     util.centerNodeOnPosition(scoreNode, scorePos)