## XIII
Class Chronometre

source: C:\XIII\XIII\Classes\Chronometre.uc

    Core.Object
       |
       +--Engine.Actor
          |
          +--Engine.Inventory
             |
             +--Engine.Powerups
                |
                +--XIII.XIIIItems
                   |
                   +--XIII.Chronometre

Direct Known Subclasses:None

class Chronometre
extends XIII.XIIIItems

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

Variables
`int` | `BTime` Beginning time
`ChronoSeconds,` | `ChronoSecond` , TimeOver;
`int` | `CountDownStart` CountDown start (time to reach 0 from spawn)
`int` | `WarnTime` Next time a warning message will be sent

Function Summary
`string` | `GetTimeString()`
    //_____________________________________________________________________________
`void` | `PostBeginPlay()`
    //_____________________________________________________________________________
`void` | `ReSetTimer(float fTime)`
    //_____________________________________________________________________________
`void` | `SetWarnTime()`
    //_____________________________________________________________________________
`void` | `Timer()`
    //_____________________________________________________________________________
`simulated` | `UseMe()`
    //_____________________________________________________________________________

Source Code

    00001	//-----------------------------------------------------------
    00002	//
    00003	//-----------------------------------------------------------
    00004	class Chronometre extends XIIIItems;
    00005
    00006	var int BTime;                    // Beginning time
    00007	var int CountDownStart;           // CountDown start (time to reach 0 from spawn)
    00008	var int WarnTime;                 // Next time a warning message will be sent
    00009	var localized string ChronoSeconds, ChronoSecond; //, TimeOver;
    00010
    00011	//_____________________________________________________________________________
    00012	function PostBeginPlay()
    00013	{
    00014	    ResetTimer(CountDownStart);
    00015	}
    00016
    00017	//_____________________________________________________________________________
    00018	function ReSetTimer(float fTime)
    00019	{
    00020	    BTime=Level.TimeSeconds + fTime;
    00021	    SetWarnTime();
    00022	    SetTimer(0.5, true);
    00023	}
    00024
    00025	//_____________________________________________________________________________
    00026	function SetWarnTime()
    00027	{
    00028	    // Warntime is ne next time we'll warn the player.
    00029	    if ( (BTime-Level.TimeSeconds) > 70 )
    00030	    { // Every Minute
    00031	      WarnTime=int((BTime-Level.TimeSeconds)/60)*60;
    00032	    }
    00033	    else if ( (BTime-Level.TimeSeconds) > 11 )
    00034	    { // Every 10 seconds
    00035	      WarnTime=int((BTime-Level.TimeSeconds)/10)*10;
    00036	    }
    00037	    else if ( (BTime-Level.TimeSeconds) > 6 )
    00038	    { // Every 5 seconds
    00039	      WarnTime=int((BTime-Level.TimeSeconds)/5)*5;
    00040	    }
    00041	    else if ( (BTime-Level.TimeSeconds) > -2 )
    00042	    { // Every Second
    00043	      WarnTime=int(BTime-Level.TimeSeconds);
    00044	    }
    00045	}
    00046
    00047	//_____________________________________________________________________________
    00048	function Timer()
    00049	{
    00050	    local XIIIPlayerController PC;
    00051
    00052	    PC = XIIIPlayerController(Instigator.Controller);
    00053
    00054	    if ( (BTime-Level.TimeSeconds) < -2)
    00055	    {
    00056	      SetTimer(0.0, false);
    00057	      TriggerEvent('ChronoEnded', self, Pawn(Owner));
    00058	      return;
    00059	    }
    00060
    00061	    if ( XIIIBaseHUD(PC.MyHud) != none )
    00062	      XIIIBaseHUD(PC.MyHUD).AddChronoDisplay(GetTimeString());
    00063
    00064	/*
    00065	    if ( int(BTime-Level.TimeSeconds) < WarnTime )
    00066	    {
    00067	      if ( PC == none )
    00068	        return;
    00069	      PC.ReceiveLocalizedMessage(class'XIIISoloMessage', 3, PC.PlayerReplicationInfo, none, self);
    00070	      SetWarnTime();
    00071	    }
    00072	*/
    00073	}
    00074
    00075	//_____________________________________________________________________________
    00076	function string GetTimeString()
    00077	{
    00078	    local XIIIPlayerController PC;
    00079
    00080	    PC = XIIIPlayerController(Instigator.Controller);
    00081
    00082	    if ( (BTime-Level.TimeSeconds) > 0 )
    00083	    {
    00084	/*      if ( int(BTime-Level.TimeSeconds)+1 == 1 )
    00085	      {
    00086	//         if ( XIIIBaseHUD(PC.MyHUD).bNumericDisplay )
    00087	//             return ""$int(BTime-Level.TimeSeconds)+1;
    00088	//         else
    00089	             return ""$int(BTime-Level.TimeSeconds)+1$ChronoSecond;
    00090	      }
    00091	      else
    00092	//         if ( XIIIBaseHUD(PC.MyHUD).bNumericDisplay )
    00093	//             return ""$int(BTime-Level.TimeSeconds)+1;
    00094	//         else
    00095	             return ""$int(BTime-Level.TimeSeconds)+1$ChronoSeconds;*/
    00096		    if ( (BTime-Level.TimeSeconds+1) <= 10 )
    00097			{
    00098				XIIIBaseHUD(PC.MyHUD).bDrawChronoWithWarningColors=true;
    00099				if ( Level.TimeSeconds-int(Level.TimeSeconds)>0.5 )
    00100					return right("00"$(int(BTime-Level.TimeSeconds)+1),3)$"s";
    00101				else
    00102					return "";
    00103			}
    00104			else
    00105			{
    00106				XIIIBaseHUD(PC.MyHUD).bDrawChronoWithWarningColors=false;
    00107				return right("00"$(int(BTime-Level.TimeSeconds)+1),3)$"s";
    00108			}
    00109	    }
    00110		XIIIBaseHUD(PC.MyHUD).bDrawChronoWithWarningColors=true;
    00111	    return "000s";
    00112	}
    00113
    00114	//_____________________________________________________________________________
    00115	event Destroyed()
    00116	{
    00117	    // time display is deleted when chrono is destroyed
    00118
    00119		local XIIIPlayerController PC;
    00120
    00121	    PC = XIIIPlayerController(Instigator.Controller);
    00122
    00123		if ( XIIIBaseHUD(PC.MyHud) != none )
    00124			XIIIBaseHUD(PC.MyHud).bDrawChrono = false;
    00125
    00126		Super.Destroyed();
    00127	}
    00128
    00129	//_____________________________________________________________________________
    00130	Simulated function UseMe()
    00131	{
    00132	    local XIIIPlayerController PC;
    00133
    00134	    PC = XIIIPlayerController(Instigator.Controller);
    00135	    if ( PC == none )
    00136	      return;
    00137
    00138	    PC.ReceiveLocalizedMessage(class'XIIISoloMessage', 3, PC.PlayerReplicationInfo, none, self);
    00139	}
    00140
    00141	//     Icon=texture'XIIISounds.Icons.IIChrono'
    00142	//     TimeOver=" Time Over !"
    00143
    00144	defaultproperties
    00145	{
    00146	     CountDownStart=60
    00147	     ChronoSeconds=" seconds"
    00148	     ChronoSecond=" second"
    00149	     bCanHaveMultipleCopies=True
    00150	     bAutoActivate=True
    00151	     ExpireMessage="Chronometre was used."
    00152	     Charge=1
    00153	     PlayerViewOffset=(X=8.600000,Y=6.000000,Z=-5.800000)
    00154	     ItemName="CHRONOMETRE"
    00155	}

End Source Code