Overview Package Class Source Class tree Glossary
previous class      next class frames      no frames

UnrealShare.TriggeredAmbientSound


00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047
00048
00049
00050
00051
00052
00053
00054
00055
00056
00057
00058
00059
00060
00061
00062
00063
00064
00065
00066
00067
00068
00069
00070
00071
00072
00073
00074
00075
00076
00077
00078
00079
00080
00081
00082
00083
00084
00085
//=============================================================================
// TriggeredAmbientSound.
//=============================================================================
class TriggeredAmbientSound extends Keypoint;

// Re-plays a sound effect if triggered.  If in state TriggerToggled,
// the sound is turned off if triggered, and turned on, etc..
// when triggered again.  In the OnWhileTriggered state, the instigator
// must stay within the trigger's radius for the sound effect to continue
// playing.  bInitiallyOn determines if the sound is playing from the 
// start, and does not apply in the OnWhileTriggered state.  A variance
// can also be set for the timing, so that the replay time can seem
// more 'real'.

var() bool  bInitiallyOn;
var() sound AmbSound;
var() float rePlayTime;
var() float rePlayVariance;
var() bool  bPlayOnceOnly;

var   bool  bIsOn;
var   bool  bPlayedOnce;

function BeginPlay () {
    
    local float timeDelta;
    
    if (bInitiallyOn) {
        PlaySound (AmbSound, , Float(SoundVolume)/128, , Float(SoundRadius)*25);
        bIsOn = true;
    }

    timeDelta = (rePlayVariance*2)*FRand() - rePlayVariance + rePlayTime;
    SetTimer(timeDelta, False);
}


function Timer () {

    local float timeDelta;
    
    if ( (bIsOn && !bPlayOnceOnly) || (bIsOn && bPlayOnceOnly && !bPlayedOnce) ) {
    
        // Replay the sound
        // Which sound should be played?
        PlaySound (AmbSound, , Float(SoundVolume)/128, , Float(SoundRadius)*25);
        bPlayedOnce = true;
    }

    timeDelta = (rePlayVariance*2)*FRand() - rePlayVariance + rePlayTime;
    SetTimer(timeDelta, False);
}


state() TriggerToggled
{
    function Trigger( actor Other, pawn EventInstigator )
    {
        bIsOn = !bIsOn;
        bPlayedOnce = false;
    }
}


state() OnWhileTriggered
{
    function Trigger( actor Other, pawn EventInstigator )
    {
        bIsOn = true;
        bPlayedOnce = false;
    }

    function UnTrigger( actor Other, pawn EventInstigator )
    {
        bIsOn = false;
    }

Begin:
    bIsOn = false;
}

defaultproperties
{
}

Overview Package Class Source Class tree Glossary
previous class      next class frames      no frames
Class file time: za 22-4-2006 13:27:48.000 - Creation time: za 22-4-2006 13:29:31.500 - Created with UnCodeX