bool CMusicRoomHandler::pollInstrument(MusicInstrument instrument) {
	int &arrIndex = _startPos[instrument];
	if (arrIndex < 0) {
		_instruments[instrument]->clear();
		return false;
	}

	const CMusicSong &song = *_songs[instrument];
	if (arrIndex >= song.size()) {
		arrIndex = -1;
		_instruments[instrument]->clear();
		return false;
	}

	const CValuePair &vp = song[arrIndex];
	uint duration = static_cast<int>(getAnimDuration(instrument, arrIndex) * 44100.0) & ~1;

	if (vp._data == 0x7FFFFFFF || _array1[instrument]._muteControl)
		_instruments[instrument]->reset(duration);
	else
		_instruments[instrument]->chooseWaveFile(getPitch(instrument, arrIndex), duration);

	if (_array1[instrument]._directionControl == _array2[instrument]._directionControl) {
		++arrIndex;
	} else {
		--arrIndex;
	}

	return true;
}
示例#2
0
文件: CmdPlayer.cpp 项目: korman/Temp
CommandX* CommandPlayer::defence( float _duration, NDNode* _owner, const char* _anim )
{
	m_eCommandType = E_CMD_PLAYER_DEFENCE;
	m_pkOwnerNode = _owner;
	m_strAnimationName = _anim;
	m_fDuration = getAnimDuration(_duration, _anim, E_PLAYER_ANIMGRP_DEFENCE);
	return this;
}
示例#3
0
文件: CmdPlayer.cpp 项目: korman/Temp
CommandX* CommandPlayer::playAnim( float _duration, NDNode* _owner, const char* _anim )
{
	m_eCommandType = E_CMD_PLAYER_PLAY_ANIM;
	m_pkOwnerNode = _owner;
	m_strAnimationName = _anim;
	m_fDuration = getAnimDuration(_duration, _anim, E_PLAYER_ANIMGRP_MISC);
	return this;
}
void CMusicRoomHandler::updateInstruments() {
	uint currentTicks = g_system->getMillis();

	if (_active && _soundStartTicks) {
		for (MusicInstrument instrument = BELLS; instrument <= BASS;
				instrument = (MusicInstrument)((int)instrument + 1)) {
			MusicRoomInstrument &ins1 = _array1[instrument];
			MusicRoomInstrument &ins2 = _array2[instrument];
			CMusicRoomInstrument *ins = _instruments[instrument];

			// Is this about checking playback position?
			if (_position[instrument] < 0 || ins1._muteControl || _position[instrument] >= _songs[instrument]->size()) {
				_position[instrument] = -1;
				continue;
			}

			double time = (double)(currentTicks - _soundStartTicks) / 1000.0 - 0.6;
			double threshold = _animExpiryTime[instrument] - ins->_insStartTime;

			if (time >= threshold) {
				_animExpiryTime[instrument] += getAnimDuration(instrument, _position[instrument]);

				const CValuePair &vp = (*_songs[instrument])[_position[instrument]];
				if (vp._data != 0x7FFFFFFF) {
					int amount = getPitch(instrument, _position[instrument]);
					_instruments[instrument]->update(amount);
				}

				if (ins1._directionControl == ins2._directionControl) {
					_position[instrument]++;
				} else {
					_position[instrument]--;
				}
			}
		}
	}
}