Exemplo n.º 1
0
void Speech::stopOtherSpeechesFromSameCharacter() {
	Level *globalLevel = StarkGlobal->getLevel();
	Level *currentLevel = StarkGlobal->getCurrent()->getLevel();
	Location *currentLocation = StarkGlobal->getCurrent()->getLocation();

	Common::Array<Speech *> globalLevelSpeeches = globalLevel->listChildrenRecursive<Speech>();
	Common::Array<Speech *> currentLevelSpeeches = currentLevel->listChildrenRecursive<Speech>();
	Common::Array<Speech *> currentLocationSpeeches = currentLocation->listChildrenRecursive<Speech>();

	Common::Array<Speech *> speeches;
	speeches.push_back(globalLevelSpeeches);
	speeches.push_back(currentLevelSpeeches);
	speeches.push_back(currentLocationSpeeches);

	for (uint i = 0; i < speeches.size(); i++) {
		Speech *speech = speeches[i];
		if (speech->_character == _character && speech->isPlaying()) {
			speech->stop();
		}
	}
}
Exemplo n.º 2
0
void Script::updateSuspended() {
	if (_pauseTimeLeft >= 0) {
		// Decrease the remaining pause time
		_pauseTimeLeft -= StarkGlobal->getMillisecondsPerGameloop();
	} else {
		_pauseTimeLeft = -1;
	}

	if (_nextCommand->getSubType() == Command::kScriptPauseSkippable
			&& (StarkUserInterface->wasInteractionDenied() || _pauseTimeLeft < 0)) {
		StarkUserInterface->setInteractive(true);
		_pauseTimeLeft = -1;
	}

	if (_nextCommand->getSubType() == Command::kItemSetActivity && _pauseTimeLeft < 0) {
		_nextCommand->resumeItemSetActivity();
	}

	bool commandChanged = false;

	if (_suspendingResource) {
		// Check if the suspending resource is still active
		switch (_suspendingResource->getType().get()) {
		case Type::kDialog: {
			if (!StarkDialogPlayer->isRunning()) {
				// Resume the script execution if the dialog is complete
				_suspendingResource = nullptr;
			}
			break;
		}
		case Type::kFMV: {
			// Scripts are not running during an FMV, if we are here, then it has stopped playing
			_suspendingResource = nullptr;
			break;
		}
		case Type::kSoundItem: {
			Sound *soundItem = Object::cast<Sound>(_suspendingResource);
			if (!soundItem->isPlaying()) {
				// Resume the script execution once the sound has stopped playing
				_suspendingResource = nullptr;
			}
			break;
		}
		case Type::kSpeech: {
			Speech *speech = Object::cast<Speech>(_suspendingResource);
			if (!speech->isPlaying()) {
				// Resume the script execution once the speech has stopped playing
				_suspendingResource = nullptr;
			}
			break;
		}
		case Type::kScroll: {
			Scroll *scroll = Object::cast<Scroll>(_suspendingResource);
			if (!scroll->isActive()) {
				// Resume the script execution once the scroll target position is reached
				_suspendingResource = nullptr;
			}
			break;
		}
		case Type::kItem: {
			if (_nextCommand->getSubType() == Command::kWalkTo) {
				if (_resumeStatus == kResumeComplete) {
					// Resume the script execution once the item has stopped its movement
					_suspendingResource = nullptr;
					_nextCommand = _nextCommand->nextCommandIf(false);
					commandChanged = true;
				} else if (_resumeStatus == kResumeAbort) {
					// Resume the script execution once the item has stopped its movement
					_suspendingResource = nullptr;
					_nextCommand = _nextCommand->nextCommandIf(true);
					commandChanged = true;
				}
			} else {
				if (_resumeStatus != kResumeSuspend) {
					// Resume the script execution once the item has stopped its movement
					_suspendingResource = nullptr;
				}
			}
			break;
		}
		default:
			error("Unhandled suspending resource type %s", _suspendingResource->getType().getName());
		}
	}

	if (!isSuspended() && _shouldResetGameSpeed) {
		StarkGlobal->setNormalSpeed();
	}

	if (!isSuspended() && !commandChanged) {
		// Resume to the next command
		goToNextCommand();
	}
}