本文整理汇总了C#中GameEntity.ForceDestroy方法的典型用法代码示例。如果您正苦于以下问题:C# GameEntity.ForceDestroy方法的具体用法?C# GameEntity.ForceDestroy怎么用?C# GameEntity.ForceDestroy使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类GameEntity
的用法示例。
在下文中一共展示了GameEntity.ForceDestroy方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Control
public override bool Control( GameEntity control, TimeSpan gameTime, Microsoft.Xna.Framework.Input.KeyboardState keyState )
{
if ( !control.Variables.ContainsKey( "VacuumSpeed" ) )
{
control.Variables[ "VacuumSpeed" ] = baseSpeed;
}
float vacSpeed = ( float )control.Variables[ "VacuumSpeed" ];
float d = Vector2.Distance( Owner.Position, control.Position );
if ( d * 2 <= Owner.GameWidth + Owner.GameHeight )
{
control.Variables.Remove( "VacuumSpeed" );
control.ForceDestroy();
}
else
{
control.Move( vacSpeed, Tools.Angle( control, Owner ) );
if ( spiral )
{
control.Move( vacSpeed + 10, Tools.Angle( control, Owner ) + 90 );
}
}
if ( vacSpeed < maxSpeed )
{
vacSpeed += acceleration;
}
else
{
vacSpeed = maxSpeed;
}
control.Variables[ "VacuumSpeed" ] = vacSpeed;
if ( t != null )
{
Tank ta = ( Tank )Owner;
if ( !Game.HasController( this ) )
{
destroyTime += 1;
if ( destroyTime > 1000 )
{
ta.RemoveTankController();
}
}
}
return true;
}
示例2: Control
public override bool Control( GameEntity control, TimeSpan gameTime, KeyboardState keyState )
{
if ( !control.Variables.ContainsKey( "VacuumSpeed" ) )
{
control.Variables[ "VacuumSpeed" ] = baseSpeed;
}
float vacSpeed = ( float )control.Variables[ "VacuumSpeed" ]; // The current pull speed
float d = Vector2.Distance( Position, control.Position ); // The current distance
if ( d <= 16 * Scale ) // if the distance is smaller than that value, the entity is inside the black hole and therefore should be destroyed.
{
// Destroy
control.Variables.Remove( "VacuumSpeed" );
control.ForceDestroy();
}
else // Else the control is outside so do the orbit
{
control.Move( vacSpeed, Tools.Angle( control.Position, Position ) ); // The pull
control.Move( vacSpeed + spiralFactor, Tools.Angle( control.Position, Position ) + 90 ); // The turn
}
// Accelerate the pull speed
vacSpeed += acceleration;
if ( vacSpeed > maxSpeed && maxSpeed >= 0 )
{
// Limit the pull speed from the top
vacSpeed = maxSpeed;
}
if ( vacSpeed < minSpeed && minSpeed >= 0 )
{
// Limit the pull speed from the bottom
vacSpeed = minSpeed;
}
control.Variables[ "VacuumSpeed" ] = vacSpeed;
return true;
}