public void UpdateFrame()
{
if (texture == null || topRacket == null || bottomRacket == null)
{
Start();
}
texture.DrawFilledRectangle(new Rect(0, 0, width, height), Color.clear);
var wallColor = Color.blue;
if (missCount > 0)
{
wallColor = Color.red;
missCount--;
}
texture.DrawFilledRectangle(new Rect(0, 0, wallWidth, height), wallColor);
texture.DrawFilledRectangle(new Rect(width - wallWidth, 0, wallWidth, height), wallColor);
balls = balls.FindAll((b) => b.Update());
topRacket.x = topRacketX;
topRacket.Update();
isTopRacketValid = topRacket.isValid;
bottomRacket.x = bottomRacketX;
bottomRacket.Update();
isBottomRacketValid = bottomRacket.isValid;
texture.Apply();
Status status = null;
try
{
status = gameObject.GetComponent <Status>() as Status;
}
catch (MissingReferenceException) { }
if (status != null)
{
if (status.ticks % 500 == 0 && !status.isGameover)
{
AddBall(Mathf.Sqrt(1 + status.ticks * 0.0003f));
}
if (status.isRestarting || status.isGameover)
{
balls.Clear();
if (status.isRestarting)
{
AddBall();
}
}
var bc = balls.Count;
if (isTopRacketValid)
{
status.tmpBallCount = bc;
}
else
{
status.tmpBallCount += bc;
}
if (isBottomRacketValid)
{
status.ballCount = status.tmpBallCount;
status.ticks++;
if (status.isRestarting)
{
status.isRestarting = false;
}
}
}
}