XIDCine
Class DialogueManagerRandom

source: C:\XIII\XIDCine\Classes\DialogueManagerRandom.uc
Core.Object
   |
   +--Engine.Actor
      |
      +--Engine.Info
         |
         +--XIDCine.DialogueManager
            |
            +--XIDCine.DialogueManagerRandom
Direct Known Subclasses:None

class DialogueManagerRandom
extends XIDCine.DialogueManager

//----------------------------------------------------------- // DialogueManagerRandom // Created by iKi //-----------------------------------------------------------
Variables
 int LastLineIndex
 Pawn LastSpeaker

States
STA_PlayingDialogue

Function Summary
 void ForceLine(int line)
 bool MustBeStop( )
 void NextSentence()
     
/*
 void StartDialogue(optional int)
 bool WarnIfAVoiceIsAlreadyRunning()


State STA_PlayingDialogue Function Summary



Source Code


00001	//-----------------------------------------------------------
00002	// DialogueManagerRandom
00003	// Created by iKi
00004	//-----------------------------------------------------------
00005	class DialogueManagerRandom extends DialogueManager;
00006	
00007	#exec Texture Import File=Textures\dialman2_ico.tga Name=DialMan2_ico Mips=Off
00008	//VAR bool bNotFirst;
00009	VAR int LastLineIndex;
00010	VAR Pawn LastSpeaker;
00011	
00012	EVENT PostBeginPlay()
00013	{
00014	}
00015	
00016	FUNCTION StartDialogue( optional int firstline )
00017	{
00018		LOCAL int i;
00019		
00020		if ( !bStarted )
00021		{
00022			if ( PC == none )
00023				PC = XIIIGameInfo( Level.Game ).MapInfo.XIIIController;
00024	
00025			LineIndex = firstline;
00026			bStarted = true;
00027			GotoState( 'STA_PlayingDialogue' );
00028		}
00029		else
00030		{
00031			ForceLine( firstline );
00032		}
00033	}
00034	
00035	FUNCTION ForceLine(coerce int line)
00036	{
00037		if ( PC == none )
00038			PC = XIIIGameInfo( Level.Game ).MapInfo.XIIIController;
00039	
00040		LineIndex = line;
00041		tag = '';
00042		Speak( );
00043	}
00044	
00045	EVENT Trigger( actor Other, pawn EventInstigator )
00046	{
00047	//	if ( bNotFirst )
00048	//		Lines.Remove( LineIndex, 1 ); // Remove used sentence in random mode
00049		if ( Timer2Rate==0 )
00050			SetTimer2(0.05,true);
00051	//	LOG ( "DMR Triggered !" );
00052		LineIndex = Rand( Lines.Length ); // choose a random lines in random mode
00053		if ( LastLineIndex==LineIndex )
00054		{
00055			LineIndex = (LineIndex+1)%(Lines.Length);
00056		}
00057		LastLineIndex=LineIndex;
00058		Lines[ LineIndex ].ExpectedEventBeforeNext = Tag;
00059		Speakers[ Lines[ LineIndex ].SpeakerIndex ].Pawn = EventInstigator;
00060	//	bNotFirst = true;
00061		StartDialogue( LineIndex );
00062		
00063	}
00064	
00065	EVENT Timer2()
00066	{
00067		if ( bSpeaking && CurrentSpeakerPawn!=none && CurrentSpeakerPawn.bIsDead )
00068		{
00069			StopVoice();
00070			XIIIBaseHud( PC.MyHud ).HudDlg.RemoveMe();
00071			SetTimer2(0,false);
00072			bSpeaking = false;
00073		}
00074	}
00075	
00076	FUNCTION bool MustBeStop( )
00077	{
00078		return false;
00079	}
00080	
00081	FUNCTION bool WarnIfAVoiceIsAlreadyRunning()
00082	{
00083		LOCAL DialogueManager dm;
00084	
00085		foreach DynamicActors( class'DialogueManager', dm )
00086		{
00087			if ( dm.bSpeaking )
00088			{
00089				StopVoice( );
00090				XIIIBaseHud( PC.MyHud ).HudDlg.RemoveMe();
00091	//			dm.Destroy();
00092				break;
00093			}
00094		}
00095		return false;
00096	}
00097	/*
00098	FUNCTION NextSentence()
00099	{
00100		Log ( "DMR NextSentence" );	
00101	}*/
00102	
00103	STATE STA_PlayingDialogue
00104	{
00105		EVENT BeginState( )
00106		{
00107			if ( !bDialoguePlaying )
00108			{
00109				Speak( );
00110				bDialoguePlaying = true;
00111			}
00112		}
00113		
00114		EVENT Trigger( actor Other, pawn EventInstigator )
00115		{
00116			Global.Trigger( Other, EventInstigator );
00117		}
00118	}
00119		
00120	
00121	
00122	defaultproperties
00123	{
00124	     LastLineIndex=-1
00125	     Texture=Texture'XIDCine.DialMan2_ico'
00126	}

End Source Code