コード例 #1
0
ファイル: 9ntd.py プロジェクト: offmeplz/9game
 def _draw_tower_sketch(self):
     tower_cls = self._tower_for_build_class
     if tower_cls is not None:
         mpos = self._to_field_coord(pygame.mouse.get_pos())
         if mpos is None:
             return
         g_pos = util.screen2fgame(mpos)
         g_topleft = util.placeintrect(g_pos, (tower_cls.size, ) * 2)
         s_topleft = util.game2tlscreen(g_topleft)
         self._tower_sketch_rect = tower_cls.draw_oksketch_on(
                 self._field_surface, s_topleft)
コード例 #2
0
ファイル: 9ntd.py プロジェクト: offmeplz/9game
    def sell_tower(self, tower):
        sizes = (tower.size, tower.size)
        topleft = util.placeintrect(tower.g_pos, sizes)
        cells = util.iterpoints(topleft, sizes)
        self.field.clearon(*cells)

        money = int(self.sell_factor * tower.cost)
        message = '+%d' % money
        self.money += money
        self.messages.add(Message(message, 1, tower.g_pos, GOLD_COLOR))

        tower.kill()
コード例 #3
0
ファイル: 9ntd.py プロジェクト: offmeplz/9game
 def build_tower(self, tower_cls, pos):
     if tower_cls.cost > self.get_money():
         raise BuildError, "Not enough money"
     sizes = (tower_cls.size, tower_cls.size)
     topleft = util.placeintrect(pos, sizes)
     canbuild = all(
             self.field.canbuildon(p)
             for p in util.iterpoints(topleft, sizes))
     
     if canbuild:
         self.add_tower(topleft, tower_cls)
     else:
         raise BuildError, "Can't build here"