示例#1
0
def draw_walk_path():
	_walk_path = ui_squad_control.WALK_PATH
	
	if not _walk_path:
		return
	
	_width = display.get_surface('life')['width']
	_height = display.get_surface('life')['height']
	_entity = ui_squad_control.get_selected_squad_member()
	_action_points = _entity['stats']['action_points']
	
	for x, y in _walk_path:
		_x = x - camera.X
		_y = y - camera.Y
		
		if _x < 0 or _y < 0 or _x >= _width or _y >= _height:
			continue
		
		if _action_points < 0:
			_fore_color = (200, 0, 0)
			_char = chr(176)
		
		else:
			_fore_color = (200, 200, 200)
			_char = chr(177)
		
		display.write_char('nodes', _x, _y, _char, fore_color=_fore_color)
		_action_points -= constants.IDLE_COST
		_action_points -= movement.get_move_cost(_entity)
示例#2
0
文件: ui_draw.py 项目: penny64/r3-tdw
def draw_walk_path():
    _walk_path = ui_squad_control.WALK_PATH

    if not _walk_path:
        return

    _width = display.get_surface('life')['width']
    _height = display.get_surface('life')['height']
    _entity = ui_squad_control.get_selected_squad_member()
    _action_points = _entity['stats']['action_points']

    for x, y in _walk_path:
        _x = x - camera.X
        _y = y - camera.Y

        if _x < 0 or _y < 0 or _x >= _width or _y >= _height:
            continue

        if _action_points < 0:
            _fore_color = (200, 0, 0)
            _char = chr(176)

        else:
            _fore_color = (200, 200, 200)
            _char = chr(177)

        display.write_char('nodes', _x, _y, _char, fore_color=_fore_color)
        _action_points -= constants.IDLE_COST
        _action_points -= movement.get_move_cost(_entity)
示例#3
0
文件: ai_flow.py 项目: penny64/r3-tdw
def tick():
    if settings.TURN_QUEUE:
        _squads = [settings.TURN_QUEUE[0]]

    else:
        _squads = entities.get_entity_group('squads')
        _found_able_player = False

        for squad_id in entities.get_entity_group('squads'):
            _squad = entities.get_entity(squad_id)
            _break = False

            if not _squad['faction'] == 'Rogues':
                continue

            for member_id in _squad['members']:
                _entity = entities.get_entity(member_id)

                if _entity['ai']['is_npc']:
                    continue

                if timers.has_timer_with_name(
                        _entity, 'shoot') or _entity['movement']['path'][
                            'positions'] or timers.has_timer_with_name(
                                _entity, 'move'):
                    _break = True

                    break

                _found_able_player = True

            if _break:
                break

        else:
            if _found_able_player:
                settings.set_tick_mode('strategy')

    for squad_id in _squads:
        _squad = entities.get_entity(squad_id)
        _waiting = False

        #if not _squad['faction'] == 'Rogues':
        #	settings.set_tick_mode('normal')

        for entity_id in _squad['members']:
            _entity = entities.get_entity(entity_id)

            if not settings.TURN_QUEUE:
                _entity['stats']['action_points'] = _entity['stats'][
                    'action_points_max']

                if _entity['ai']['is_npc']:
                    continue

            if _entity['stats']['action_points'] <= 0:
                continue

            _had_action = False

            if timers.has_timer_with_name(
                    _entity, 'shoot') or _entity['movement']['path'][
                        'positions'] or timers.has_timer_with_name(
                            _entity, 'move'):
                _had_action = True

            elif _entity['ai']['is_player']:
                _waiting = True

                continue

            entities.trigger_event(_entity, 'tick')

            if _had_action and not timers.has_timer_with_name(
                    _entity, 'shoot') and not _entity['movement']['path'][
                        'positions'] and not timers.has_timer_with_name(
                            _entity,
                            'move') and _entity['stats']['action_points'] > 0:
                if _entity['ai']['is_player'] and (
                        ui_squad_control.is_squad_member_selected() and _entity
                        == ui_squad_control.get_selected_squad_member()):
                    settings.set_tick_mode('strategy')

                    break

            if _entity['ai'][
                    'is_player'] and _entity['stats']['action_points'] <= 0:
                ui_squad_control.reset_selected_squad_member()
                settings.set_tick_mode('strategy')

            if not _entity['movement']['path'][
                    'positions'] and not timers.has_timer_with_name(
                        _entity, 'shoot') and not timers.has_timer_with_name(
                            _entity, 'move'):
                _entity['stats']['action_points'] -= constants.IDLE_COST

            if _entity['stats'][
                    'action_points'] <= 0:  # and list(_squad['members']).index(entity_id)+1 == len(_squad['members']):
                entities.trigger_event(_squad, 'update_position_map')

            #print _entity['stats']['name'], _entity['stats']['action_points']

            break

        else:
            if _entity['ai']['is_player'] and not _waiting:
                settings.set_tick_mode('normal')
                print 'Normal...'
示例#4
0
def tick():
	if settings.TURN_QUEUE:
		_squads = [settings.TURN_QUEUE[0]]
	
	else:
		_squads = entities.get_entity_group('squads')
		_found_able_player = False
		
		for squad_id in entities.get_entity_group('squads'):
			_squad = entities.get_entity(squad_id)
			_break = False
			
			if not _squad['faction'] == 'Rogues':
				continue
			
			for member_id in _squad['members']:
				_entity = entities.get_entity(member_id)
				
				if _entity['ai']['is_npc']:
					continue
				
				if timers.has_timer_with_name(_entity, 'shoot') or _entity['movement']['path']['positions'] or timers.has_timer_with_name(_entity, 'move'):
					_break = True
					
					break
				
				_found_able_player = True
			
			if _break:
				break
		
		else:
			if _found_able_player:
				settings.set_tick_mode('strategy')
	
	for squad_id in _squads:
		_squad = entities.get_entity(squad_id)
		_waiting = False
		
		#if not _squad['faction'] == 'Rogues':
		#	settings.set_tick_mode('normal')
		
		for entity_id in _squad['members']:
			_entity = entities.get_entity(entity_id)
			
			if not settings.TURN_QUEUE:
				_entity['stats']['action_points'] = _entity['stats']['action_points_max']
				
				if _entity['ai']['is_npc']:
					continue
			
			if _entity['stats']['action_points'] <= 0:
				continue
			
			_had_action = False
			
			if timers.has_timer_with_name(_entity, 'shoot') or _entity['movement']['path']['positions'] or timers.has_timer_with_name(_entity, 'move'):
				_had_action = True
			
			elif _entity['ai']['is_player']:
				_waiting = True
				
				continue
			
			entities.trigger_event(_entity, 'tick')
			
			if _had_action and not timers.has_timer_with_name(_entity, 'shoot') and not _entity['movement']['path']['positions'] and not timers.has_timer_with_name(_entity, 'move') and _entity['stats']['action_points'] > 0:
				if _entity['ai']['is_player'] and (ui_squad_control.is_squad_member_selected() and _entity == ui_squad_control.get_selected_squad_member()):
					settings.set_tick_mode('strategy')
					
					break
			
			if _entity['ai']['is_player'] and _entity['stats']['action_points'] <= 0:
				ui_squad_control.reset_selected_squad_member()
				settings.set_tick_mode('strategy')
			
			if not _entity['movement']['path']['positions'] and not timers.has_timer_with_name(_entity, 'shoot') and not timers.has_timer_with_name(_entity, 'move'):
				_entity['stats']['action_points'] -= constants.IDLE_COST
			
			if _entity['stats']['action_points'] <= 0:# and list(_squad['members']).index(entity_id)+1 == len(_squad['members']):
				entities.trigger_event(_squad, 'update_position_map')
			
			#print _entity['stats']['name'], _entity['stats']['action_points']
			
			break
		
		else:
			if _entity['ai']['is_player'] and not _waiting:
				settings.set_tick_mode('normal')
				print 'Normal...'