Exemplo n.º 1
0
def generate():
	logging.info('Generating world...')
	
	ai_factions.boot()
	ai_squads.boot()
	ai_flow.boot()
	
	_weight_map, _tile_map, _solids, _node_grid = mapgen.create_map(constants.STRAT_MAP_WIDTH/constants.MAP_CELL_SPACE, constants.STRAT_MAP_HEIGHT/constants.MAP_CELL_SPACE)
	
	_ownable_plots = create_map()
	create_bases(_ownable_plots)
	create_factions()
	
	_node_sets = {}
	_fsl = {}
	world_strategy.MAP
	
	for y in range(0, constants.STRAT_MAP_HEIGHT):
		for x in range(0, constants.STRAT_MAP_WIDTH):
			_m_x = x / constants.MAP_CELL_SPACE
			_m_y = y / constants.MAP_CELL_SPACE
			#_camp = world_strategy.MAP['grid'][_m_x, _m_y]
			_tile_map[_m_y][_m_x] = tiles.grass(_m_x, _m_y)
	
	_zone_id = zones.create('arena', constants.STRAT_MAP_WIDTH/constants.MAP_CELL_SPACE, constants.STRAT_MAP_HEIGHT/constants.MAP_CELL_SPACE, _node_grid, _node_sets, _weight_map, _tile_map, {}, _fsl, {}, {}, [], [])
	zones.activate(_zone_id)
Exemplo n.º 2
0
def _start_battle(attacking_squads=[], defending_squads=[]):
	global FADER
	
	create()
	
	_width, _height, _node_grid, _node_sets, _weight_map, _tile_map, _solids, _fsl, _trees, _inside, _lights, _spawns = mapgen_arena.generate(200, 200)
	_zone = zones.create('swamps', _width, _height, _node_grid, _node_sets, _weight_map, _tile_map, _solids, _fsl, _trees, _inside, _lights, _spawns)
	_attacking_spawn_x, _attacking_spawn_y = random.choice(list(_spawns['attacking']))
	_attacking_spawn_positions = [(x, y) for x, y in shapes.circle(_attacking_spawn_x, _attacking_spawn_y, 5) if not (x, y) in _solids]
	
	for squad_id in attacking_squads:
		_squad = entities.get_entity(squad_id)
		
		for member_id in _squad['members']:
			_member = entities.get_entity(member_id)
			_spawn_x, _spawn_y = _attacking_spawn_positions.pop(random.randint(0, len(_attacking_spawn_positions) - 1))
			
			entities.trigger_event(_member, 'set_position', x=_spawn_x, y=_spawn_y)
	
	_defending_spawn_x, _defending_spawn_y = random.choice(list(_spawns['defending']))
	_attacking_spawn_positions = [(x, y) for x, y in shapes.circle(_defending_spawn_x, _defending_spawn_y, 5) if not (x, y) in _solids]
	
	for squad_id in defending_squads:
		_squad = entities.get_entity(squad_id)
		
		for member_id in _squad['members']:
			_member = entities.get_entity(member_id)
			_spawn_x, _spawn_y = _attacking_spawn_positions.pop(random.randint(0, len(_attacking_spawn_positions) - 1))
			
			entities.trigger_event(_member, 'set_position', x=_spawn_x, y=_spawn_y)

	zones.activate(_zone)
	
	FADER = entities.create_entity()
	timers.register(FADER)
	fade_in()
	
	display.blit_background('tiles')
	
	while loop():
		events.trigger_event('cleanup')
Exemplo n.º 3
0
def _start_battle(attacking_squads=[], defending_squads=[]):
    global FADER

    create()

    _width, _height, _node_grid, _node_sets, _weight_map, _tile_map, _solids, _fsl, _trees, _inside, _lights, _spawns = mapgen_arena.generate(
        200, 200)
    _zone = zones.create('swamps', _width, _height, _node_grid, _node_sets,
                         _weight_map, _tile_map, _solids, _fsl, _trees,
                         _inside, _lights, _spawns)
    _attacking_spawn_x, _attacking_spawn_y = random.choice(
        list(_spawns['attacking']))
    _attacking_spawn_positions = [
        (x, y)
        for x, y in shapes.circle(_attacking_spawn_x, _attacking_spawn_y, 5)
        if not (x, y) in _solids
    ]

    for squad_id in attacking_squads:
        _squad = entities.get_entity(squad_id)

        for member_id in _squad['members']:
            _member = entities.get_entity(member_id)
            _spawn_x, _spawn_y = _attacking_spawn_positions.pop(
                random.randint(0,
                               len(_attacking_spawn_positions) - 1))

            entities.trigger_event(_member,
                                   'set_position',
                                   x=_spawn_x,
                                   y=_spawn_y)

    _defending_spawn_x, _defending_spawn_y = random.choice(
        list(_spawns['defending']))
    _attacking_spawn_positions = [
        (x, y)
        for x, y in shapes.circle(_defending_spawn_x, _defending_spawn_y, 5)
        if not (x, y) in _solids
    ]

    for squad_id in defending_squads:
        _squad = entities.get_entity(squad_id)

        for member_id in _squad['members']:
            _member = entities.get_entity(member_id)
            _spawn_x, _spawn_y = _attacking_spawn_positions.pop(
                random.randint(0,
                               len(_attacking_spawn_positions) - 1))

            entities.trigger_event(_member,
                                   'set_position',
                                   x=_spawn_x,
                                   y=_spawn_y)

    zones.activate(_zone)

    FADER = entities.create_entity()
    timers.register(FADER)
    fade_in()

    display.blit_background('tiles')

    while loop():
        events.trigger_event('cleanup')