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

UnrealShare.DynamicAmbientSound


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
//=============================================================================
// DynamicAmbientSound.
//=============================================================================
class DynamicAmbientSound extends Keypoint;

var() bool       bInitiallyOn;      // Initial state
var() sound      Sounds[16];        // What to play (must be at least one sound)
var() float      playProbability;   // The chance of the sound effect playing
var() float      minReCheckTime;   // Try to restart the sound after (min amount)
var() float      maxReCheckTime;   // Try to restart the sound after (max amount)
var() bool       bDontRepeat;       // Never play two of the same sound in a row
var   bool       soundPlaying;      // Is it currently playing it?
var   float      rePlayTime;
var   int        numSounds;     // The number of sounds available
var   int        lastSound;     // Which sound was played most recently?

function BeginPlay () 
{
    
    local int i;
    
    // Calculate how many sounds the user specified
    numSounds=6;
    for (i=0; i<16; i++) 
    {
        if (Sounds[i] == None) 
        {
            numSounds=i;
            break;
        }
    }

    lastSound=-1;
    if (bInitiallyOn) 
    {
        // Which sound should be played?
        i = Rand(numSounds);
        PlaySound (Sounds[i]);
        lastSound = i;
    }

    rePlayTime = (maxReCheckTime-minReCheckTime)*FRand() + minReCheckTime;
    SetTimer(rePlayTime, False);
}


function Timer () 
{

    local int i;
    
    if (FRand() <= playProbability) 
    {
    
        // Play the sound
        // Which sound should be played?
        i = Rand(numSounds);
        while( i == lastSound && bDontRepeat && numSounds > 1 )
            i = Rand(numSounds);
        
        PlaySound (Sounds[i]);
        lastSound = i;
    }

    rePlayTime = (maxReCheckTime-minReCheckTime)*FRand() + minReCheckTime;
    SetTimer(rePlayTime, False);
}

defaultproperties
{
     playProbability=0.600000
     minReCheckTime=5.000000
     maxReCheckTime=10.000000
     bStatic=False
}

Overview Package Class Source Class tree Glossary
previous class      next class frames      no frames
Class file time: za 22-4-2006 13:06:32.000 - Creation time: za 22-4-2006 13:07:25.406 - Created with UnCodeX