Silverlight游戏编程:使用Silverlight 3.0实现贪吃蛇游戏(c#)(4)
#region 属性 public DirectionMoveDirection { set { Bodyhead = _bodies.First().Key; if (head.MoveDirection == Direction.Up value == Direction.Down) return ; if (head.MoveDirection == Direction.Down v
#region 属性
public Direction MoveDirection
{
set
{
Body head = _bodies.First().Key;
if (head.MoveDirection == Direction.Up && value == Direction.Down)
return;
if (head.MoveDirection == Direction.Down && value == Direction.Up)
return;
if (head.MoveDirection == Direction.Left && value == Direction.Right)
return;
if (head.MoveDirection == Direction.Right && value == Direction.Left)
return;
_moveDirection = value;
}
}
public bool Enabled
{
get { return _enabled; }
set { _enabled = value; }
}
public double Speed
{
get { return _speed; }
set { _speed = value; }
}
public int AteCapacity
{
get { return _ateCapacity; }
set { _ateCapacity = value; }
}
#endregion
#region 事件 GameOver 和 Ate
public event EventHandler GameOver;
public event EventHandler Ate;
#endregion
}
}
[源码下载]
精彩图集
精彩文章