Esempio n. 1
0
    def __init__(self, game, steps=None, name=None, description=None, year=0):

        stats = Stats()
        #    stats.R_HUMAN.turrets = [ stats.T_SOLAR_0 ]
        #    stats.R_HUMAN.missiles = []
        #    stats.R_HUMAN.ships = []
        stats.PlayableShips = {}

        steps = []
        for i in xrange(8):
            steps.append(
                Step(goal=lambda self, game: not filter(
                    lambda ship: ship.alive, self.ennemyShips),
                     onBegin=lambda self, game, stepNbr=i + 1: self.
                     stepFunction(game, stepNbr),
                     failure=lambda self, game: not self.player.flagship or
                     not self.player.flagship.alive,
                     texts=[(1, "Clear the area.")]))

        Scenario.__init__(self, game, steps=steps, stats=stats)

        self.sol = Sun(game.stats.S_SOL, 4000, 0)

        for i in range(75):  # asteroids
            asteroid = Asteroid(game, -2000, 0, 800)
            game.harvestables.append(asteroid)

        game.astres = [self.sol]

        self.player = None
        self.startingPoint = (-1000, 0)

        self.ennemyPosition = (-2000, 0)
        self.ennemy = Faction(game.stats.R_EXTRA, "Unknown")
        game.addPlayer(self.ennemy)

        self.infestedAsteroid = Asteroid(game, self.ennemyPosition[0],
                                         self.ennemyPosition[1], 0)
        game.harvestables.append(self.infestedAsteroid)

        self.ennemyShips = []
Esempio n. 2
0
    def __init__(self, game, steps=None, name=None, description=None, year=0):
    
        stats = Stats()
    #    stats.R_HUMAN.turrets = [ stats.T_SOLAR_0 ]
    #    stats.R_HUMAN.missiles = []
    #    stats.R_HUMAN.ships = []
        stats.PlayableShips = {}
        
        steps = []
        for i in xrange( 8 ):
            steps.append( Step( 
                goal=lambda self, game: not filter( lambda ship: ship.alive, self.ennemyShips ),
                onBegin=lambda self, game, stepNbr=i+1: self.stepFunction( game, stepNbr ),
                failure=lambda self, game: not self.player.flagship or not self.player.flagship.alive,
                texts = [ (1,"Clear the area.")] )
                )
        
        Scenario.__init__(self, game, steps=steps, stats=stats )
        
        self.sol = Sun( game.stats.S_SOL, 4000, 0 )

        for i in range( 75 ): # asteroids
            asteroid = Asteroid( game, -2000, 0, 800 )
            game.harvestables.append( asteroid )
            
        game.astres = [ self.sol ]
        
        self.player = None
        self.startingPoint = ( -1000, 0 )
        
        self.ennemyPosition = ( -2000, 0 )
        self.ennemy = Faction( game.stats.R_EXTRA, "Unknown" )
        game.addPlayer( self.ennemy )
        
        self.infestedAsteroid = Asteroid( game, self.ennemyPosition[0], self.ennemyPosition[1], 0 )
        game.harvestables.append( self.infestedAsteroid )
        
        self.ennemyShips = []
Esempio n. 3
0
    def __init__(self, game, steps=None, name=None, description=None, year=0):
        
        stats = Stats()
        stats.R_HUMAN.turrets = [ stats.T_LASER_SR_1, stats.T_LASER_SR_0,
stats.T_MASS_SR_1, stats.T_MASS_SR_0, stats.T_MASS_MR_0 ]
        stats.R_HUMAN.missiles = []
        stats.R_HUMAN.ships = [ stats.HARVESTER ]
        stats.PlayableShips = {}
        
        steps = [
            Step( 
                goal=lambda self, game: utils.distLowerThanObjects( self.player.flagship, self.asteroid, 300 ),
                failure=lambda self, game: not self.player.flagship or not self.player.flagship.alive,
             #   onBegin=lambda self, game: self.player.flagship.ore = 500,
                texts = [ (0, "We need some materials."),
                            (4*config.fps, "There is an asteroid close to the Moon."),
                            (8*config.fps, "Get close to it.") ] ),
            Step( 
                goal=lambda self, game: self.player.flagship.ai.launching[ self.player.race.defaultHarvester.img ],
                failure=lambda self, game: not self.player.flagship or not self.player.flagship.alive,
                texts = [ (0, "Begin collecting raw ore."),
     (4*config.fps, "To do so, launch your harvester by pressing the blue arrow button at the bottom of the screen.") ] ),
            Step(
                goal=lambda self, game: self.player.flagship.oreProcess,
                failure=lambda self, game: not self.player.flagship or not self.player.flagship.alive,
                texts = [ (0, "Now wait for them to bring back the ore."),
                (6*config.fps, "Don't worry about the ships following you around."),
                (10*config.fps, "They are civilian and while they are under your protection they speed up building processes.") ] ),
            Step( 
                goal=lambda self, game: self.player.flagship.ore >= 100,
                failure=lambda self, game: not self.player.flagship or not self.player.flagship.alive,
                texts = [ (0, "They have now added the raw ore to the processing queue."),
                (4*config.fps, "Wait a little while and it will be transformed into usable materials."),
                (8*config.fps, "Keep harvesting and processing the ore until you reach 100 material."),
                (12*config.fps, "Notice the moving bars at the bottom right corner of the screen..."),
                (14*config.fps, "they represents the ore being processed."),
                (18*config.fps, "once they reach the right, they are usable!"),
                (22*config.fps, "They will then be added to the ore stock indicated by the blue gage in the bottom right corner."), ] ),
            Step( 
                goal=lambda self, game: self.player.flagship.shipyards[ self.player.race.defaultHarvester.img ].getCount() >= 4,
                failure=lambda self, game: not self.player.flagship or not self.player.flagship.alive,
                texts = [ (0, "You now have enough material to build a new harvester and speed it up!"),
    (2*config.fps, "To do so, click on the icon of the harvester at the bottom of the screen, under the launch button.") ] ),
            Step( 
                goal=lambda self, game: self.player.flagship.ore >= 300,
                failure=lambda self, game: not self.player.flagship or not self.player.flagship.alive,
                texts = [ (0, "Keep harvesting and processing ore util you reach 300 material."),
                (4*config.fps, "It will follow the orders the others already received."),
                (8*config.fps, "Notice the blue bar in the upper right corner and the green one in the bottm right..."),
                (12*config.fps, "the blue one represents your shield and the green one your hull.") ] ),
            Step( 
                goal=lambda self, game: len( filter( lambda turret: turret.install, self.player.flagship.turrets ) ) >= 3,
                failure=lambda self, game: not self.player.flagship or not self.player.flagship.alive,
                texts = [ (0, "There are rumors of pirates in the area."),
                (4*config.fps, "Build one more mass cannon turret on your ship."),
                (8*config.fps, "To do so, click on an empty slot on the right of the screen and select an affordable turret."), ] ),
            Step( 
                goal=lambda self, game: not self.ennemyShip.alive,
                failure=lambda self, game: not self.player.flagship or not self.player.flagship.alive,
                onBegin=lambda self, game: (self.addAttackingEnnemy( game, (self.moon.xp-1500,self.moon.yp-800), self.player.flagship, "Pirate lambda" ), game.setRelationBetween( self.player, self.ennemy, 1 )),
                texts = [ (0, "Defend yourself from the incoming pirate ship."),
                (4*config.fps, "To attack it, simply left-click on it once."),
                (8*config.fps, "Your crew will aim and fire the turrets."),
                (12*config.fps, "You can still help them by manoeuvering the ship so that the ennemy is in range of the turrets.") ] ),
            Step( 
                goal=lambda self, game: utils.distLowerThanObjects( self.player.flagship, self.orbitalbase, 100 ),
                failure=lambda self, game: not self.player.flagship or not self.player.flagship.alive,
                texts = [ (0, "Well done!"),
                (2*config.fps, "Recall your harvester and return to the orbital base.") ] ),
            ]
        
        Scenario.__init__(self, game, steps=steps, stats=stats )
    
        ### redefining stats, dangerous
        
        
        self.sol = Sun( game.stats.S_SOL, 0, 0 )
        self.mercury = Planet( game.stats.P_MERCURY, -4100, 1400 )
        self.venus = Planet( game.stats.P_VENUS, 5000, 2300 )
        self.earth = Planet( game.stats.P_EARTH, -3100, 6700 )
        self.mars = Planet( game.stats.P_MARS_1, -7800, -2300 )
        self.moon = Planet( game.stats.P_MOON, -3900, 6400 )
        self.jupiter = Planet( game.stats.P_JUPITER, -13000, -4800 )
        self.saturn = Planet( game.stats.P_SATURN, 13000, 2500 )
        self.neptune = Planet( game.stats.P_NEPTUNE, 15000, 7000 )
        
        self.moon.zp = -50
        self.moon.yi = 0.1
        self.moon.orbiting = self.earth
        
        # asteroids over the moon, vital to scenario
        for i in xrange( 1 ):
            self.asteroid = Asteroid( game, self.moon.xp-200, self.moon.yp+150, 10 )
            game.harvestables.append( self.asteroid )
        
        for i in xrange( 3 ): # civilians around self.earth
            dist = randint( 100, 800 )
            angle = 2*pi*random()

            (x,y) = (self.earth.xp+dist*cos(angle), self.earth.yp+dist*sin(angle))
            s = Ship( game.stats.CIVILIAN_0, AiCivilian(), x, y, -20 )
            game.objects.append( s )

        for i in range( 50 ): # asteroids outer self.mars
            dist = 9000
            angle = (1-2*random())*pi/8+pi*9/8
            asteroid = Asteroid( game, self.sol.xp+dist*cos(angle), self.sol.yp+dist*sin(angle), 300 )
            game.harvestables.append( asteroid )

        game.astres = [self.sol, self.mercury, self.venus, self.earth, self.moon, self.mars, self.jupiter, self.saturn, self.neptune, self.moon ]
        
        dist = self.earth.stats.maxRadius*1.5
        angle = 5*pi/8
        self.orbitalbase = OrbitalBase( None, game.stats.HUMAN_BASE_MINING, None, self.earth.xp+dist*cos(angle),self.earth.yp+dist*sin(angle))
        self.orbitalbase.ri = -0.013
        game.objects.append( self.orbitalbase )
        
        self.player = None
Esempio n. 4
0
    def __init__(self, game, steps=None, name=None, description=None, year=0):
    
        stats = Stats()
        stats.R_HUMAN.turrets = [ stats.T_SOLAR_0 ]
        stats.R_HUMAN.missiles = []
        stats.R_HUMAN.ships = []
        stats.PlayableShips = {}
        
        steps = [
            Step( 
                goal=lambda self, game: game.tick-9*config.fps>=self.lastStepAt and self.player.inputs.xc and not utils.distLowerThan( (self.player.inputs.xc+self.player.inputs.wc/2, self.player.inputs.yc+self.player.inputs.hc/2 ), self.player.flagship.pos, 200 ),
                failure=lambda self, game: not self.player.flagship or not self.player.flagship.alive,
                texts = [ (0,_("Look around your ship a bit.")),
    (config.fps*3, _("To move the camera, either use the arrow keys...")),
    (config.fps*6, _("or click on the radar in the upper left corner."))] ),
            Step( 
                goal=lambda self, game: game.tick-6*config.fps>=self.lastStepAt and utils.distLowerThan( (self.player.inputs.xc+self.player.inputs.wc/2, self.player.inputs.yc+self.player.inputs.hc/2 ), self.player.flagship.pos, 2 ),
                failure=lambda self, game: not self.player.flagship or not self.player.flagship.alive,
                texts = [ (0,_("Good, now stick the camera to your ship.")),
    (config.fps*3, _("To do so, click on the center of the radar.")),] ),
            Step( 
                goal=lambda self, game:  game.tick-9*config.fps>=self.lastStepAt and not utils.distLowerThan( self.startingPoint, self.player.flagship.pos, 100 ),
                failure=lambda self, game: not self.player.flagship or not self.player.flagship.alive,
                texts = [ (0,_("Now move away from the orbital station.")),
      (3*config.fps, _("To move the ship, left-click on the destination and your crew will manoeuver towards there.") ),
      (6*config.fps, _("To give the order to stop, left-click on the ship.") ) ] ),
            Step( 
                goal=lambda self, game: filter( lambda turret: turret.building==stats.T_SOLAR_0, self.player.flagship.turrets ),
                failure=lambda self, game: not self.player.flagship or not self.player.flagship.alive,
                texts = [ (0,_("Let's prepare ourselves before going out to explore.")),
          (3*config.fps, _("Jumping uses a lot of energy, so first build 2 solar arrays on your ship.") ),
          (6*config.fps, _("To do so, left-click on one of the black circle at the right of the screen.") ),           
          (9*config.fps, _("Then select the solar array from the list.") ) ] ),
            Step( 
                goal=lambda self, game: filter( lambda turret: turret.install and turret.install.stats==stats.T_SOLAR_0, self.player.flagship.turrets ),
                failure=lambda self, game: not self.player.flagship or not self.player.flagship.alive,
                texts = [ (0,_("Well done, it will take a little while for it to be completed.")),
                          (3*config.fps, _("Begin building the second one right away.") ),
                          (9*config.fps, _("Notice the green bar in the top right corner...") ),
                          (12*config.fps, _("it indicates the proportion of energy in your battery.") ),
                          (15*config.fps, _("The quantity is indicated in green text next to it..") ) ] ),
            Step( 
                goal=lambda self, game: len(filter( lambda turret: turret.install and turret.install.stats==stats.T_SOLAR_0, self.player.flagship.turrets ) ) >= 2 and game.tick-6*config.fps>=self.lastStepAt,
                failure=lambda self, game: not self.player.flagship or not self.player.flagship.alive,
                texts = [ (0,_("Every ship benefits from solar energy the closer they are to a sun.") ),
                    (3*config.fps,_("A solar array will capture even more solar energy but will consume a little when in deep space.") ) ] ),
            Step( 
                goal=lambda self, game: self.player.flagship.jumping,
                failure=lambda self, game: not self.player.flagship or not self.player.flagship.alive,
                texts = [ (0,_("We still need to fill the battery before jumping.")),
                          (3*config.fps, _("Use the long-range sensor in fullscreen mode to see our destination.") ),
                          (6*config.fps, _("Left-click on the Radar button in the upper-left corner.") ),
                          (12*config.fps, _("Notice your poition over Earth. It will be useful to come back.") ),
                          (15*config.fps, _("Mars is the 4th planet from the sun.") ),
                          (18*config.fps, _("You can see it on the right of the asteroid field down left from you.")),
                          (21*config.fps, _("To execute the jump, left-click on the blue button at the top of the screen") ),
                          (24*config.fps, _("the left-click on the destination, the planet Mars.") ), ] ),
            Step( 
                goal=lambda self, game: not self.player.flagship.jumping,
                failure=lambda self, game: not self.player.flagship or not self.player.flagship.alive,
                onBegin=lambda self, game: self.addEnnemyShip( game, self.ennemyPosition ),
                texts = [ ( 0, _("Know that you can change the destination of the jump while it charges.") ),
                          (3*config.fps, _("Go back to normal view by clicking on the radar button again.") ), ] ),
            Step( 
                goal=lambda self, game: utils.distLowerThan( self.ennemyPosition, self.player.flagship.pos, 500 ),
                failure=lambda self, game: not self.player.flagship or not self.player.flagship.alive,
                texts = [ ( config.fps, _("Now head for the asteroid field.") ),
                    ( 4*config.fps, _("Reports are that there is a anormal rotating asteroid towards the bottom of the field.") ),
                    ( 7*config.fps, _("Investigate it.") ) ] ),
            Step( 
                goal=lambda self, game: utils.distLowerThan( self.ennemyPosition, self.player.flagship.pos, 200 ),
                failure=lambda self, game: not self.player.flagship or not self.player.flagship.alive,
                texts = [ ( 0, _("It may be dangerous but get closer to gather data.") ) ] ),
            Step( 
                goal=lambda self, game: self.player.flagship.jumping,
                failure=lambda self, game: not self.player.flagship or not self.player.flagship.alive,
                texts = [ ( 0, _("What ever it is. It is hostile!") ),
                    ( 1*config.fps, _("Enough data collected.") ),
                    ( 2*config.fps, _("Jump away now!") ) ] ),
            Step( 
                goal=lambda self, game: not self.player.flagship.jumping,
                failure=lambda self, game: not self.player.flagship or not self.player.flagship.alive,
                texts = [ ( 0, _("Don't worry, your shield and hull should be able to handle the hits for a little longer.") ) ] ),
            Step( 
                goal=lambda self, game: utils.distLowerThanObjects( self.player.flagship, self.orbitalbase, 2000 ),
                failure=lambda self, game: not self.player.flagship or not self.player.flagship.alive,
                texts = [ ( 1, _("Head back to Earth.") ) ] ),
            Step( 
                goal=lambda self, game: utils.distLowerThanObjects( self.player.flagship, self.orbitalbase, 100 ),
                failure=lambda self, game: not self.player.flagship or not self.player.flagship.alive,
                texts = [ (0, _("Return to the orbital station.")),
                    ( 3*config.fps, _("Collected data will be useful if they ever try to get closer to Earth.") ) ] ),
                ]
        
        Scenario.__init__(self, game, steps=steps, stats=stats )
        
        ### redefining stats, dangerous
        
        self.sol = Sun( game.stats.S_SOL, 0, 0 )
        self.mercury = Planet( game.stats.P_MERCURY, -4100, 1400 )
        self.venus = Planet( game.stats.P_VENUS, 5000, 2300 )
        self.earth = Planet( game.stats.P_EARTH, -3100, 6700 )
        self.mars = Planet( game.stats.P_MARS_1, -7800, -2300 )
        self.moon = Planet( game.stats.P_MOON, -3900, 6400 )
        self.jupiter = Planet( game.stats.P_JUPITER, -13000, -4800 )
        self.saturn = Planet( game.stats.P_SATURN, 13000, 2500 )
        self.neptune = Planet( game.stats.P_NEPTUNE, 15000, 7000 )
        
        self.moon.zp = -50
        self.moon.yi = 0.1
        self.moon.orbiting = self.earth
        

        for i in range( 50 ): # asteroids outer self.mars
            dist = 9000
            angle = (1-2*random())*pi/8+pi*9/8
            asteroid = Asteroid( game, self.sol.xp+dist*cos(angle), self.sol.yp+dist*sin(angle), 300 )
            game.harvestables.append( asteroid )

        for i in range( 60 ): # asteroids between self.saturn and self.neptune
            dist = 15000
            angle = (1-2*random())*pi/10+pi/7
            asteroid = Asteroid( game, self.sol.xp+dist*cos(angle), self.sol.yp+dist*sin(angle), 300 )
            game.harvestables.append( asteroid )
            
        game.astres = [self.sol, self.mercury, self.venus, self.earth, self.moon, self.mars, self.jupiter, self.saturn, self.neptune, self.moon ]
        
        dist = self.earth.stats.maxRadius*1.5
        angle = 5*pi/8
        self.orbitalbase = OrbitalBase( None, game.stats.HUMAN_BASE_MINING, None, self.earth.xp+dist*cos(angle),self.earth.yp+dist*sin(angle))
        self.orbitalbase.ri = -0.013
        game.objects.append( self.orbitalbase )
        
        self.player = None
        self.startingPoint = ( self.orbitalbase.xp+50, self.orbitalbase.yp+60 )
        
        dist = 9000
        angle = pi*9/8+pi/8*2/3
        self.ennemyPosition = ( self.sol.xp+dist*cos(angle), self.sol.yp+dist*sin(angle) )
Esempio n. 5
0
    def __init__(self, game, steps=None, name=None, description=None, year=0):

        stats = Stats()
        stats.R_HUMAN.turrets = [
            stats.T_LASER_SR_1, stats.T_LASER_SR_0, stats.T_MASS_SR_1,
            stats.T_MASS_SR_0, stats.T_MASS_MR_0
        ]
        stats.R_HUMAN.missiles = []
        stats.R_HUMAN.ships = [stats.HARVESTER]
        stats.PlayableShips = {}

        steps = [
            Step(
                goal=lambda self, game: utils.distLowerThanObjects(
                    self.player.flagship, self.asteroid, 300),
                failure=lambda self, game: not self.player.flagship or not self
                .player.flagship.alive,
                #   onBegin=lambda self, game: self.player.flagship.ore = 500,
                texts=[(0, "We need some materials."),
                       (4 * config.fps,
                        "There is an asteroid close to the Moon."),
                       (8 * config.fps, "Get close to it.")]),
            Step(
                goal=lambda self, game: self.player.flagship.ai.launching[
                    self.player.race.defaultHarvester.img],
                failure=lambda self, game: not self.player.flagship or not self
                .player.flagship.alive,
                texts=
                [(0, "Begin collecting raw ore."),
                 (4 * config.fps,
                  "To do so, launch your harvester by pressing the blue arrow button at the bottom of the screen."
                  )]),
            Step(
                goal=lambda self, game: self.player.flagship.oreProcess,
                failure=lambda self, game: not self.player.flagship or not self
                .player.flagship.alive,
                texts=
                [(0, "Now wait for them to bring back the ore."),
                 (6 * config.fps,
                  "Don't worry about the ships following you around."),
                 (10 * config.fps,
                  "They are civilian and while they are under your protection they speed up building processes."
                  )]),
            Step(
                goal=lambda self, game: self.player.flagship.ore >= 100,
                failure=lambda self, game: not self.player.flagship or not self
                .player.flagship.alive,
                texts=[
                    (0,
                     "They have now added the raw ore to the processing queue."
                     ),
                    (4 * config.fps,
                     "Wait a little while and it will be transformed into usable materials."
                     ),
                    (8 * config.fps,
                     "Keep harvesting and processing the ore until you reach 100 material."
                     ),
                    (12 * config.fps,
                     "Notice the moving bars at the bottom right corner of the screen..."
                     ),
                    (14 * config.fps,
                     "they represents the ore being processed."),
                    (18 * config.fps,
                     "once they reach the right, they are usable!"),
                    (22 * config.fps,
                     "They will then be added to the ore stock indicated by the blue gage in the bottom right corner."
                     ),
                ]),
            Step(
                goal=lambda self, game: self.player.flagship.shipyards[
                    self.player.race.defaultHarvester.img].getCount() >= 4,
                failure=lambda self, game: not self.player.flagship or not self
                .player.flagship.alive,
                texts=
                [(0,
                  "You now have enough material to build a new harvester and speed it up!"
                  ),
                 (2 * config.fps,
                  "To do so, click on the icon of the harvester at the bottom of the screen, under the launch button."
                  )]),
            Step(
                goal=lambda self, game: self.player.flagship.ore >= 300,
                failure=lambda self, game: not self.player.flagship or not self
                .player.flagship.alive,
                texts=
                [(0,
                  "Keep harvesting and processing ore util you reach 300 material."
                  ),
                 (4 * config.fps,
                  "It will follow the orders the others already received."),
                 (8 * config.fps,
                  "Notice the blue bar in the upper right corner and the green one in the bottm right..."
                  ),
                 (12 * config.fps,
                  "the blue one represents your shield and the green one your hull."
                  )]),
            Step(
                goal=lambda self, game: len(
                    filter(lambda turret: turret.install, self.player.flagship.
                           turrets)) >= 3,
                failure=lambda self, game: not self.player.flagship or not self
                .player.flagship.alive,
                texts=[
                    (0, "There are rumors of pirates in the area."),
                    (4 * config.fps,
                     "Build one more mass cannon turret on your ship."),
                    (8 * config.fps,
                     "To do so, click on an empty slot on the right of the screen and select an affordable turret."
                     ),
                ]),
            Step(
                goal=lambda self, game: not self.ennemyShip.alive,
                failure=lambda self, game: not self.player.flagship or not self
                .player.flagship.alive,
                onBegin=lambda self, game: (self.addAttackingEnnemy(
                    game, (self.moon.xp - 1500, self.moon.yp
                           - 800), self.player.flagship, "Pirate lambda"
                ), game.setRelationBetween(self.player, self.ennemy, 1)),
                texts=
                [(0, "Defend yourself from the incoming pirate ship."),
                 (4 * config.fps,
                  "To attack it, simply left-click on it once."),
                 (8 * config.fps,
                  "Your crew will aim and fire the turrets."),
                 (12 * config.fps,
                  "You can still help them by manoeuvering the ship so that the ennemy is in range of the turrets."
                  )]),
            Step(goal=lambda self, game: utils.distLowerThanObjects(
                self.player.flagship, self.orbitalbase, 100),
                 failure=lambda self, game: not self.player.flagship or
                 not self.player.flagship.alive,
                 texts=[
                     (0, "Well done!"),
                     (2 * config.fps,
                      "Recall your harvester and return to the orbital base.")
                 ]),
        ]

        Scenario.__init__(self, game, steps=steps, stats=stats)

        ### redefining stats, dangerous

        self.sol = Sun(game.stats.S_SOL, 0, 0)
        self.mercury = Planet(game.stats.P_MERCURY, -4100, 1400)
        self.venus = Planet(game.stats.P_VENUS, 5000, 2300)
        self.earth = Planet(game.stats.P_EARTH, -3100, 6700)
        self.mars = Planet(game.stats.P_MARS_1, -7800, -2300)
        self.moon = Planet(game.stats.P_MOON, -3900, 6400)
        self.jupiter = Planet(game.stats.P_JUPITER, -13000, -4800)
        self.saturn = Planet(game.stats.P_SATURN, 13000, 2500)
        self.neptune = Planet(game.stats.P_NEPTUNE, 15000, 7000)

        self.moon.zp = -50
        self.moon.yi = 0.1
        self.moon.orbiting = self.earth

        # asteroids over the moon, vital to scenario
        for i in xrange(1):
            self.asteroid = Asteroid(game, self.moon.xp - 200,
                                     self.moon.yp + 150, 10)
            game.harvestables.append(self.asteroid)

        for i in xrange(3):  # civilians around self.earth
            dist = randint(100, 800)
            angle = 2 * pi * random()

            (x, y) = (self.earth.xp + dist * cos(angle),
                      self.earth.yp + dist * sin(angle))
            s = Ship(game.stats.CIVILIAN_0, AiCivilian(), x, y, -20)
            game.objects.append(s)

        for i in range(50):  # asteroids outer self.mars
            dist = 9000
            angle = (1 - 2 * random()) * pi / 8 + pi * 9 / 8
            asteroid = Asteroid(game, self.sol.xp + dist * cos(angle),
                                self.sol.yp + dist * sin(angle), 300)
            game.harvestables.append(asteroid)

        game.astres = [
            self.sol, self.mercury, self.venus, self.earth, self.moon,
            self.mars, self.jupiter, self.saturn, self.neptune, self.moon
        ]

        dist = self.earth.stats.maxRadius * 1.5
        angle = 5 * pi / 8
        self.orbitalbase = OrbitalBase(None, game.stats.HUMAN_BASE_MINING,
                                       None, self.earth.xp + dist * cos(angle),
                                       self.earth.yp + dist * sin(angle))
        self.orbitalbase.ri = -0.013
        game.objects.append(self.orbitalbase)

        self.player = None
Esempio n. 6
0
    def __init__(self, game, steps=None, name=None, description=None, year=0):

        stats = Stats()
        stats.R_HUMAN.turrets = [stats.T_SOLAR_0]
        stats.R_HUMAN.missiles = []
        stats.R_HUMAN.ships = []
        stats.PlayableShips = {}

        steps = [
            Step(goal=lambda self, game: game.tick - 9 * config.fps >= self.
                 lastStepAt and self.player.inputs.xc and not utils.
                 distLowerThan((self.player.inputs.xc + self.player.inputs.wc /
                                2, self.player.inputs.yc + self.player.inputs.
                                hc / 2), self.player.flagship.pos, 200),
                 failure=lambda self, game: not self.player.flagship or
                 not self.player.flagship.alive,
                 texts=[
                     (0, _("Look around your ship a bit.")),
                     (config.fps * 3,
                      _("To move the camera, either use the arrow keys...")),
                     (config.fps * 6,
                      _("or click on the radar in the upper left corner."))
                 ]),
            Step(goal=lambda self, game: game.tick - 6 * config.fps >= self.
                 lastStepAt and utils.distLowerThan(
                     (self.player.inputs.xc + self.player.inputs.wc / 2, self.
                      player.inputs.yc + self.player.inputs.hc / 2), self.
                     player.flagship.pos, 2),
                 failure=lambda self, game: not self.player.flagship or
                 not self.player.flagship.alive,
                 texts=[
                     (0, _("Good, now stick the camera to your ship.")),
                     (config.fps * 3,
                      _("To do so, click on the center of the radar.")),
                 ]),
            Step(
                goal=lambda self, game: game.tick - 9 * config.fps >= self.
                lastStepAt and not utils.distLowerThan(
                    self.startingPoint, self.player.flagship.pos, 100),
                failure=lambda self, game: not self.player.flagship or not self
                .player.flagship.alive,
                texts=
                [(0, _("Now move away from the orbital station.")),
                 (3 * config.fps,
                  _("To move the ship, left-click on the destination and your crew will manoeuver towards there."
                    )),
                 (6 * config.fps,
                  _("To give the order to stop, left-click on the ship."))]),
            Step(
                goal=lambda self, game: filter(
                    lambda turret: turret.building == stats.T_SOLAR_0, self.
                    player.flagship.turrets),
                failure=lambda self, game: not self.player.flagship or not self
                .player.flagship.alive,
                texts=
                [(0,
                  _("Let's prepare ourselves before going out to explore.")),
                 (3 * config.fps,
                  _("Jumping uses a lot of energy, so first build 2 solar arrays on your ship."
                    )),
                 (6 * config.fps,
                  _("To do so, left-click on one of the black circle at the right of the screen."
                    )),
                 (9 * config.fps,
                  _("Then select the solar array from the list."))]),
            Step(
                goal=lambda self, game: filter(
                    lambda turret: turret.install and turret.install.stats ==
                    stats.T_SOLAR_0, self.player.flagship.turrets),
                failure=lambda self, game: not self.player.flagship or not self
                .player.flagship.alive,
                texts=
                [(0,
                  _("Well done, it will take a little while for it to be completed."
                    )),
                 (3 * config.fps,
                  _("Begin building the second one right away.")),
                 (9 * config.fps,
                  _("Notice the green bar in the top right corner...")),
                 (12 * config.fps,
                  _("it indicates the proportion of energy in your battery.")),
                 (15 * config.fps,
                  _("The quantity is indicated in green text next to it.."))]),
            Step(
                goal=lambda self, game: len(
                    filter(
                        lambda turret: turret.install and turret.install.stats
                        == stats.T_SOLAR_0, self.player.flagship.turrets)
                ) >= 2 and game.tick - 6 * config.fps >= self.lastStepAt,
                failure=lambda self, game: not self.player.flagship or not self
                .player.flagship.alive,
                texts=
                [(0,
                  _("Every ship benefits from solar energy the closer they are to a sun."
                    )),
                 (3 * config.fps,
                  _("A solar array will capture even more solar energy but will consume a little when in deep space."
                    ))]),
            Step(
                goal=lambda self, game: self.player.flagship.jumping,
                failure=lambda self, game: not self.player.flagship or not self
                .player.flagship.alive,
                texts=[
                    (0,
                     _("We still need to fill the battery before jumping.")),
                    (3 * config.fps,
                     _("Use the long-range sensor in fullscreen mode to see our destination."
                       )),
                    (6 * config.fps,
                     _("Left-click on the Radar button in the upper-left corner."
                       )),
                    (12 * config.fps,
                     _("Notice your poition over Earth. It will be useful to come back."
                       )),
                    (15 * config.fps,
                     _("Mars is the 4th planet from the sun.")),
                    (18 * config.fps,
                     _("You can see it on the right of the asteroid field down left from you."
                       )),
                    (21 * config.fps,
                     _("To execute the jump, left-click on the blue button at the top of the screen"
                       )),
                    (24 * config.fps,
                     _("the left-click on the destination, the planet Mars.")),
                ]),
            Step(
                goal=lambda self, game: not self.player.flagship.jumping,
                failure=lambda self, game: not self.player.flagship or not self
                .player.flagship.alive,
                onBegin=lambda self, game: self.addEnnemyShip(
                    game, self.ennemyPosition),
                texts=[
                    (0,
                     _("Know that you can change the destination of the jump while it charges."
                       )),
                    (3 * config.fps,
                     _("Go back to normal view by clicking on the radar button again."
                       )),
                ]),
            Step(
                goal=lambda self, game: utils.distLowerThan(
                    self.ennemyPosition, self.player.flagship.pos, 500),
                failure=lambda self, game: not self.player.flagship or not self
                .player.flagship.alive,
                texts=
                [(config.fps, _("Now head for the asteroid field.")),
                 (4 * config.fps,
                  _("Reports are that there is a anormal rotating asteroid towards the bottom of the field."
                    )), (7 * config.fps, _("Investigate it."))]),
            Step(goal=lambda self, game: utils.distLowerThan(
                self.ennemyPosition, self.player.flagship.pos, 200),
                 failure=lambda self, game: not self.player.flagship or
                 not self.player.flagship.alive,
                 texts=[
                     (0,
                      _("It may be dangerous but get closer to gather data."))
                 ]),
            Step(goal=lambda self, game: self.player.flagship.jumping,
                 failure=lambda self, game: not self.player.flagship or
                 not self.player.flagship.alive,
                 texts=[(0, _("What ever it is. It is hostile!")),
                        (1 * config.fps, _("Enough data collected.")),
                        (2 * config.fps, _("Jump away now!"))]),
            Step(
                goal=lambda self, game: not self.player.flagship.jumping,
                failure=lambda self, game: not self.player.flagship or not self
                .player.flagship.alive,
                texts=
                [(0,
                  _("Don't worry, your shield and hull should be able to handle the hits for a little longer."
                    ))]),
            Step(goal=lambda self, game: utils.distLowerThanObjects(
                self.player.flagship, self.orbitalbase, 2000),
                 failure=lambda self, game: not self.player.flagship or
                 not self.player.flagship.alive,
                 texts=[(1, _("Head back to Earth."))]),
            Step(
                goal=lambda self, game: utils.distLowerThanObjects(
                    self.player.flagship, self.orbitalbase, 100),
                failure=lambda self, game: not self.player.flagship or not self
                .player.flagship.alive,
                texts=
                [(0, _("Return to the orbital station.")),
                 (3 * config.fps,
                  _("Collected data will be useful if they ever try to get closer to Earth."
                    ))]),
        ]

        Scenario.__init__(self, game, steps=steps, stats=stats)

        ### redefining stats, dangerous

        self.sol = Sun(game.stats.S_SOL, 0, 0)
        self.mercury = Planet(game.stats.P_MERCURY, -4100, 1400)
        self.venus = Planet(game.stats.P_VENUS, 5000, 2300)
        self.earth = Planet(game.stats.P_EARTH, -3100, 6700)
        self.mars = Planet(game.stats.P_MARS_1, -7800, -2300)
        self.moon = Planet(game.stats.P_MOON, -3900, 6400)
        self.jupiter = Planet(game.stats.P_JUPITER, -13000, -4800)
        self.saturn = Planet(game.stats.P_SATURN, 13000, 2500)
        self.neptune = Planet(game.stats.P_NEPTUNE, 15000, 7000)

        self.moon.zp = -50
        self.moon.yi = 0.1
        self.moon.orbiting = self.earth

        for i in range(50):  # asteroids outer self.mars
            dist = 9000
            angle = (1 - 2 * random()) * pi / 8 + pi * 9 / 8
            asteroid = Asteroid(game, self.sol.xp + dist * cos(angle),
                                self.sol.yp + dist * sin(angle), 300)
            game.harvestables.append(asteroid)

        for i in range(60):  # asteroids between self.saturn and self.neptune
            dist = 15000
            angle = (1 - 2 * random()) * pi / 10 + pi / 7
            asteroid = Asteroid(game, self.sol.xp + dist * cos(angle),
                                self.sol.yp + dist * sin(angle), 300)
            game.harvestables.append(asteroid)

        game.astres = [
            self.sol, self.mercury, self.venus, self.earth, self.moon,
            self.mars, self.jupiter, self.saturn, self.neptune, self.moon
        ]

        dist = self.earth.stats.maxRadius * 1.5
        angle = 5 * pi / 8
        self.orbitalbase = OrbitalBase(None, game.stats.HUMAN_BASE_MINING,
                                       None, self.earth.xp + dist * cos(angle),
                                       self.earth.yp + dist * sin(angle))
        self.orbitalbase.ri = -0.013
        game.objects.append(self.orbitalbase)

        self.player = None
        self.startingPoint = (self.orbitalbase.xp + 50,
                              self.orbitalbase.yp + 60)

        dist = 9000
        angle = pi * 9 / 8 + pi / 8 * 2 / 3
        self.ennemyPosition = (self.sol.xp + dist * cos(angle),
                               self.sol.yp + dist * sin(angle))
Esempio n. 7
0
    def __init__(self, game, steps=None, name=None, description=None, year=0):
    
        stats = Stats()
        stats.R_HUMAN.turrets = [ stats.T_LASER_SR_1, stats.T_LASER_SR_0, stats.T_LASER_MR_0,
    stats.T_MASS_SR_1, stats.T_MASS_SR_0, stats.T_MASS_LR, stats.T_MASS_MR_0,
    stats.T_MISSILE_1, stats.T_MISSILE_0,
    stats.T_PULSE, stats.T_MINER, 
    stats.T_SOLAR_0,  ]
        stats.R_HUMAN.missiles = [ids.M_NORMAL, ids.M_PULSE, ids.M_MINER]
        stats.R_HUMAN.ships = [ stats.HARVESTER, stats.HUMAN_FIGHTER ]
        stats.PlayableShips = {}
        
        
        steps = []
        
        ### missiles
        steps.append( Step( 
            goal=lambda self, game: filter( lambda turret: turret.install and turret.install.stats==stats.T_MISSILE_0, self.player.flagship.turrets ),
            failure=lambda self, game: not self.player.flagship or not self.player.flagship.alive,
            onBegin=lambda self, game: self.addEnnemyShip( game, (self.player.flagship.xp+stats.T_MASS_MR_0.weapon.maxRange+100, self.player.flagship.yp), None ),
            texts = [(0,"There's an ennemy ship on the other side of Earth, directly to your right."),
                (config.fps*4, "It is too far away to reach with your current weapons."),
                (config.fps*8, "Select an empty turret, on the right of the screen, and build a missile launcher."),
                (config.fps*16, "It would also be a good idea to begin harvesting the asteroid close by."),
                (config.fps*20, "Build more harvester if you feel that it's necessary." )] ) )
        steps.append( Step( 
            goal=lambda self, game: self.player.flagship.missiles[ids.M_NORMAL].amount >= 10,
            failure=lambda self, game: not self.player.flagship or not self.player.flagship.alive,
            texts = [(0,"Now that the launcher is ready you will need some missiles!"),
                (config.fps*4, "Click on the missile icon at the botom of the screen to start building them."),
                (config.fps*8, "10 should be enough to initiate the combat.") ] ) )
        steps.append( Step( 
            goal=lambda self, game: not self.ennemyShip.alive,
            failure=lambda self, game: not self.player.flagship or not self.player.flagship.alive,
            onBegin=lambda self, game: (game.setRelationBetween( self.player, self.ennemy, 1 ), game.setRelationBetween( self.ennemy, self.player, 1 )),
            texts = [(0,"Now attack it!"),
                (config.fps*4, "It is the blue dot on the radar screen, left-click on it to begin the attack." ) ] ) )
            
        ### mass turret / upgrading
        steps.append( Step( 
            goal=lambda self, game: filter( lambda turret: turret.install and turret.install.stats==stats.T_MASS_LR, self.player.flagship.turrets ),
            failure=lambda self, game: not self.player.flagship or not self.player.flagship.alive,
            onBegin=lambda self, game: self.addEnnemyShip( game, (self.player.flagship.xp+stats.T_MASS_LR.weapon.maxRange-400, self.player.flagship.yp), None ),
            texts = [(0,"One appeared even further away!"),
                (config.fps*4, "Upgrade at least one of your mass cannon to a mass driver turret." ) ] ) )
        steps.append( Step( 
            goal=lambda self, game: not self.ennemyShip.alive,
            failure=lambda self, game: not self.player.flagship or not self.player.flagship.alive,
            onBegin=lambda self, game: (game.setRelationBetween( self.player, self.ennemy, 1 ), game.setRelationBetween( self.ennemy, self.player, 1 )),
            text = "Now that you can reach it, attack it!" ) )
            
        ### fighters
        steps.append( Step( 
            goal=lambda self, game: self.player.flagship.shipyards[ ids.S_HUMAN_FIGHTER ].getCount() >= 5,
            failure=lambda self, game: not self.player.flagship or not self.player.flagship.alive,
            onBegin=lambda self, game: self.addEnnemyShips( game, (self.player.flagship.xp+stats.T_MASS_LR.weapon.maxRange+1000, self.player.flagship.yp), 200, count=2 ),
            texts = [(0,"There's another one too far away for your turrets."),
            (config.fps*4, "You need to build at leats 5 fighters."),
            (config.fps*8, "To do so, click on the fighter icon, at the bottom of the screen next to the harvester." )] ) )
        steps.append( Step( 
            goal=lambda self, game: self.player.flagship.ai.launching[ ids.S_HUMAN_FIGHTER ],
            failure=lambda self, game: not self.player.flagship or not self.player.flagship.alive,
            texts = [(0,"Launch your fighters."),
            (config.fps*4, "To do so, press the blue arrow button at the bottom of the screen." )] ) )
        steps.append( Step( 
            goal=lambda self, game: not self.ennemy.flagships,
            failure=lambda self, game: not self.player.flagship or not self.player.flagship.alive,
            onBegin=lambda self, game: (game.setRelationBetween( self.player, self.ennemy, 1 ), game.setRelationBetween( self.ennemy, self.player, 1 )),
            text = "Now order your fighters to attack it by left-clicking on it." ) )
         
         ### mines
        steps.append( Step( 
            goal=lambda self, game: filter( lambda turret: turret.install and turret.install.stats==stats.T_MINER, self.player.flagship.turrets ),
            failure=lambda self, game: not self.player.flagship or not self.player.flagship.alive,
            texts = [(0, "The pirates always come from the same direction."),
                (config.fps*4, "Let's think ahead and build a mine field."),
                (config.fps*8, "First, build a mine layer turret."),
                (config.fps*12, "It would be a good idea to recall your fighters before laying the mine field."),
                (config.fps*16, "To do so, press  onthe green arrow over the fighter icon." )] ) )
        steps.append( Step( 
            goal=lambda self, game: self.player.flagship.missiles[ids.M_MINER].amount >= 1,
            failure=lambda self, game: not self.player.flagship or not self.player.flagship.alive,
            text = "Build 8 or more miner missiles.\nThe button appeared next to the missile button." ) )
        steps.append( Step( 
            goal=lambda self, game: filter( lambda obj: isinstance( obj, MinerMissile ), game.objects.objects ),
            failure=lambda self, game: not self.player.flagship or not self.player.flagship.alive,
            text = "A missile is ready.\nShoot it by clicking on the red targetting button over its icon.",
            texts= [
    (config.fps*4,"Then click on the target, in this case target at a little distance to the right of the station."),
    (config.fps*8,"You can always cancel the launch of a missile by right clicking on the screen when targetting.")
                    ] ) )
        steps.append( Step( 
            goal=lambda self, game: len( filter( lambda obj: isinstance( obj, Mine ), game.objects.objects ) ) >= stats.T_MINER.specialValue[1]*8,
            failure=lambda self, game: not self.player.flagship or not self.player.flagship.alive,
            text = "Build and deploy a total of at least 8 missiles." ) )
            
         ### pulse
        steps.append( Step( 
            goal=lambda self, game: filter( lambda turret: turret.install and turret.install.stats==stats.T_PULSE, self.player.flagship.turrets ),
            failure=lambda self, game: not self.player.flagship or not self.player.flagship.alive,
           onBegin=lambda self, game: self.addEnnemyShips( game, (self.player.flagship.xp+stats.T_MASS_LR.weapon.maxRange+200, self.player.flagship.yp), 200, count=4 ),
            texts = [(0, "A group of pirates can now be seen far away."),
            (config.fps*4, "To trap them and give us a head start let's hit them with an EMP weapon first!"),
            (config.fps*8, "Build a pulse launcher.") ] ) )
        steps.append( Step( 
            goal=lambda self, game: self.player.flagship.missiles[ids.M_PULSE].amount >= 1,
            failure=lambda self, game: not self.player.flagship or not self.player.flagship.alive,
            text = "Build at least one pulse missile." ) )
        steps.append( Step( 
            goal=lambda self, game: filter( lambda obj: isinstance( obj, PulseMissile ), game.objects.objects ),
            failure=lambda self, game: not self.player.flagship or not self.player.flagship.alive,
            text = "A missile is ready.\nShoot it in the middle of the pirates." ) )
        steps.append( Step( 
            goal=lambda self, game: not filter( lambda obj: isinstance( obj, PulseMissile ), game.objects.objects ),
            failure=lambda self, game: not self.player.flagship or not self.player.flagship.alive,
            onBegin=lambda self, game: (game.setRelationBetween( self.player, self.ennemy, 1 ), game.setRelationBetween( self.ennemy, self.player, 1 )),
            texts = [(0,"Wait for them to get hit."),
            (config.fps*4, "Every ship caught in the explosion will have its engines disabled for a few seconds..."),
            (config.fps*8, "its shield will also be badly hit.")] ) )
        steps.append( Step( 
            goal=lambda self, game: not self.ennemy.flagships,
            failure=lambda self, game: not self.player.flagship or not self.player.flagship.alive,
            texts = [(0,"Wait for them to recover from the EMP and to get caught in the mine field!"),
                (config.fps*4, "Then finish them.")] ) )
            
        
        Scenario.__init__(self, game, steps=steps, stats=stats )
        
        
        self.sol = Sun( game.stats.S_SOL, 0, 0 )
        self.mercury = Planet( game.stats.P_MERCURY, -4100, 1400 )
        self.venus = Planet( game.stats.P_VENUS, 5000, 2300 )
        self.earth = Planet( game.stats.P_EARTH, -3100, 6700 )
        self.mars = Planet( game.stats.P_MARS_1, -7800, -2300 )
        self.moon = Planet( game.stats.P_MOON, -3900, 6400 )
        self.jupiter = Planet( game.stats.P_JUPITER, -13000, -4800 )
        self.saturn = Planet( game.stats.P_SATURN, 13000, 2500 )
        self.neptune = Planet( game.stats.P_NEPTUNE, 15000, 7000 )
        
        self.moon.zp = -50
        self.moon.yi = 0.1
        self.moon.orbiting = self.earth
        
        # asteroids near the station
        for i in xrange( 1 ):
            asteroid = Asteroid( game, self.moon.xp+200, self.moon.yp+430, 0 )
            game.harvestables.append( asteroid )
        
        for i in xrange( 10 ): # civilians around self.earth
            dist = randint( 100, 800 )
            angle = 2*pi*random()

            (x,y) = (self.earth.xp+dist*cos(angle), self.earth.yp+dist*sin(angle))
            s = Ship( game.stats.CIVILIAN_0, AiCivilian(), x, y, -20 )
            game.objects.append( s )

        for i in range( 50 ): # asteroids outer self.mars
            dist = 9000
            angle = (1-2*random())*pi/8+pi*9/8
            asteroid = Asteroid( game, self.sol.xp+dist*cos(angle), self.sol.yp+dist*sin(angle), 300 )
            game.harvestables.append( asteroid )

        game.astres = [self.sol, self.mercury, self.venus, self.earth, self.moon, self.mars, self.jupiter, self.saturn, self.neptune, self.moon ]
        
      #  dist = self.earth.stats.maxRadius*1.2
      #  angle = 7/8*pi
     #   self.orbitalbase = OrbitalBase( None, game.stats.HUMAN_BASE, None, self.earth.xp+dist*cos(angle),self.earth.yp+dist*sin(angle))
      #  self.orbitalbase.ri = -0.013
      #  game.objects.append( self.orbitalbase )
        
        self.player = None