import class RoachRaceLogicController extends MinigameLogicController
{
	private editable var m_damageAnimation : CName;
	private editable var m_healAnimation : CName;
	private editable var m_healthText : inkTextRef;
	private editable var m_scoreText : inkTextRef;
	private editable var m_scoreMultiplierText : inkTextRef;
	private var m_previousHealth : Int32;
	default m_previousHealth = 0;

	protected override function OnGameStateUpdateLogic( gameStateUpdateEvent : MiniGameStateUpdateEvent )
	{
		var gameState : RoachRaceGameState;
		gameState = ( ( RoachRaceGameState )( gameStateUpdateEvent.gameState ) );
		if( inkTextRef.IsValid( m_healthText ) )
		{
			inkTextRef.SetText( m_healthText, IntToString( gameState.currentLives ) );
		}
		if( inkTextRef.IsValid( m_scoreText ) )
		{
			inkTextRef.SetText( m_scoreText, IntToString( gameState.currentScore ) );
		}
		inkTextRef.SetText( m_scoreMultiplierText, ( ( gameState.pointsBonusTime > 0.0 ) ? ( "x2" ) : ( "x1" ) ) );
		if( gameState.currentLives < m_previousHealth )
		{
			PlayLibraryAnimationOnTargets( m_damageAnimation, SelectWidgets( inkTextRef.Get( m_healthText ) ) );
		}
		else if( gameState.currentLives > m_previousHealth )
		{
			PlayLibraryAnimationOnTargets( m_healAnimation, SelectWidgets( inkTextRef.Get( m_healthText ) ) );
		}
		if( gameState.currentLives == 0 )
		{
			FinishGameLogic();
		}
		m_previousHealth = gameState.currentLives;
	}

}

