程序清單8-15 寶石對象的Update函數(shù),將_fallDistance遞減使寶石能夠下落
/// <summary>
/// Update the gem's position
/// </summary>
public override void Update()
{
// Allow the base class to perform any processing it needs
base.Update();
switch (_gemType)
{
case GemTypes.NextGem:
// If this gem is part of the "next piece" display then there
// is nothing for us to do as these gems don't move
break;
case GemTypes.OnTheBoard:
// To do...
break;
case GemTypes.PlayerControlled:
// This gem is under player control so allow it to gently drop
// towards the bottom of the board.
// We'll let the game itself work out how to deal with it landing,
// etc.
_fallDistance -= _fallSpeed;
break;
}
}