Ejemplo n.º 1
0
    def Render(self, screen):
        screen.fill((0, 0, 0))

        screen.blit(GetImage("Images/Neptune.jpg"),
                    (0 - Camera.GetXOffset(), 0))

        # Draw your units on screen
        for unit in self.cu:
            topLeft = (unit.xpos - Camera.GetXOffset(), unit.ypos, unit.width,
                       unit.hight)
            bottomRight = (unit.animate.frame, 0, unit.width, unit.hight)
            if (self.UnitMovement.movementmode == "A"):
                unit.animate.nextFrame()
                screen.blit(GetImage(unit.imagepath + "walk.png"), topLeft,
                            bottomRight)
            else:
                unit.animate.prevFrame()
                screen.blit(
                    pygame.transform.flip(
                        GetImage(unit.imagepath + "walk.png"), True, False),
                    topLeft, bottomRight)
        # Draw enemy units on screen
        for unit in self.ce:
            unit.animate.prevFrame()
            topLeft = (unit.xpos - Camera.GetXOffset(), unit.ypos, unit.width,
                       unit.hight)
            bottomRight = (unit.animate.frame, 0, unit.width, unit.hight)
            screen.blit(
                pygame.transform.flip(GetImage(unit.imagepath + "walk.png"),
                                      True, False), topLeft, bottomRight)

        # Draw the GUI
        self.attackbutton.Draw(screen)
        self.holdbutton.Draw(screen)
        self.defendbutton.Draw(screen)

        # Make sure not to update the text unless it has changed
        if "Moon Crystals: " + str(
                CurrencyManagement.GetMoonCrystals()) != self.resourcebar.txt:
            self.resourcebar.SetText("Moon Crystals: " +
                                     str(CurrencyManagement.GetMoonCrystals()))

        if "Units: " + str(
                UnitLoader.GetUsedSupply()) + "/40" != self.supplybar.txt:
            self.supplybar.SetText("Units: " +
                                   str(UnitLoader.GetUsedSupply()) + "/40")

        self.resourcebar.Draw(screen)
        self.supplybar.Draw(screen)

        self.buildqueue.Draw(screen)
        self.buildmenu.Draw(screen)
        self.openmenu.Draw(screen)

        self.basehealth.Draw(screen)
        self.ebasehealth.Draw(screen)

        self.text.Draw(screen)
        self.etext.Draw(screen)
Ejemplo n.º 2
0
    def EnqueueUnit(cls, unit):
        if CurrencyManagement.GetMoonCrystals() - unit.unitcost >= 0:
            if len(cls.createdUnits) + len(cls.queuedUnits) < 40:

                if cls.lane > 2:
                    cls.lane = 1
                else:
                    cls.lane = cls.lane + 1

                unit.laneid = cls.lane
                CurrencyManagement.PurchaseUnit(unit)
                cls.queuedUnits.append(unit)
            else:
                print("Max unit count reached!")
Ejemplo n.º 3
0
 def Attack(cls,
            Friendlies,
            Enemies,
            EnemyList,
            Rate,
            OGSpeed=0,
            EOGSpeed=0):
     if (Friendlies.speed != 0):
         OGSpeed = Friendlies.speed
     Friendlies.speed = 0
     if ((Rate * (Friendlies.attackrate)) > 50):
         Enemies.DamageUnit(Friendlies.damage)
         if (Enemies.health < 1):
             CurrencyManagement.AddMoonCrystals((Enemies.unitcost) / 2)
             UnitSpawner.DeleteUnit(Enemies)
Ejemplo n.º 4
0
    def Update(self):
        if self.movecamera != 0:
            if Camera.CheckCameraOffsets(self.offset, self.movecamera):
                self.offset += self.movecamera
                Camera.SetCameraOffset(self.offset, 0)

        self.cu = UnitLoader.GetCreatedUnits()
        self.ce = UnitSpawner.GetCreatedUnits()

        self.basehealth.SetFillPercentage(self.Health, 1000)

        self.ebasehealth.SetFillPercentage(self.EHealth, 1000)

        #Generate Money
        if (len(self.cu) > 0):
            self.Economy = True
        if (self.Economy == True):
            if (self.MoneyCounter == 60):
                self.MoneyCounter = 0
                if UpgradeData.economy:
                    CurrencyManagement.AddMoonCrystals(15)
                elif not UpgradeData.economy:
                    CurrencyManagement.AddMoonCrystals(10)

            else:
                self.MoneyCounter += 1
        if (len(self.cu) < 1):
            if (len(self.ce) < 1):
                if (self.Economy == True):
                    self.Economy = False
                    if (CurrencyManagement.GetMoonCrystals() < 100):
                        CurrencyManagement.AddMoonCrystals(
                            100 - CurrencyManagement.GetMoonCrystals())

        # Move all the units based on the current movement mode
        self.UnitMovement.MoveUnits()
        self.UnitMovement.MoveEnemyUnits()
        UnitLoader.BuildUnitsInQueue(self.buildqueue)

        # Call the AI
        self.AI.AIUpdate()

        # Move all spawned enemy units
        self.UnitMovement.MoveEnemyUnits()

        UnitSpawner.BuildUnitsInQueue()
        #You attack
        AttackDefend.UnitsAttack(self.cu, self.ce, self.AttackRate,
                                 self.EAttackRate)
        if (self.AttackRate > 50):
            self.AttackRate = 0
        else:
            self.AttackRate += 1
        if (self.EAttackRate > 50):
            self.EAttackRate = 0
        else:
            self.EAttackRate += 1
        #Attack Base
        if (self.Health != 1000):
            if (self.Health != 1500):
                if (len(self.cu) > 0):
                    self.Health = WinCon.ReachedPlayer(self.cu, 0, self.Health)
        if (self.Health == 1500):
            if (len(self.cu) > 0):
                self.Health = WinCon.ReachedPlayer(self.cu, 0, self.Health)
        if (self.Health == 1000):
            if (len(self.cu) > 0):
                self.Health = WinCon.ReachedPlayer(self.cu, 0)
        if (self.Health <= 0):
            print "Congrats you have won"
            self.SwitchToScene("Scenes.Levels.Level6Victory.Level6Victory")

        #Enemies Attack Base
        if (self.EHealth != 1000):
            if (self.EHealth != 1500):
                if (len(self.ce) > 0):
                    self.EHealth = WinCon.ReachedEPlayer(
                        self.ce, 1, self.EHealth)
        if (self.EHealth == 1000):
            if (len(self.ce) > 0):
                self.EHealth = WinCon.ReachedEPlayer(self.ce, 1)
        if (self.EHealth == 1500):
            if (len(self.ce) > 0):
                self.EHealth = WinCon.ReachedEPlayer(self.ce, 1, self.EHealth)
        if (self.EHealth <= 0):
            print "YOU LOST YOU F*****G SUCK YOU LITTLE DUMBASS"
            self.SwitchToScene("Scenes.Levels.Level6Defeat.Level6Defeat")
Ejemplo n.º 5
0
    def ProcessInput(self, events, pressed_keys):

        mousepos = pygame.mouse.get_pos()

        for event in events:

            # Keydown events
            if event.type == pygame.KEYDOWN:
                if event.key == pygame.K_RETURN:
                    self.SwitchToScene(None)

                elif event.key == pygame.K_ESCAPE:
                    self.SwitchToScene(
                        "Scenes.Levels.Level6Victory.Level6Victory")

                elif event.key == pygame.K_a:
                    self.buildqueue.SetFillPercentage(10, 100)

                elif event.key == pygame.K_b:
                    self.buildmenutoggle = not self.buildmenutoggle
                    self.buildmenu.ToggleMenu(self.buildmenutoggle)

                elif event.key == pygame.K_RIGHT:
                    if self.movecamera >= 0:
                        self.movecamera += self.scrollfactor

                elif event.key == pygame.K_LEFT:
                    if self.movecamera <= 3600:
                        self.movecamera -= self.scrollfactor

                elif event.key == pygame.K_m:
                    CurrencyManagement.AddMoonCrystals(100)

            elif event.type == pygame.KEYUP:
                if event.key == pygame.K_RIGHT:
                    if self.movecamera >= 0:
                        self.movecamera -= self.scrollfactor

                elif event.key == pygame.K_LEFT:
                    if self.movecamera <= 3600:
                        self.movecamera += self.scrollfactor

            # Mouse click events
            elif event.type == pygame.MOUSEBUTTONDOWN:

                if self.attackbutton.IsClicked(mousepos):
                    self.attackbutton.call_back_()

                elif self.defendbutton.IsClicked(mousepos):
                    self.defendbutton.call_back_()

                elif self.holdbutton.IsClicked(mousepos):
                    self.holdbutton.call_back_()

                elif self.buildhorserifleblaster.IsClicked(mousepos):
                    self.buildhorserifleblaster.call_back_()

                elif self.buildspaceraider.IsClicked(mousepos):
                    self.buildspaceraider.call_back_()

                elif self.buildtank.IsClicked(mousepos):
                    self.buildtank.call_back_()

                elif self.buildrifleblaster.IsClicked(mousepos):
                    self.buildrifleblaster.call_back_()

                elif self.openmenu.IsClicked(mousepos):
                    self.buildmenutoggle = not self.buildmenutoggle
                    self.buildmenu.ToggleMenu(self.buildmenutoggle)