コード例 #1
0
void CameraZone::Update() {
	_was_camera_inside = _camera_inside;
	_was_player_sprite_inside = _player_sprite_inside;

	VirtualSprite* camera = MapMode::CurrentInstance()->GetCamera();
	if (camera == NULL) {
		_camera_inside = false;
	}
	// Camera must share a context with the zone and be within its borders
	else if ((_active_contexts & camera->GetContext()) && (IsInsideZone(camera->x_position, camera->y_position) == true)) {
		_camera_inside = true;
	}
	else {
		_camera_inside = false;
	}

	VirtualSprite* player = MapMode::CurrentInstance()->GetPlayerSprite();
	if (player == NULL) {
		_player_sprite_inside = false;
	}
	// Camera must share a context with the zone and be within its borders
	else if ((_active_contexts & player->GetContext()) && (IsInsideZone(player->x_position, player->y_position) == true)) {
		_player_sprite_inside = true;
	}
	else {
		_player_sprite_inside = false;
	}
}
コード例 #2
0
ファイル: map_zones.cpp プロジェクト: NemesisDD/ValyriaTear
void ResidentZone::AddPotentialResident(VirtualSprite* sprite) {
	if (sprite == NULL) {
		IF_PRINT_WARNING(MAP_DEBUG) << "function received NULL argument" << endl;
		return;
	}

	// Check that sprite is not already a resident
	if (IsSpriteResident(sprite) == true) {
		return;
	}

	// Check that the sprite's context is compatible with this zone and is located within the zone boundaries
	if (sprite->GetContext() & _active_contexts) {
		if (IsInsideZone(sprite->GetXPosition(), sprite->GetYPosition())) {
			_entering_residents.insert(sprite);
			_residents.insert(sprite);
		}
	}
}
コード例 #3
0
ファイル: map_zones.cpp プロジェクト: NemesisDD/ValyriaTear
void CameraZone::Update() {
	_was_camera_inside = _camera_inside;

	// Update only if camera is on a real sprite
	if (MapMode::CurrentInstance()->IsCameraOnVirtualFocus()) {
		return;
	}

	VirtualSprite* camera = MapMode::CurrentInstance()->GetCamera();
	if (camera == NULL) {
		_camera_inside = false;
	}
	// Camera must share a context with the zone and be within its borders
	else if ((_active_contexts & camera->GetContext())
			&& (IsInsideZone(camera->GetXPosition(), camera->GetYPosition()))) {
		_camera_inside = true;
	}
	else {
		_camera_inside = false;
	}
}
コード例 #4
0
void ResidentZone::Update() {
	_entering_residents.clear();
	_exiting_residents.clear();

	// Holds a list of sprites that should be removed from the resident zone. This is necessary because we can't iterate through
	// the resident list and erase former residents without messing up the set iteration.
	vector<VirtualSprite*> remove_list;

	// Examine all residents to see if they still reside in the zone. If not, move them to the exiting residents list
	for (set<VirtualSprite*>::iterator i = _residents.begin(); i != _residents.end(); i++) {
		// Make sure that the resident is still in a context shared by the zone and located within the zone boundaries
		if ((((*i)->GetContext() & _active_contexts) == 0x0) || (IsInsideZone((*i)->x_position, (*i)->y_position) == false)) {
			remove_list.push_back(*i);
		}
	}

	for (uint32 i = 0; i < remove_list.size(); i++) {
		_exiting_residents.insert(remove_list[i]);
		_residents.erase(remove_list[i]);
	}
}