private void Worker()
{
//int loopCounter = 0;
while (IsAlive && !_shutdown)
{
bool updateState = false;
if (_danceTimeout > 0)
{
_danceTimeout--;
if (_danceTimeout == 0)
{
_turn = Turn.Off;
}
else if ((_danceTimeout % (300 / _threadWaitTime)) == 0)
{
_turn = _turn == Turn.Left ? Turn.Right : Turn.Left;
}
updateState = true;
}
if (_flapTimeout > 0)
{
_flapTimeout--;
if (_flapTimeout == 0)
{
_flap = Flap.Off;
}
else if ((_flapTimeout % (300 / _threadWaitTime)) == 0)
{
_flap = _flap == Flap.Up ? Flap.Down : Flap.Up;
}
updateState = true;
}
if (_heartbeatTimeout > 0)
{
_heartbeatTimeout--;
if (_heartbeatTimeout == 0)
{
_heart = false;
}
else if ((_heartbeatTimeout % (100 / _threadWaitTime)) == 0)
{
_heart = !_heart;
}
updateState = true;
}
if (_rainbowTimeout > 0)
{
_rainbowTimeout--;
if (_rainbowTimeout == 0)
{
_currentColor = _targetColor;
}
else
{
_currentColor = (Color)(_rainbowTimeout % 7);
}
updateState = true;
}
//loopCounter++;
//if (loopCounter > (3000 / _threadWaitTime))
//{
// loopCounter = 0;
// updateState = true;
//}
if (updateState) {
UpdateState();
}
Thread.Sleep(_threadWaitTime);
}
}