Esempio n. 1
0
    def OnMenu(self, evt):
        """Handle the context menu events for performing
        filesystem operations

        """
        e_id = evt.GetId()
        path = self.GetItemPath(self._treeId)
        paths = self.GetPaths()
        ok = (False, '')
        if e_id == ID_EDIT:
            self.OpenFiles(paths)
        elif e_id == ID_OPEN:
            worker = OpenerThread(paths)
            worker.start()
        elif e_id == ID_REVEAL:
            worker = OpenerThread([os.path.dirname(fname) for fname in paths])
            worker.start()
        elif e_id == ID_SEARCH_DIR:
            paths = self.GetPaths()
            if len(paths):
                path = paths[0]  # Go off of the first selected item
                if not os.path.isdir(path):
                    path = os.path.dirname(path)
                mdata = dict(mainw=self._mw, lookin=path)
                ed_msg.PostMessage(ed_msg.EDMSG_FIND_SHOW_DLG, mdata)
        elif e_id == ID_GETINFO:
            last = None
            for fname in paths:
                info = ed_mdlg.EdFileInfoDlg(self.GetTopLevelParent(), fname)
                if last is None:
                    info.CenterOnParent()
                else:
                    lpos = last.GetPosition()
                    info.SetPosition((lpos[0] + 14, lpos[1] + 14))
                info.Show()
                last = info
        elif e_id == ID_RENAME:
            self._tree.EditLabel(self._treeId)
        elif e_id == ID_NEW_FOLDER:
            ok = ebmlib.MakeNewFolder(path, _("Untitled_Folder"))
        elif e_id == ID_NEW_FILE:
            ok = ebmlib.MakeNewFile(path, _("Untitled_File") + ".txt")
        elif e_id == ID_DUPLICATE:
            for fname in paths:
                ok = DuplicatePath(fname)
        elif e_id == ID_ARCHIVE:
            ok = MakeArchive(path)
        elif e_id == ID_DELETE:
            Trash.moveToTrash(paths)
            ok = (True, os.path.dirname(path))
        else:
            evt.Skip()
            return

        if e_id in (ID_NEW_FOLDER, ID_NEW_FILE, ID_DUPLICATE, ID_ARCHIVE,
                    ID_DELETE):
            if ok[0]:
                self.ReCreateTree()
                self._SCommand(self.SetPath, ok[1])
Esempio n. 2
0
    def OnMenu(self, evt):
        """Handle the context menu events for performing
        filesystem operations

        """
        e_id = evt.GetId()
        path = self.GetItemPath(self._treeId)
        paths = self.GetPaths()
        ok = (False, '')
        if e_id == ID_EDIT:
            self.OpenFiles(paths)
        elif e_id == ID_OPEN:
            worker = OpenerThread(paths)
            worker.start()
        elif e_id == ID_REVEAL:
            worker = OpenerThread([os.path.dirname(fname) for fname in paths])
            worker.start()
        elif e_id == ID_SEARCH_DIR:
            paths = self.GetPaths()
            if len(paths):
                path = paths[0] # Go off of the first selected item
                if not os.path.isdir(path):
                    path = os.path.dirname(path)
                mdata = dict(mainw=self._mw, lookin=path)
                ed_msg.PostMessage(ed_msg.EDMSG_FIND_SHOW_DLG, mdata) 
        elif e_id == ID_GETINFO:
            last = None
            for fname in paths:
                info = ed_mdlg.EdFileInfoDlg(self.GetTopLevelParent(), fname)
                if last is None:
                    info.CenterOnParent()
                else:
                    lpos = last.GetPosition()
                    info.SetPosition((lpos[0] + 14, lpos[1] + 14))
                info.Show()
                last = info
        elif e_id == ID_RENAME:
            self._tree.EditLabel(self._treeId)
        elif e_id == ID_NEW_FOLDER:
            ok = ebmlib.MakeNewFolder(path, _("Untitled_Folder"))
        elif e_id == ID_NEW_FILE:
            ok = ebmlib.MakeNewFile(path, _("Untitled_File") + ".txt")
        elif e_id == ID_DUPLICATE:
            for fname in paths:
                ok = DuplicatePath(fname)
        elif e_id == ID_ARCHIVE:
            ok = MakeArchive(path)
        elif e_id == ID_DELETE:
            Trash.moveToTrash(paths)
            ok = (True, os.path.dirname(path))
        else:
            evt.Skip()
            return

        if e_id in (ID_NEW_FOLDER, ID_NEW_FILE, ID_DUPLICATE, ID_ARCHIVE,
                    ID_DELETE):
            if ok[0]:
                self.ReCreateTree()
                self._SCommand(self.SetPath, ok[1])
Esempio n. 3
0
    def OnMenu(self, evt):
        """Handle the context menu events for performing
        filesystem operations

        """
        e_id = evt.GetId()
        path = self.GetItemPath(self._treeId)
        paths = self.GetPaths()
        ok = (False, '')
        if e_id == ID_EDIT:
            self.OpenFiles(paths)
        elif e_id == ID_OPEN:
            worker = OpenerThread(paths)
            worker.start()
        elif e_id == ID_REVEAL:
            worker = OpenerThread([os.path.dirname(fname) for fname in paths])
            worker.start()
        elif e_id == ID_GETINFO:
            last = None
            for fname in paths:
                info = FileInfo.FileInfoDlg(self.GetTopLevelParent(), fname)
                if last is None:
                    info.CenterOnParent()
                else:
                    lpos = last.GetPosition()
                    info.SetPosition((lpos[0] + 14, lpos[1] + 14))
                info.Show()
                last = info
        elif e_id == ID_RENAME:
            self._tree.EditLabel(self._treeId)
        elif e_id == ID_NEW_FOLDER:
            ok = util.MakeNewFolder(path, _("Untitled_Folder"))
        elif e_id == ID_NEW_FILE:
            ok = util.MakeNewFile(path, _("Untitled_File") + ".txt")
        elif e_id == ID_DUPLICATE:
            for fname in paths:
                ok = DuplicatePath(fname)
        elif e_id == ID_ARCHIVE:
            ok = MakeArchive(path)
        elif e_id == ID_DELETE:
            Trash.moveToTrash(paths)
            ok = (True, os.path.dirname(path))
        else:
            evt.Skip()
            return

        if e_id in (ID_NEW_FOLDER, ID_NEW_FILE, ID_DUPLICATE, ID_ARCHIVE,
                    ID_DELETE):
            if ok[0]:
                self.ReCreateTree()
                self._SCommand(self.SetPath, ok[1])
Esempio n. 4
0
 def checkChanges(self):
     statusChange = self.hero.statusUpdate()
     if statusChange == 1:
         self.enemiesPresent -= 1
         cultist = Trash.Cultist(self.screen, self.building)
         self.enemiesToSpawn.append(cultist)
         skeleton = Trash.Cultist(self.screen, self.building)
         self.enemiesToSpawn.append(skeleton)
         self.enemySpawnCounter = 0
     elif statusChange == 2:
         self.equipmentPresent -= 1
         self.equipmentSpawnCounter = 0
     elif statusChange == 3:
         self.gameOver = True
         self.victorious = True
Esempio n. 5
0
    def buildMap(self):
        mapData = LevelHandler.loadMapFile(self.level)
        mapList = LevelHandler.parseMap(mapData)
        tileData = LevelHandler.parseData(mapData)
        try:
            stockTypes = LevelHandler.getStockBoxes(tileData)
        except:
            stockTypes = []
        boxCount = 0
        y = -1
        for line in mapList:
            x=-1
            y+=1
            for char in line:
                x+=1
                if char == "v":
                    self.tiles.append(Tile((x*80,y*80), "Images/Tiles/stove_front.png", True, False))
                if char == "s":
                    try:
                        food = stockTypes[boxCount]
                    except:
                        food = None
                    self.tiles.append(StockBox((x*80,y*80), food, True))
                    boxCount += 1
                if char == "#":
                    try:
                        top = mapList[y-1][x]
                        bottom = mapList[y+1][x]
                        left = mapList[y][x-1]
                        right = mapList[y][x+1]
                    except:
                        pass
                    if y == 0 and x != 0 and x!= 11:
                        self.tiles.append(Counter((x*80,y*80), None,"Images/Tiles/counter_front.png"))
                    elif x == 0 and y != 0:
                        self.tiles.append(Counter((x*80,y*80), None,"Images/Tiles/counter_side_left.png"))
                    elif x == 11 and y!= 0:
                        self.tiles.append(Counter((x*80,y*80), None,"Images/Tiles/counter_side_right.png"))
                    elif x == 0 and y == 0:
                        self.tiles.append(Counter((x*80,y*80), None,"Images/Tiles/counter_corner_tl.png"))
                    else:
                        self.tiles.append(Counter((x*80,y*80), None,"Images/Tiles/counter_top.png"))

                if char == "t":
                    self.tiles.append(Trash((x*80,y*80)))
                if char == "d":
                    self.tiles.append(DeliveryTable((x*80,y*80), None))
                if char == "c":
                    self.tiles.append(ChoppingBoard((x*80,y*80), None))
                if char == "-":
                    self.tiles.append(Tile((x*80,y*80), "Images/Tiles/floor.png"))
Esempio n. 6
0
    def run_game(self):
        running = True
        move_boat_right = False
        move_boat_left = False
        move_rod_right = False
        move_rod_left = False
        move_fisher_right = False
        move_fisher_left = False
        move_line_down = False
        move_line_up = False

        while running:
            for event in pygame.event.get():
                if event.type == pygame.QUIT:
                    running = False
                if event.type == pygame.KEYDOWN:
                    if event.key == pygame.K_ESCAPE:
                        running = False
                    if event.key == pygame.K_RIGHT:
                        move_boat_right = True
                        move_fisher_right = True
                        move_rod_right = True
                    if event.key == pygame.K_LEFT:
                        move_boat_left = True
                        move_fisher_left = True
                        move_rod_left = True
                    if event.key == pygame.K_DOWN:
                        move_line_down = True
                    if event.key == pygame.K_UP:
                        move_line_up = True
                if event.type == pygame.KEYUP:
                    if event.key == pygame.K_RIGHT:
                        move_boat_right = False
                        move_fisher_right = False
                        move_rod_right = False
                    if event.key == pygame.K_LEFT:
                        move_boat_left = False
                        move_fisher_left = False
                        move_rod_left = False
                    if event.key == pygame.K_DOWN:
                        move_line_down = False
                    if event.key == pygame.K_UP:
                        move_line_up = False
            # Knowing when to spawn trash
            current_time = time.time()
            time_since_game_start = current_time - self.start_time
            if time_since_game_start > self.trashCount * self.trash_interval:
                new_trash = Trash.Trash(self.frame)
                self.trash_list.append(new_trash)
                self.trashCount += 1

            # Knowing when to spawn fish
            if time_since_game_start > self.fish1Count * self.fish1_interval:
                new_fish1 = Fish.Fish(time_since_game_start, self.frame,
                                      self.image1)
                self.fish1_list.append(new_fish1)
                self.fish1Count += 1

            if time_since_game_start > self.fish2Count * self.fish2_interval:
                new_fish2 = Fish.Fish(time_since_game_start, self.frame,
                                      self.image2)
                self.fish2_list.append(new_fish2)
                self.fish2Count += 1

            if time_since_game_start > self.fish3Count * self.fish3_interval:
                new_fish3 = Fish.Fish(time_since_game_start, self.frame,
                                      self.image3)
                self.fish3_list.append(new_fish3)
                self.fish3Count += 1

            # Update the boat pos if key pressed down
            if move_boat_right:
                self.boat.move_boat_right()
            if move_boat_left:
                self.boat.move_boat_left()

            # Update the rod pos if key pressed down
            if move_rod_right:
                self.rod.move_rod_right()
            if move_boat_left:
                self.rod.move_rod_left()

            if move_line_down:
                self.rod.line_down()
            if move_line_up:
                self.rod.line_up()

            # Update fisher pos if key pressed down
            if move_fisher_right:
                self.fisher.move_fisher_right()
            if move_fisher_left:
                self.fisher.move_fisher_left()

            #Cloud movement
            self.cloud.move_cloud()

            #Wave movement
            self.wave.move_wave()

            #Fish movement
            for fish in self.fish1_list:
                fish.move_fish1()
                if fish.offscreen:
                    self.fish1_list.remove(fish)

            for fish in self.fish2_list:
                fish.move_fish2()
                if fish.offscreen:
                    self.fish2_list.remove(fish)

            for fish in self.fish3_list:
                fish.move_fish3()
                if fish.offscreen3:
                    self.fish3_list.remove(fish)
            #Trash movement
            for trash in self.trash_list:
                trash.move_trash()
                if trash.offscreen:
                    self.trash_list.remove(trash)

            for trash in self.trash_list:
                if trash.rect.collidepoint(self.rod.line_end_pos):
                    self.score.update_score(-50)
                    self.trash_list.remove(trash)
            for fish in self.fish1_list:
                if fish.rect1.collidepoint(self.rod.line_end_pos):
                    self.score.update_score(250)
                    self.fish1_list.remove(fish)
            for fish in self.fish2_list:
                if fish.rect2.collidepoint(self.rod.line_end_pos):
                    self.score.update_score(100)
                    self.fish2_list.remove(fish)
            for fish in self.fish3_list:
                if fish.rect3.collidepoint(self.rod.line_end_pos):
                    self.score.update_score(300)
                    self.fish3_list.remove(fish)

            # Cloud collision
            self.cloud.collision()

            # Wave collision
            self.wave.collision()

            #Draw Sky
            self.frame.fill((135, 206, 235))
            #Draw Water
            pygame.draw.rect(
                self.frame, (0, 187, 209),
                (0, self.height // 2, self.width, self.height // 2))
            #Draw Clouds
            self.cloud.draw()
            #Draw Fisher
            self.fisher.draw()
            #Draw Rod
            self.rod.draw()
            #Draw Boat
            self.boat.draw()
            #Draw Waves
            self.wave.draw()
            #Draw Trash
            for trash in self.trash_list:
                trash.draw()
            #Draw fish
            for fish in self.fish1_list:
                fish.draw_fish1()

            for fish in self.fish2_list:
                fish.draw_fish2()

            for fish in self.fish3_list:
                fish.draw_fish3()

            #Draw fishing Line
            self.rod.draw_line()

            #Draw score
            self.score.draw_score_text(
                self.boat.xboat1pos - 20 + self.boat.image.get_width() // 2,
                self.boat.yboatpos - 10 + self.boat.image.get_height() // 2)

            #Draw Upgrades
            self.upgrades.draw_upgrades()
            self.upgrades.draw_upgrade_circle()

            pygame.display.update()
Esempio n. 7
0
    def gameInit(self):
        self.sounds = Sound.Sound()
        self.building = Building.Building(self.screen, self.screenSize)
        if self.rainEffect:
            self.weather = []
            for columnNumber in range(1,
                                      self.building.leftWallX // Weather.SIZE):
                self.weather.append(
                    Weather.Column(columnNumber * Weather.SIZE, self.screen,
                                   self.building.floorY))
            for columnNumber in range(self.building.leftWallX // Weather.SIZE,
                                      self.building.rightWallX //
                                      Weather.SIZE):
                self.weather.append(
                    Weather.Column(columnNumber * Weather.SIZE, self.screen,
                                   self.building.leftWallX))
            for columnNumber in range(self.building.rightWallX // Weather.SIZE,
                                      self.screenWidth // Weather.SIZE):
                self.weather.append(
                    Weather.Column(columnNumber * Weather.SIZE, self.screen,
                                   self.building.floorY))
        self.sky = Weather.Sky(self.screen, self.screenWidth,
                               self.screenHeight, self.building.leftWallX,
                               self.building.rightWallX,
                               self.building.ceilingY, self.sounds)

        # RANDOMLY SPAWNED
        self.hero = Character.Player(self.screen, self.building,
                                     self.screenWidth, self.screenHeight)

        self.cultist = Trash.Cultist(self.screen, self.building)
        self.enemiesToSpawn.append(self.cultist)
        self.cultist2 = Trash.Cultist(self.screen, self.building)
        self.enemiesToSpawn.append(self.cultist2)

        self.angel = Trash.Angel(self.screen, self.building)
        #self.enemies.append(self.angel)
        #self.angel.spawn()
        self.enemiesToSpawn.append(self.angel)

        self.skeleton = Trash.Skeleton(self.screen, self.building)
        self.enemiesToSpawn.append(self.skeleton)
        self.skeleton2 = Trash.Skeleton(self.screen, self.building)
        self.enemiesToSpawn.append(self.skeleton2)

        self.bomb = Equipment.Bomb(self.screen, self.building)
        self.equipmentToSpawn.append(self.bomb)
        self.bomb2 = Equipment.Bomb(self.screen, self.building)
        self.equipmentToSpawn.append(self.bomb2)
        self.garlic = Equipment.Garlic(self.screen, self.building)
        self.equipmentToSpawn.append(self.garlic)
        self.garlic2 = Equipment.Garlic(self.screen, self.building)
        self.equipmentToSpawn.append(self.garlic2)
        self.flute = Equipment.Flute(self.screen, self.building)
        self.equipmentToSpawn.append(self.flute)
        self.flute2 = Equipment.Flute(self.screen, self.building)
        self.equipmentToSpawn.append(self.flute2)
        self.rune = Equipment.Rune(self.screen, self.building)
        self.equipmentToSpawn.append(self.rune)
        self.rune2 = Equipment.Rune(self.screen, self.building)
        self.equipmentToSpawn.append(self.rune2)
        self.rune3 = Equipment.Rune(self.screen, self.building)
        self.equipmentToSpawn.append(self.rune3)
        self.sword = Equipment.Sword(self.screen, self.building)
        self.equipmentToSpawn.append(self.sword)
        self.whip = Equipment.Whip(self.screen, self.building)
        self.equipmentToSpawn.append(self.whip)
        self.shield = Equipment.Shield(self.screen, self.building)
        self.equipmentToSpawn.append(self.shield)