本文整理汇总了C#中GameEntity.AppendController方法的典型用法代码示例。如果您正苦于以下问题:C# GameEntity.AppendController方法的具体用法?C# GameEntity.AppendController怎么用?C# GameEntity.AppendController使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类GameEntity
的用法示例。
在下文中一共展示了GameEntity.AppendController方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Control
public override bool Control( GameEntity control, TimeSpan gameTime, Microsoft.Xna.Framework.Input.KeyboardState keyState )
{
if ( control is Projectile )
{
HashSet<Tank> tanks = new HashSet<Tank>();
if ( control.Variables.ContainsKey( "Hypnotize" ) )
{
tanks = ( ( HashSet<Tank> )control.Variables[ "Hypnotize" ] );
}
if ( Vector2.Distance( control.Position, Owner.Position ) < rad )// && !Tools.IsGoingTowardsMe( Owner.Position, control.Angle, control.Position ) )
{
if ( !control.Variables.ContainsKey( "Hypnotize" ) || !tanks.Contains( Owner ) )
{
DeflectorController d = new DeflectorController( Tools.Angle( Owner.Position, control.Position ) );
control.AppendController( d );
tanks.Add( Owner );
}
}
else
{
tanks.Remove( Owner );
}
control.Variables[ "Hypnotize" ] = tanks;
}
return base.Control( control, gameTime, keyState );
}
示例2: InstantControl
public override void InstantControl( GameEntity control, TimeSpan gameTime )
{
float closestDistance = -1; // The distance to the closest tank
Tank closestTank = null; // The closest tank
// Find the closest living tank
foreach ( Tank t in Tanks )
{
float dist = Vector2.DistanceSquared( Owner.Position, t.Position );
if ( t.IsAlive )
{
if ( ( closestTank == null || dist < closestDistance ) )
{
closestDistance = dist;
closestTank = t;
}
}
}
if ( closestTank != null ) // If no tank is alive don't do anything
{
// Set owner's angle
float ang = Tools.Angle( control.Position, closestTank.Position );
DeflectorController c = new DeflectorController( ang );
control.AppendController( c );
}
}