Example #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)
Example #2
0
 def EAttack(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):
             UnitLoader.DeleteUnit(Enemies)
Example #3
0
 def ReachedPlayer(cls, units, base, CurrentHealth=1000):
     x = 0
     BaseHealth = CurrentHealth
     if(base == 1):
         basePos = 9
     if(base == 0):
         basePos = 3531
     while(x<len(units)):
         CurrentUnit = units[x]
         x = x+1
         UnitRange = CurrentUnit.unitrange
         if abs(CurrentUnit.xpos-basePos)<10:
             Health = WinCon.AttackPlayer(BaseHealth, CurrentUnit.health)
             UnitLoader.DeleteUnit(CurrentUnit)
             x = len(units) + 1
             print Health
             return Health
         else:
             return BaseHealth
Example #4
0
    def CalculateDangerValue(self):
        count = 0
        countai = 0
        for unit in UnitLoader.GetCreatedUnits():
            count = count + 1

        for unit in UnitSpawner.GetCreatedUnits():
            countai = countai + 1

        val = count - countai

        if val <= 0:
            self.dangervalue = 0
        elif val <= 5:
            self.dangervalue = 1
        elif val <= 10:
            self.dangervalue = 2
        elif val <= 20:
            self.dangervalue = 3
        elif val <= 25:
            self.dangervalue = 4
        else:
            self.dangervalue = 5
Example #5
0
    def BTANK(self):
        unit = Unit(UnitLoader.units["Tank"])

        UnitLoader.EnqueueUnit(unit)
Example #6
0
    def BSR(self):
        unit = Unit(UnitLoader.units["SpaceRaider"])

        UnitLoader.EnqueueUnit(unit)
Example #7
0
    def BHRB(self):
        unit = Unit(UnitLoader.units["HorseRifleBlaster"])

        UnitLoader.EnqueueUnit(unit)
Example #8
0
    def __init__(self):
        SceneBase.__init__(self)
        UnitLoader.__init__()

        self.counter = 0
        self.Economy = False
        self.MoneyCounter = 0
        self.AttackRate = 0
        self.EAttackRate = 0
        self.Health = 1000
        if UpgradeData.defense:
            self.EHealth = 1500
        elif not UpgradeData.defense:
            self.EHealth = 1000

        print(self.Health)

        self.offset = 0
        self.movecamera = 0
        self.scrollfactor = 25

        self.UnitMovement = UnitMovement()

        if Options.hardcoremode:
            self.AI = BaseAI(6)
        else:
            self.AI = BaseAI(3)

        self.defendbutton = Button("Defend", (60, 635),
                                   self.Attack,
                                   size=(120, 30),
                                   font_size=20,
                                   bg=(109, 177, 255))
        self.holdbutton = Button("Hold", (185, 635),
                                 self.HoldPosition,
                                 size=(120, 30),
                                 font_size=20,
                                 bg=(109, 177, 255))
        self.attackbutton = Button("Attack", (310, 635),
                                   self.DefendPosition,
                                   size=(120, 30),
                                   font_size=20,
                                   bg=(109, 177, 255))
        self.openmenu = Button("Build List", (1130, 600),
                               self.Menu,
                               size=(120, 30),
                               font_size=20,
                               bg=(109, 177, 255))

        self.resourcebar = Bar("Moon Crystals: 100", (1080, 15),
                               size=(240, 30),
                               font_size=20,
                               bg=(176, 185, 186))
        self.supplybar = Bar("Units: 0/40", (1080, 45),
                             size=(240, 30),
                             font_size=20,
                             bg=(176, 185, 186))

        self.buildmenu = ToggleMenu((1140, 350),
                                    size=(160, 400),
                                    bg=(176, 185, 186),
                                    shown=False)

        self.buildrifleblaster = Button("RifleBlaster 100", (1130, 275),
                                        self.BRB,
                                        size=(120, 60),
                                        font_size=15,
                                        bg=(109, 177, 255))
        self.buildhorserifleblaster = Button("HorseRifleBlaster 200",
                                             (1130, 435),
                                             self.BHRB,
                                             size=(120, 60),
                                             font_size=12,
                                             bg=(109, 177, 255))
        self.buildspaceraider = Button("SpaceRaider 50", (1130, 195),
                                       self.BSR,
                                       size=(120, 60),
                                       font_size=15,
                                       bg=(109, 177, 255))
        self.buildtank = Button("Tank 300", (1130, 355),
                                self.BTANK,
                                size=(120, 60),
                                font_size=15,
                                bg=(109, 177, 255))

        self.buildmenutoggle = False

        self.buildqueue = StatBar(" ", (1090, 635),
                                  size=(200, 20),
                                  bg=(176, 185, 186),
                                  fg=(109, 177, 255))

        self.basehealth = StatBar(" ", (80, 45),
                                  size=(150, 20),
                                  bg=(176, 185, 186),
                                  fg=(219, 40, 0))

        self.ebasehealth = StatBar(" ", (80, 15),
                                   size=(150, 20),
                                   bg=(176, 185, 186),
                                   fg=(109, 177, 255))

        self.text = Text(15, 80, "Base Health", bold=True, fontSize=18)

        self.etext = Text(45, 80, "Enemy Base Health", bold=True, fontSize=18)

        self.buildmenu.AddButton(self.buildhorserifleblaster)
        self.buildmenu.AddButton(self.buildrifleblaster)
        self.buildmenu.AddButton(self.buildspaceraider)
        self.buildmenu.AddButton(self.buildtank)

        b = Boombox()
        b.PlayMusic("level6playmusic")
Example #9
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")
Example #10
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()

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

        # Move all spawned enemy units
        if (self.counter == 25):
            self.UnitMovement.MoveEnemyUnits()
            if (random.randint(0, 100) <= 5):
                #UnitSpawner.EnqueueUnit(UnitSpawner.units["RifleBlaster"])
                pass
            self.counter = 0
        else:
            self.counter = self.counter + 1

        # 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)
        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.ReachedEPlaer(self.ce, 1)
        if (self.EHealth <= 0):
            print "YOU LOST YOU F*****G SUCK YOU LITTLE DUMBASS"
            self.SwitchToScene("Scenes.Levels.Level6Defeat.Level6Defeat")