Пример #1
0
    def BuildUnit(self):
        randtemp = random.randint(0,len(self.UnlockedUnits)-1)
        unit = Unit(UnitLoader.units[self.UnlockedUnits[randtemp]])

        self.cooldown = self.cooldown + 1

        if (self.mooncrystals - unit.unitcost) >= 0:
            self.RemoveMoonCrystals(unit.unitcost)
            UnitSpawner.EnqueueUnit(unit)
Пример #2
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)
Пример #3
0
 def ReachedEPlayer(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)
             UnitSpawner.DeleteUnit(CurrentUnit)
             x = len(units) + 1
             print Health
             return Health
         else:
             return BaseHealth
Пример #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
Пример #5
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")
Пример #6
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")