Update private methods implementation.

This commit is contained in:
Huo Yaoyuan 2016-09-26 14:07:43 +08:00
parent 756e7a6a67
commit b4bb3d6317
1 changed files with 18 additions and 12 deletions

View File

@ -18,7 +18,19 @@ public abstract class KeyCounter : Container
public override string Name { get; }
public bool IsCounting { get; set; }
public int Count { get; private set; }
private int count;
public int Count
{
get { return count; }
private set
{
if (count != value)
{
count = value;
countSpriteText.Text = value.ToString(@"#,0");
}
}
}
private bool isLit;
public bool IsLit
@ -29,9 +41,9 @@ protected set
if (isLit != value)
{
isLit = value;
UpdateGlowSprite();
updateGlowSprite(value);
if (value && IsCounting)
IncreaseCount();
Count++;
}
}
}
@ -95,24 +107,18 @@ public override void Load()
Width = buttonSprite.Width;
}
private void UpdateGlowSprite()
private void updateGlowSprite(bool show)
{
if (IsLit)
if (show)
{
glowSprite.FadeIn(FadeTime);
textLayer.FadeColour(KeyDownTextColor, FadeTime);
}
else
{
glowSprite.FadeOut();
glowSprite.FadeOut(FadeTime);
textLayer.FadeColour(KeyUpTextColor, FadeTime);
}
}
private void IncreaseCount()
{
Count++;
countSpriteText.Text = Count.ToString(@"#,0");
}
}
}