Overview | Package | Class | Source | Class tree | Glossary | UnrealScript Documentation |
previous class next class | frames no frames |
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 00086 00087 00088 00089 00090 00091 00092 00093 00094 00095 00096 00097 00098 00099 00100 00101 00102 00103 00104 00105 00106 00107 00108 00109 00110 00111 |
//============================================================================= // CodeMaster. //============================================================================= class CodeMaster extends Info; // When a set of CodeTriggers are set up along with their corresponding // ElevatorMovers, the CodeMaster is notified by the CodeTriggers whenever // something encroaches upon them, and tries to match the order of trigger // activations to a preset pattern, and if the pattern is matched, the // main event is called, solving the "puzzle". M var() int OrderCode[6]; var() name MoverTags[6]; var() int NumElements; var() name MainEvent; var int ActualOrder[6]; var int TriggerFlags[6]; var int NumTriggered; var bool bTriggeredAlready; function BeginPlay() { local int i; bTriggeredAlready = false; for( i=0; i<NumElements; i++ ) TriggerFlags[i] = 0; NumTriggered = 0; } function NotifyTriggered( int TriggerCode ) { // Don't continue if the main Event has already been successfully called if( bTriggeredAlready ) return; // Don't add it to the order list if this trigger has been triggered already if( TriggerFlags[ TriggerCode ] == 1 ) return; // Set the trigger flag for this code //log( "TriggerCode = " $ TriggerCode ); TriggerFlags[ TriggerCode ] = 1; // Add this code to the sequence if( NumTriggered == NumElements ) NumTriggered = 0; ActualOrder[ NumTriggered ] = TriggerCode; NumTriggered++; CheckOrder(); } function CheckOrder() { local int i; local int bR; local ElevatorMover EM; local Actor tAct; // Check if the order given matches what is required to cause the event bR = 1; // First check if all the triggers were activated for( i=0; i<NumElements; i++ ) bR = bR * TriggerFlags[i]; if( bR != 0 ) { //log("All triggers activated"); // All the triggers were activated // Now check if the order of activation was correct for( i=0; i<NumElements; i++ ) { if( OrderCode[i] == ActualOrder[i] ) { if( i == NumElements-1 ) { //log("Successful! Calling Main Event."); // successful match // Call the main Event if( MainEvent != '' ) foreach AllActors( class 'Actor', tAct, MainEvent ) tAct.Trigger( Self, Self.Instigator ); // deactivate the CodeMaster bTriggeredAlready = true; return; } } else break; } //log("Resetting puzzle"); // If false then find all ElevatorMovers who have Tags which match // this CodeMaster's Event, and Move them to keyframe 0. for( i=0; i<NumElements; i++ ) { if( MoverTags[i] != '' ) foreach AllActors( class 'ElevatorMover', EM, MoverTags[i] ) EM.MoveKeyframe( 0, EM.MoveTime ); } // Clear the TriggerFlags array, reset the puzzle for( i=0; i<NumElements; i++ ) TriggerFlags[i] = 0; NumTriggered = 0; } } defaultproperties { } |
Overview | Package | Class | Source | Class tree | Glossary | UnrealScript Documentation |
previous class next class | frames no frames |