程序清单8-15 宝石对象的Update函数,将_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;
}
}