Exemple #1
0
    def select(self, player):
        '''
        This method observes the events on the planet and calls the related methods
        and notifies the corresponding objects based on the state of the planet
        @param player, the player who has selected
        '''
        player.selected_star = None
        
        if(not self.activated and player.selected_planet == self):
            if((self.prev_planet == None or self.prev_planet.activated) and \
                    self.parent_star.activated and self.parent_star.player == player):
                self.activatePlanet(player)
        else:
#            from gameEngine.gameEngine import all_stars 
#            for star in all_stars:
#                star.deactivateHighlight()
            from gameEngine.gameEngine import all_planets
            for planet in all_planets:
                if(self != planet or self.next_planet != planet or self.prev_planet != planet):
                    planet.deactivateHighlight()
            if self.next_planet != None: self.next_planet.activateHighlight(True) 
            if self.prev_planet != None: self.prev_planet.activateHighlight(True)
            self.activateHighlight(False)
        
        player.selected_planet = self
        
        from gameEngine.gameEngine import updateGUI
        updateGUI.refreshUnitsAndConstructions(self)
 def __init__(self, host_planet):
     '''
     Constructor
     '''
     super(Forge, self).__init__(FORGE_MAX_ENERGY, host_planet)
     self.host_planet.setTexture("forge")
     from gameModel.ai import AI
     if(type(host_planet.player) != AI):
         if(host_planet == host_planet.player.selected_planet):
             from gameEngine.gameEngine import updateGUI
             updateGUI.refreshUnitsAndConstructions(host_planet)
 def __init__(self, energy, host_planet):
     '''
     Constructor
     @param energy: Structure's energy
     @param host_planet : The planet where the structure is constructed on
     '''
     self.energy = energy
     self.host_planet = host_planet
     self.host_planet.addSurfaceStructure(self)
     from gameModel.ai import AI
     if(type(host_planet.player) != AI):
         if(host_planet == host_planet.player.selected_planet):
             from gameEngine.gameEngine import updateGUI
             updateGUI.refreshUnitsAndConstructions(host_planet)
             updateGUI.paintConstructionPanel(host_planet)
Exemple #4
0
 def changePlayer(self, player):
     '''
     Change the control of the planet from the self.player to the parameter player
     @param player: Player, the player who has captured the planet by swarms
     @precondition: the player must have used the capture ability of a swarm type unit on the planet
     '''
     '''TODO: Use makeArc to change the color of the orbit'''
     
     ''' stop any constructions on the planet '''
     if(self.task_structure_timer != None):
         taskMgr.remove(self.task_structure_timer)
         self.task_structure_timer = None
     if(self.task_unit_timer != None):
         taskMgr.remove(self.task_unit_timer)
         self.task_unit_timer = None
     if(self.task_structure_timers != None):
         taskMgr.remove(self.task_structure_timers)
         self.task_structure_timers = None
     if(self.task_unit_timers != None):
         taskMgr.remove(self.task_unit_timers)
         self.task_unit_timers = None
     ''' remove previous player's control from the planet '''
     for structure in self.structures():
         self.player.structures.remove(structure)
     ''' set control of the planet to the new player '''
     for structure in self.structures():
         player.structures.append(structure)
     ''' update the construction panel for the human player'''
     from gameModel.ai import AI
     ''' if human player is the previous owner '''
     if(type(self.player) != AI):
         from gameEngine.gameEngine import updateGUI
         updateGUI.refreshUnitsAndConstructions(self)
     ''' give total control to new player '''
     self.player = player
     ''' if human player is the new owner '''
     if(type(player) != AI):
         from gameEngine.gameEngine import updateGUI
         updateGUI.refreshUnitsAndConstructions(self)
Exemple #5
0
    def activatePlanet(self, player):
        '''
        Activates a constructed dead planet object, starting the orbital movement with the assigned value while
        the Game Engine calls the graphic engine to display the corresponding animation.
        @param player: Player, the player who controls the planet
        @precondition: MIN_PLANET_VELOCITY < orbital_velocity < MAX_PLANET_VELOCITY
        '''
        self.activated = True
        player.planets.append(self)
        self.player = player
        
        
        planet_created_sound = base.loader.loadSfx("sound/effects/planet/planetCreation.wav")
        planet_created_sound.setVolume(0.3)
        planet_created_sound.play()
#        base.sfxManagerList[0].update()
#        SphericalBody.planet_created_sound.play()
        
        self.radius = MAX_PLANET_RADIUS
        self.model_path.setScale(self.radius)
        
        '''TODO : display planet creation animation '''
        
        #rand = random.randrange(1,8,1)
        self.model_path.setTexture(SphericalBody.planet_activated_tex, 1)
        self.startSpin()
        
        # We want to avoid adding this task when the 'collapseOrbit' is already running
        if self.parent_star.lifetime != 0:
            taskMgr.add(self._accelerateOrbit, 'accelerateOrbit')
        
        self.orbit_path = shapes.makeArc(self.player.color, 360, int(self.orbital_radius))
        self.orbit_path.reparentTo(self.parent_star.point_path)
        self.orbit_path.setScale(self.orbital_radius)
        
        from gameModel.ai import AI
        if(type(self.player) != AI):
            from gameEngine.gameEngine import updateGUI
            updateGUI.refreshUnitsAndConstructions(self)
 def incrementLevel(self, player):
     self._level = self._level + 1 if self._level < 4 else self._level
     if(player.selected_planet != None):
         from gameEngine.gameEngine import updateGUI
         updateGUI.refreshUnitsAndConstructions(player.selected_planet)