## XIIIMP
Class XIIIBombHud

source: C:\XIII\XIIIMP\Classes\XIIIBombHud.uc

    Core.Object
       |
       +--Engine.Actor
          |
          +--Engine.HUD
             |
             +--XIII.XIIIBaseHud
                |
                +--XIIIMP.XIIIMPHud
                   |
                   +--XIIIMP.XIIITeamHud
                      |
                      +--XIIIMP.XIIIBombHud

Direct Known Subclasses:None

class XIIIBombHud
extends XIIIMP.XIIITeamHud

    //-----------------------------------------------------------
    //
    //-----------------------------------------------------------

Variables
`MPBombingBase` | `ActiveBombBase`
`BlinkTime,` | `BotBlinkTime`
`int` | `ClientBombTimeInit[3]`
`float` | `ClientBombTime[3]`
`array` | `OXL,OYL`
`array` | `Objectives`
`int` | `SoundBomb[3],BotBlink[3]`
`sound` | `sndTicTac1,sndTicTac2,sndTicTacOff`
`texBombOut,` | `texChrono`

Function Summary
`void` | `DrawHUD(Canvas C)`
    //____________________________________________________________________
`simulated` | `InitObjectives(Canvas C)`
    //____________________________________________________________________
`void` | `MarioBonusDisplay(Canvas C)`
    //____________________________________________________________________
`void` | `PlayerNameDisplay(Canvas C)`
    //____________________________________________________________________
`string` | `TwoDigitString(int Num)`
    //_____________________________________________________________________________
`void` | `UpDatePlayerReplicationInfoForLAN()`
    //____________________________________________________________________

Source Code

    00001	//-----------------------------------------------------------
    00002	//
    00003	//-----------------------------------------------------------
    00004	class XIIIBombHud extends XIIITeamHud;
    00005
    00006	var array<MPBombingBase> Objectives;
    00007	var array<float> OXL,OYL;
    00008	var MPBombingBase ActiveBombBase;
    00009	var texture texBomb1, texBomb2, texBomb3, texBombOut, texChrono;
    00010	var float BlinkTime, BotBlinkTime;
    00011	var float ClientBombTime[3];
    00012	var int ClientBombTimeInit[3];
    00013	var int SoundBomb[3],BotBlink[3];
    00014	var sound sndTicTac1,sndTicTac2,sndTicTacOff;
    00015
    00016	//_____________________________________________________________________________
    00017	function string TwoDigitString(int Num)
    00018	{
    00019	    if ( Num < 10 )
    00020	      return "0"$Num;
    00021	    else
    00022	      return string(Num);
    00023	}
    00024	//____________________________________________________________________
    00025	simulated function InitObjectives(Canvas C)
    00026	{
    00027	    Local MPBombingBase OB;
    00028	    Local int Loop;
    00029	    local MPBombingBase TmpOB[3];
    00030
    00031
    00032	    if ( Objectives.Length == 0 )
    00033	    {
    00034	      UseLargeFont(C);
    00035	//      i = 0;
    00036	      foreach allactors(class'MPBombingBase', OB)
    00037	      {
    00038	        TmpOB[ OB.BombPointID-1 ] = OB;
    00039	//        Objectives[i] = OB; // auto incrment array
    00040	//        // init text length as they will not change later
    00041	//        OXL.Length = OXL.Length + 1;
    00042	//        OYL.Length = OYL.Length + 1;
    00043	//
    00044	//        C.StrLen(Objectives[i].sBaseName, OXL[i], OYL[i]); // may not auto increment OXL & OYL so inc before
    00045	//
    00046	//        i++;
    00047	      }
    00048	    }
    00049
    00050	    for( loop=0; loop<3; loop++ )
    00051	    {
    00052	        Objectives.Length = Objectives.Length+1;
    00053	        Objectives[ Objectives.Length-1 ] = TmpOB[ Loop ];
    00054	    }
    00055	}
    00056
    00057	//____________________________________________________________________
    00058	function PlayerNameDisplay(Canvas C)
    00059	{
    00060	//    local float W,H;
    00061	    local float W2,H2;
    00062	//    local string TmpCountDown;
    00063	    local int Score[2], PlayerId, loop;
    00064	//    local int TmpTime ;
    00065	//    local float TmpRest;
    00066	    local int Minutes, Seconds;
    00067	    local XIIIGameReplicationInfo TGRI;
    00068	    local int iSec, iMillisec;
    00069	    local bool blink;
    00070
    00071	    if( BotBlinkTime == -1 )
    00072	    {
    00073	        BotBlinkTime = Level.TimeSeconds;
    00074	        blink = true;
    00075	    }
    00076
    00077	    if( Level.TimeSeconds - BotBlinkTime > 1.0 )
    00078	    {
    00079	        BotBlinkTime = Level.TimeSeconds;
    00080	        blink = true;
    00081	    }
    00082	    else if( Level.TimeSeconds - BotBlinkTime > 0.5 )
    00083	    {
    00084	        blink = false;
    00085	    }
    00086	    else
    00087	    {
    00088	        blink = true;
    00089	    }
    00090
    00091
    00092
    00093	    UseHugeFont(C);
    00094	    C.SpaceX = 0;
    00095	    C.StrLen("00:00", W2, H2 );
    00096
    00097	    if ( Objectives.Length == 0 )
    00098	      InitObjectives(C);
    00099
    00100	    if( ! bInit )
    00101	    {
    00102	      bInit = true;
    00103	      C.StrLen("999", ScoreWidth, ScoreHeight );
    00104	      ScoreHeight += 4;
    00105	      Scoring.UpdateScores();
    00106	      if ( (Level.NetMode != NM_Standalone) || (Level.bLonePlayer) )
    00107	        bSplitt = false;
    00108	      else
    00109	        bSplitt = true;
    00110	    }
    00111
    00112	    PlayerId = PlayerOwner.PlayerReplicationInfo.Team.TeamIndex;
    00113
    00114	    C.bUseBorder = false;
    00115	    C.Style = ERenderStyle.STY_Alpha;
    00116
    00117	    // ________________
    00118	    // List of bombing point states
    00119	    C.DrawColor = TeamColor[PlayerId];
    00120	    C.DrawColor.A = 200;
    00121	    C.SetPos( XP, YP);
    00122	    DrawStdBackGround(C, ScoreHeight, ScoreHeight*3);
    00123	    C.DrawColor = WhiteColor;
    00124	    C.DrawColor.A = 255;
    00125
    00126	    C.SetPos( XP + ScoreHeight, YP-1);
    00127
    00128	    if( ( ( BotBlink[0]==1 ) && ( Objectives[0].CurrentTeam == 1 ) ) && blink )
    00129	    {
    00130	        C.DrawColor = C.Static.MakeColor(253,191,68);
    00131	        C.DrawColor.A = 255;
    00132	    }
    00133	    else
    00134	    {
    00135	        C.DrawColor = WhiteColor;
    00136	        C.DrawColor.A = 255;
    00137	    }
    00138
    00139	    if( Objectives[0].CurrentTeam == 1 )
    00140	      C.DrawTile(texBomb1, ScoreHeight,ScoreHeight, 0, 0, texBomb1.USize, texBomb1.VSize);
    00141	    else
    00142	      C.DrawTile(texBombOut, ScoreHeight,ScoreHeight, 0, 0, texBombOut.USize, texBombOut.VSize);
    00143
    00144
    00145	    if( ( ( BotBlink[1]==1 ) && ( Objectives[1].CurrentTeam == 1 ) ) && blink )
    00146	    {
    00147	        C.DrawColor = C.Static.MakeColor(253,191,68);
    00148	        C.DrawColor.A = 255;
    00149	    }
    00150	    else
    00151	    {
    00152	        C.DrawColor = WhiteColor;
    00153	        C.DrawColor.A = 255;
    00154	    }
    00155
    00156	    if( Objectives[1].CurrentTeam == 1 )
    00157	      C.DrawTile(texBomb2, ScoreHeight,ScoreHeight, 0, 0, texBomb2.USize, texBomb2.VSize);
    00158	    else
    00159	      C.DrawTile(texBombOut, ScoreHeight,ScoreHeight, 0, 0, texBombOut.USize, texBombOut.VSize);
    00160
    00161
    00162	    if( ( ( BotBlink[2]==1 ) && ( Objectives[2].CurrentTeam == 1 ) ) && blink )
    00163	    {
    00164	        C.DrawColor = C.Static.MakeColor(253,191,68);
    00165	        C.DrawColor.A = 255;
    00166	    }
    00167	    else
    00168	    {
    00169	        C.DrawColor = WhiteColor;
    00170	        C.DrawColor.A = 255;
    00171	    }
    00172
    00173	    if( Objectives[2].CurrentTeam == 1 )
    00174	      C.DrawTile(texBomb3, ScoreHeight,ScoreHeight, 0, 0, texBomb3.USize, texBomb3.VSize);
    00175	    else
    00176	      C.DrawTile(texBombOut, ScoreHeight,ScoreHeight, 0, 0, texBombOut.USize, texBombOut.VSize);
    00177
    00178	    C.DrawColor.A = 255;
    00179
    00180	    // ________________
    00181	    // Timer display if a bomb is being activated
    00182	    for (loop=0; loop<Objectives.Length; loop++)
    00183	    {
    00184	      if( Objectives[loop].BombTime != -1 )
    00185	      {
    00186	        if( Objectives[loop].Role == ROLE_Authority )
    00187	        {
    00188	          iSec = 12 + Objectives[loop].BombTime - Level.TimeSeconds;
    00189	          iMilliSec = (120.0 + Objectives[loop].BombTime*10.0 - Level.TimeSeconds*10.0 - iSec*10.0);
    00190	        }
    00191	        else
    00192	        {
    00193	          iSec = 12 + ClientBombTime[Loop] - Level.TimeSeconds;
    00194	          iMilliSec = (120.0 + ClientBombTime[Loop]*10.0 - Level.TimeSeconds*10.0 - iSec*10.0);
    00195	        }
    00196
    00197	        if( ( iSec >= 0 ) && ( iMilliSec >= 0 ) )
    00198	        {
    00199	          if( SoundBomb[Loop] != 1 )
    00200	            PlayerOwner.PlayMenu( sndTicTac1 );
    00201	          SoundBomb[Loop] = 1;
    00202
    00203	          C.DrawColor = WhiteColor;
    00204	          C.DrawColor.A = 128;
    00205	          C.SetPos( C.ClipX/2 - (ScoreHeight+W2)/2, C.ClipY/3);
    00206
    00207	          switch( Loop )
    00208	          {
    00209	            case 0:
    00210	              C.DrawTile(texBomb1, ScoreHeight,ScoreHeight, 0, 0, texBomb1.USize, texBomb1.VSize);
    00211	              break;
    00212	            case 1:
    00213	              C.DrawTile(texBomb2, ScoreHeight,ScoreHeight, 0, 0, texBomb2.USize, texBomb2.VSize);
    00214	              break;
    00215	            case 2:
    00216	              C.DrawTile(texBomb3, ScoreHeight,ScoreHeight, 0, 0, texBomb3.USize, texBomb3.VSize);
    00217	              break;
    00218	          }
    00219	          C.SetPos( C.ClipX/2 - (ScoreHeight+W2)/2 + ScoreHeight, C.ClipY/3);
    00220	          C.DrawText( iSec$":"$iMilliSec$"0" , false);
    00221	        }
    00222	        else
    00223	        {
    00224	          if ( SoundBomb[Loop] != 2 )
    00225	            PlayerOwner.PlayMenu( sndTicTac2 );
    00226	          SoundBomb[Loop] = 2;
    00227
    00228	          if( ( iSec < -6 ) && ( SoundBomb[Loop] != 0 ) ) // antibug si arrive a lacher la bombe a l'exterieure de la zone
    00229	          {
    00230	              log("ANTIBUG");
    00231	              Objectives[loop].BombTime = -1;
    00232	          }
    00233	        }
    00234	      }
    00235	      else
    00236	      {
    00237	//        ClientBombTimeInit[Loop]=0;
    00238	        if( SoundBomb[Loop] != 0 )
    00239	        {
    00240	          //Log("---- TicTac OFF ----");
    00241	          PlayerOwner.PlayMenu( sndTicTacOff );
    00242	        }
    00243	        SoundBomb[Loop] = 0;
    00244	      }
    00245
} 00246 00247 // ________________ 00248 // Left time 00249 C.DrawColor = TeamColor[PlayerId]; 00250 C.DrawColor.A = 200; 00251 C.SetPos( XP, YP+ScoreHeight+4); 00252 DrawStdBackGround(C, ScoreHeight, W2+8); 00253 C.SetPos( XP, YP+ScoreHeight); 00254 C.DrawColor = WhiteColor; 00255 C.DrawColor.A = 255; 00256 C.DrawTile(texChrono, ScoreHeight+8, ScoreHeight+8, 64, 32, 32, 32); 00257 C.SetPos( XP+ ScoreHeight+ 8, YP+ScoreHeight+4); 00258 TGRI = XIIIGameReplicationInfo(PlayerOwner.GameReplicationInfo); 00259 Minutes = TGRI.XIIIRemainingTime/60; 00260 Seconds = TGRI.XIIIRemainingTime % 60; 00261 C.bTextShadow = true; 00262 C.DrawText(TwoDigitString(Minutes)$":"$TwoDigitString(Seconds), false); 00263 C.bTextShadow = false; 00264 00265 // ________________ 00266 // Frag made. 00267 if ( OldScore != XIIIPlayerReplicationInfo(PlayerOwner.PlayerReplicationInfo).MyDeathScore ) 00268 { 00269 FragCount = XIIIPlayerReplicationInfo(PlayerOwner.PlayerReplicationInfo).MyDeathScore-OldScore; 00270 00271 if( FragCount > 0 ) 00272 { 00273 SetTimer2( 2.0, true ); 00274 PlayerOwner.PlayMenu( SndFrag ); 00275 LastFragTime=Level.TimeSeconds; 00276 } 00277 else 00278 FragCount = 0; 00279 } 00280 OldScore = XIIIPlayerReplicationInfo(PlayerOwner.PlayerReplicationInfo).MyDeathScore; 00281 00282 if( FragCount != 0 ) 00283 DrawFrag(C); 00284 00285 MarioBonusDisplay(C); 00286 } 00287 00288 //____________________________________________________________________ 00289 00290 function UpDatePlayerReplicationInfoForLAN() 00291 { 00292 local weapon MyBomb; 00293 local controller TmpC; 00294 00295 for (TmpC=Level.ControllerList; TmpC!=None; TmpC=TmpC.NextController ) 00296 { 00297 if( ( TmpC.Pawn == none ) || ( TmpC.Pawn.Health == 0 ) ) 00298 XIIIPlayerReplicationInfo(TmpC.PlayerReplicationInfo).bHasTheBomb=false; 00299 else 00300 { 00301 MyBomb = weapon(TmpC.Pawn.FindInventoryType(class'MPBomb')); 00302 if( ( MyBomb != none ) && ( MyBomb.AmmoType.AmmoAmount != 0 ) ) 00303 XIIIPlayerReplicationInfo(TmpC.PlayerReplicationInfo).bHasTheBomb=true; 00304 else 00305 XIIIPlayerReplicationInfo(TmpC.PlayerReplicationInfo).bHasTheBomb=false; 00306 } 00307 } 00308 } 00309 00310 //____________________________________________________________________ 00311 function DrawHUD( canvas C ) 00312 { 00313 local int loop; 00314 // Log("BOMBHUD DrawHud PlayerOwner="$PlayerOwner@"GRI="$PlayerOwner.GameReplicationInfo); 00315 if ( (PlayerOwner == none) || (PlayerOwner.GameReplicationInfo == none) ) 00316 return; // wait for game initialization/replications 00317 00318 if ( Level.NetMode != NM_Standalone ) 00319 UpDatePlayerReplicationInfoForLAN(); 00320 00321 // ________________ 00322 // Timer display if a bomb is being activated, SetUp initial time for on-line 00323 for (loop=0; loop<Objectives.Length; loop++) 00324 { 00325 if( Objectives[loop].BombTime != -1 ) 00326 { 00327 if( Objectives[loop].Role != ROLE_Authority ) 00328 { 00329 if( ClientBombTimeInit[Loop] != Objectives[loop].BombingCount ) 00330 { // initialized new count on clients 00331 // Log("Client NewBombActivated BombingCount="$Objectives[loop].BombingCount); 00332 ClientBombTimeInit[Loop] = Objectives[loop].BombingCount; 00333 ClientBombTime[Loop] = Level.TimeSeconds; 00334 } 00335 } 00336 } 00337 } 00338 /* // Useless multiple call 00339 HUDSetup( C ); 00340 00341 // ELR do show scores if needed. 00342 if ( XIIIGameReplicationInfo(PlayerOwner.GameReplicationInfo).iGameState != 2 ) 00343 { 00344 if ( Scoring != None ) 00345 { 00346 Scoring.OwnerHUD = self; 00347 Scoring.ShowScores(C, ViewPortId, Level.Game.NumPlayers); 00348 DrawViewPortSeparator(C); 00349 return; 00350 } 00351 } 00352 */ 00353 Super.DrawHud(C); 00354 } 00355 00356 //____________________________________________________________________ 00357 simulated function LocalizedMessage( class<LocalMessage> Message, optional int Switch, optional PlayerReplicationInfo RelatedPRI_1, optional PlayerReplicationInfo RelatedPRI_2, optional Object OptionalObject, optional string CriticalString ) 00358 { 00359 if( ( Level.NetMode == NM_StandAlone) && ( ( Level.Game == none ) || ( Level.Game.NumPlayers > 2 ) ) ) 00360 return; 00361 00362 if ( Message == class'XIIIEndGameMessage' ) 00363 { 00364 AddHudEndMessage( Message, Switch, RelatedPRI_1, RelatedPRI_2, OptionalObject, CriticalString ); 00365 bHideHud = true; 00366 } 00367 else if( ( ( ( ( ( Message == class'XIIIDeathMessage' ) || ( Message == class'XIIIMPCTFMessage') ) || ( Message == class'XIIIMultiMessage' ) ) || ( Message == class'XIIIMPSabotageMessage' ) ) || ( Message == class'XIIIMPBlueDeathMessage' ) ) || ( Message == class'XIIIMPRedDeathMessage' ) ) 00368 AddHudMPMessage( Message, Switch, RelatedPRI_1, RelatedPRI_2, OptionalObject, CriticalString ); 00369 else 00370 AddHudMessage( Message, Switch, RelatedPRI_1, RelatedPRI_2, OptionalObject, CriticalString ); 00371 } 00372 00373 //____________________________________________________________________ 00374 function MarioBonusDisplay(Canvas C) 00375 { 00376 local string strMarioBonus; 00377 local float W,H ; 00378 local int Loop,BonusIndex,BonusValue; 00379 local texture BonusTex; 00380 local string TmpBaseName; 00381 local bool blink; 00382 00383 if( PlayerOwner == none ) 00384 return; 00385 00386 if( PlayerOwner.Pawn == none ) 00387 return; 00388 00389 if ( Level.NetMode != NM_Standalone ) 00390 { 00391 MarioBonus = XIIIMPPlayerPawn(PlayerOwner.Pawn).MarioBonusLAN; 00392 } 00393 00394 if( MarioBonus != OldMarioBonus ) 00395 UpdateBonusSound(); 00396 00397 OldMarioBonus = MarioBonus; 00398 00399 if( MarioBonus < 0 ) 00400 { 00401 MarioBonus = 0; 00402 bDrawBonusText= false; 00403 } 00404 00405 if( bDrawBonusText ) 00406 DrawBonusText(C); 00407 00408 if( MarioBonus == 1024 ) 00409 { 00410 if ( PlayerOwner.Pawn != none ) 00411 foreach PlayerOwner.Pawn.TouchingActors(class'MPBombingBase', ActiveBombBase) 00412 break; 00413 00414 if( ( ActiveBombBase != none ) && ( ActiveBombBase.CurrentTeam == 1 ) ) 00415 { 00416 if( BlinkTime == -1 ) 00417 BlinkTime = Level.TimeSeconds; 00418 00419 blink = true; 00420 } 00421 else 00422 { 00423 blink = false; 00424 } 00425 00426 if( blink ) 00427 { 00428 if( Level.TimeSeconds - BlinkTime > 1.0 ) 00429 BlinkTime = -1; 00430 else if( Level.TimeSeconds - BlinkTime > 0.5 ) 00431 blink = false; 00432 } 00433 00434 UseHugeFont(C); 00435 C.SpaceX = 0; 00436 C.bUseBorder = true; 00437 C.Style = ERenderStyle.STY_Alpha; 00438 C.StrLen("A", W, H ); 00439 00440 if( blink ) 00441 { 00442 C.BorderColor = C.Static.MakeColor(253,191,68); 00443 C.DrawColor = C.Static.MakeColor(253,191,68); 00444 } 00445 else 00446 { 00447 C.BorderColor = WhiteColor; 00448 C.DrawColor = WhiteColor; 00449 } 00450 00451 C.DrawColor.A = 255; 00452 00453 BonusTex = MarioBonusTex[10]; 00454 C.SetPos( XP,YP+2*(H+4)); 00455 C.DrawTile(BonusTex, H,H, 0, 0, BonusTex.USize, BonusTex.VSize); 00456 00457 C.bUseBorder = false; 00458 } 00459 } 00460 00461 //____________________________________________________________________ 00462 00463 00464 00465 defaultproperties 00466 { 00467 texBomb1=Texture'XIIIMenu.HUD.iconebomb1' 00468 texBomb2=Texture'XIIIMenu.HUD.iconebomb2' 00469 texBomb3=Texture'XIIIMenu.HUD.iconebomb3' 00470 texBombOut=Texture'XIIIMenu.HUD.iconebombout' 00471 texChrono=Texture'XIIIMenu.HUD.HudIcons' 00472 BlinkTime=-1.000000 00473 BotBlinkTime=-1.000000 00474 sndTicTac1=Sound'XIIIsound.Multi__SFXMulti.SFXMulti__hBomBing' 00475 sndTicTac2=Sound'XIIIsound.Multi__SFXMulti.SFXMulti__hBombArmored' 00476 sndTicTacOff=Sound'XIIIsound.Multi__SFXMulti.SFXMulti__hBombOut' 00477 }

End Source Code