void FieldCutscene::UpdateCharacters(int delta, vector<HeightMap *> *pHeightMapList)
{
    vector<PositionalSound> soundsToPlayList;

    if (GetIsFinished() || (pCurrentPhase != NULL && pCurrentPhase->GetAllowsCharacterUpdates()))
    {
        for (map<string, FieldCharacter *>::iterator iter = idToCharacterMap.begin(); iter != idToCharacterMap.end(); ++iter)
        {
            iter->second->UpdateAnimation(delta);
            iter->second->SetExtraHeightFromHeightMaps(pHeightMapList);
            AnimationSound *pSoundToPlay = iter->second->GetSoundToPlay();

            if (pSoundToPlay != NULL)
            {
                soundsToPlayList.push_back(PositionalSound(pSoundToPlay, iter->second->GetMidPoint()));
            }
        }
    }

    for (unsigned int i = 0; i < soundsToPlayList.size(); i++)
    {
        AnimationSound *pSoundToPlay = soundsToPlayList[i].pSound;
        Vector2 soundOriginPosition = soundsToPlayList[i].location;

        double distanceToOrigin = (soundOriginPosition - currentCameraPosition).Length();
        double zeroDistance = max(gScreenWidth, gScreenHeight);//sqrt(gScreenWidth * gScreenWidth + gScreenHeight * gScreenHeight);
        double volume = max(0.0, 1.0 - distanceToOrigin / zeroDistance);

        pSoundToPlay->Play(volume);
    }
}
void Video::Frame::Update(int delta)
{
    AnimationSound *pSoundToPlay = GetSoundToPlay();

    if (pSoundToPlay != NULL)
    {
        pSoundToPlay->Play(gSoundEffectsVolume);
    }

    elapsedDuration += delta;
}
void Button::Update(int delta)
{
    isMouseOver = false;
    isMouseDown = false;

    if (pOutEase->GetIsStarted() && !pOutEase->GetIsFinished())
    {
        pOutEase->Update(delta);
        animationOffset = (int)pOutEase->GetCurrentValue();
    }
    else if (pOutEase->GetIsFinished())
    {
        SetIsHidden(true);
    }
    else if (pInEase->GetIsStarted() && !pInEase->GetIsFinished())
    {
        pInEase->Update(delta);
        animationOffset = (int)pInEase->GetCurrentValue();
    }
    else
    {
        if (GetUnlockedLockCount() > 0 && !pUnlockingAnimation->IsFinished())
        {
            pUnlockingAnimation->Update(delta);

            AnimationSound * pSoundToPlay = pUnlockingAnimation->GetSoundToPlay();

            if (pSoundToPlay != NULL)
            {
                pSoundToPlay->Play(gSoundEffectsVolume);
            }
        }
        else if (!GetIsDisabled())
        {
            RectangleWH positionRect = RectangleWH(GetXPosition(), GetYPosition(), pTextFont->GetWidth(GetText()), TextHeight);
            bool isPressed = MouseHelper::PressedAndHeldAnywhere() || MouseHelper::DoublePressedAndHeldAnywhere();

            if (MouseHelper::ClickedOnRect(positionRect))
            {
                OnClicked();
            }

            if (MouseHelper::MouseDownOnRect(positionRect) && !isPressed)
            {
                isMouseDown = true;
            }
            else if (MouseHelper::MouseOverRect(positionRect) && !isPressed)
            {
                isMouseOver = true;
            }
        }
    }
}
Exemple #4
0
	//---------------------------------------------------------------------
	Skill & Skill::operator = (const Skill &rhs)
	{
		removeAllAnimationEffectInfos();

		// Copy effect infos
		unsigned int i;
		for(i = 0; i < rhs.getNumAnimationEffectInfos(); ++i)
		{
			AnimationEffectInfo *rhsAEI = rhs.getAnimationEffectInfo(i);
			AnimationEffectInfo *newAEI = addAnimationEffectInfo();

			assert ( rhsAEI && newAEI );

		//	rhsAEI->copyParametersTo(newAEI);
            rhsAEI->copyParameters(*newAEI);
		}

		removeAllAnimationRibbons();

		// copy ribbons
		for(i = 0; i < rhs.getNumAnimationRibbons(); ++i)
		{
			AnimationRibbon *rhsAEI = rhs.getAnimationRibbon(i);
			AnimationRibbon *newAEI = addAnimationRibbon();

			assert ( rhsAEI && newAEI );

		//	rhsAEI->copyParametersTo(newAEI);
            rhsAEI->copyParameters(*newAEI);
		}

		removeAllAnimationSounds();

		// copy sounds
		for(i = 0; i < rhs.getNumAnimationSounds(); ++i)
		{
			AnimationSound *rhsAEI = rhs.getAnimationSound(i);
			AnimationSound *newAEI = addAnimationSound();

			assert ( rhsAEI && newAEI );
            rhsAEI->copyParameters(*newAEI);
		}

        removeAllAnimationSceneLightInfos();

        // Copy light infos
        for(i = 0; i < rhs.getNumAnimationSceneLightInfos(); ++i)
        {
            AnimationSceneLightInfo *rhsAEI = rhs.getAnimationSceneLightInfo(i);
            AnimationSceneLightInfo *newAEI = addAnimationSceneLightInfo();

            assert ( rhsAEI && newAEI );

            rhsAEI->copyParameters(*newAEI);
        }

		 removeAllAnimationBulletFlows();

        // Copy blullet flows
        for(i = 0; i < rhs.getNumAnimationBulletFlows(); ++i)
        {
            AnimationBulletFlow *rhsAEI = rhs.getAnimationBulletFlow(i);
            AnimationBulletFlow *newAEI = addAnimationBulletFlow();

            assert ( rhsAEI && newAEI );

            rhsAEI->copyParameters(*newAEI);
        }

		removeAllAnimationCameraShakes();
		// Copy camera shakes
		for(i = 0; i < rhs.getNumAnimationCameraShake(); ++i)
		{
			AnimationCameraShake *rhsAEI = rhs.getAnimationCameraShake(i);
			AnimationCameraShake *newAEI = addAnimationCameraShake();

			assert ( rhsAEI && newAEI );

			rhsAEI->copyParameters(*newAEI);
		}

		// copy skill parameter
	//	rhs.copyParametersTo(this);
        rhs.copyParameters(this);

		return *this;
	}