Some minor improvements.

This commit is contained in:
Dean Herbert 2017-04-05 20:00:22 +09:00
parent 8d16e1efa2
commit 863dc44c4d
No known key found for this signature in database
GPG Key ID: 46D71BF4958ABB49
2 changed files with 14 additions and 10 deletions

View File

@ -60,8 +60,8 @@ public float TriangleScale
protected override void LoadComplete()
{
base.LoadComplete();
for (int i = 0; i < aimTriangleCount; i++)
addTriangle(true);
addTriangles(true);
}
private int aimTriangleCount => (int)(DrawWidth * DrawHeight * 0.002f / (triangleScale * triangleScale) * SpawnRatio);
@ -83,8 +83,8 @@ protected override void Update()
t.Expire();
}
while (CreateNewTriangles && Children.Count() < aimTriangleCount)
addTriangle(false);
if (CreateNewTriangles)
addTriangles(false);
}
protected virtual Triangle CreateTriangle()
@ -113,12 +113,16 @@ protected virtual Triangle CreateTriangle()
protected virtual Color4 GetTriangleShade() => Interpolation.ValueAt(RNG.NextSingle(), ColourDark, ColourLight, 0, 1);
private void addTriangle(bool randomY)
private void addTriangles(bool randomY)
{
var sprite = CreateTriangle();
float triangleHeight = sprite.DrawHeight / DrawHeight;
sprite.Position = new Vector2(RNG.NextSingle(), randomY ? RNG.NextSingle() * (1 + triangleHeight) - triangleHeight : 1);
Add(sprite);
int addCount = aimTriangleCount - Children.Count();
for (int i = 0; i < addCount; i++)
{
var sprite = CreateTriangle();
float triangleHeight = sprite.DrawHeight / DrawHeight;
sprite.Position = new Vector2(RNG.NextSingle(), randomY ? RNG.NextSingle() * (1 + triangleHeight) - triangleHeight : 1);
Add(sprite);
}
}
}
}

View File

@ -155,7 +155,7 @@ public string Text
public void MarkAllRead()
{
notifications.Children.ForEach(n => n.Read = true);
notifications?.Children.ForEach(n => n.Read = true);
}
}
}