我正在尝试使6条鱼(左侧3条,右侧3条)彼此靠近。
我不太确定该怎么做。
下面的代码使6条鱼全部转圈,我想使用一个if语句,这样,当某事发生时(例如,屏幕上随机出现某物(chicken.leg!= null),鱼将停止转圈)并开始移向屏幕上出现的对象。
public override void Update(ref GameTime pGameTime)
{
Vector3 tokenPosition = this.PossessedToken.Position;
tokenPosition.X = tokenPosition.X + xSpeed;
this.PossessedToken.Position = tokenPosition;
this.PossessedToken.Orientation = new Vector3(mFacingDirectionX,
this.PossessedToken.Orientation.Y,
this.PossessedToken.Orientation.Z);
tokenPosition.Y = tokenPosition.Y + ySpeed;
this.PossessedToken.Position = tokenPosition;
this.PossessedToken.Orientation = new Vector3(mFacingDirectionX,
this.PossessedToken.Orientation.Y,
this.PossessedToken.Orientation.Z);
if (tokenPosition.X == -280 || tokenPosition.X == 320)
{
xSpeed = 1;
ySpeed = -1;
}
if (tokenPosition.Y == 120 || tokenPosition.Y == -180 || tokenPosition.Y == -30)
{
xSpeed = -1;
ySpeed = 0;
}
if (tokenPosition.X == -300 || tokenPosition.X == 300)
{
xSpeed = 1;
ySpeed = 1;
}
if (mAquarium.ChickenLeg != null)
{
xSpeed = 1;
}
}
我希望使用一堂课,左边的3条鱼向右走,右边的3条鱼向左走。