本文整理汇总了C#中Ball.Reset方法的典型用法代码示例。如果您正苦于以下问题:C# Ball.Reset方法的具体用法?C# Ball.Reset怎么用?C# Ball.Reset使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Ball
的用法示例。
在下文中一共展示了Ball.Reset方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Point
public void Point(Player scorer, Ball ball)
{
ball.Reset();
int score = scorer.GetScore() + 1;
scorer.SetScore(score);
bool swapped = false;
bool gameIsOver = false;
for (int i = 0; i < 3; i++)
{
if (players[i].isBall)
{
players[i].SetScore(players[i].GetScore() + 1);
}
else if (roundPoints(i) >= pointsPerRound)
{
swapped = true;
}
if (players[i].GetScore() >= pointsPerGame)
{
gameIsOver = true;
}
}
if (gameIsOver)
{
GameOver();
}
else if (swapped)
{
Swap (false);
ballWaitingForSwap = ball;
for (int p = 0; p < 3; p++)
{
roundStartPoints[p] = players[p].GetScore();
}
}
else
{
ball.SetMoveDelay();
}
}
示例2: Boundaries
/// <summary>
/// Prevents the ball from moving out of the screen.
/// </summary>
private void Boundaries(Ball b)
{
if (b.BoundingBox.Top < 0)
{
b.position.Y = b.Texture.Height / 2;
b.direction.Y *= -1;
}
if (b.BoundingBox.Bottom > Data.fieldSize.Y)
{
b.position.Y = Data.fieldSize.Y - b.Texture.Height / 2;
b.direction.Y *= -1;
}
if (b.BoundingBox.Left < 0)
{
b.position.X = b.Texture.Width / 2;
b.direction.X *= -1;
this.paddleRight.score += 1;
b.Reset(new Vector2(Data.fieldSize.X / 2 + 100, Data.fieldSize.Y / 2));
}
if (b.BoundingBox.Right > Data.fieldSize.X)
{
b.position.X = Data.fieldSize.X - b.Texture.Width / 2;
b.direction.X *= -1;
this.paddleLeft.score += 1;
b.Reset(new Vector2(Data.fieldSize.X / 2 - 100, Data.fieldSize.Y / 2));
}
}