//=============================================================================
// Battle2D
//=============================================================================
class Battle2D expands Menu;

var Pawn2D PawnList[8];
var int NumPawns;
var float DeltaTime;

function Destroyed()
{
	local int i;

	for ( i=0; i<NumPawns; i++ )
		PawnList[i].Destroy();

	Super.Destroyed();
}

function DrawSelf(canvas Canvas, int StartX)
{
	local int i,j;
	local vector DrawOffset, DrawLoc;
	local rotator DrawRot;

	if ( NumPawns == 0 )
	{
		PlayerOwner.bBehindView = false;
		NumPawns = 1;
		PawnList[0] = Spawn(class'MaleOne2D',PlayerOwner);
	}
	if ( PlayerOwner.ViewTarget == None )
	{
		PlayerOwner.ViewRotation.Pitch = 0;
		PlayerOwner.ViewRotation.Roll = 0;
		DrawRot = PlayerOwner.ViewRotation;
		DrawLoc = PlayerOwner.Location + PlayerOwner.EyeHeight * vect(0,0,1);
	}
	else
	{
		DrawLoc = PlayerOwner.ViewTarget.Location;
		DrawRot = PlayerOwner.ViewTarget.Rotation;
		if ( Pawn(PlayerOwner.ViewTarget) != None )
		{
			if ( (Level.NetMode == NM_StandAlone) 
				&& (PlayerOwner.ViewTarget.IsA('PlayerPawn') || PlayerOwner.ViewTarget.IsA('Bot')) )
					DrawRot = Pawn(PlayerOwner.ViewTarget).ViewRotation;

			DrawLoc.Z += Pawn(PlayerOwner.ViewTarget).EyeHeight;
		}
	}

	//update AI visibility, position
	for ( i=0; i<NumPawns; i++ )
	{
		PawnList[i].Update(DeltaTime);
		DrawOffset = StartX * vect(1,0,0);
		DrawOffset.Y += 20 * PawnList[i].Position - 10;
		DrawOffset = DrawOffset >> DrawRot;
		PawnList[i].SetLocation(DrawLoc + DrawOffset);
		Canvas.DrawActor(PawnList[i], false);
	}
}

