public override void AddedToFieldHook() { base.AddedToFieldHook(); //Strategy that does not automatically rotate but instead, needs to be rotated manually TargetRotationStrategy = new TargetAngleRotation ( owner: this , verticalOrientation: Direction.Vertical , angleDeltaCount: 45 , maxAngleDegrees: 160 ); //Initialization of the default Shooting parameters via strategy AddStrategy(new Shooting ( owner: this , shootingInterval: 10 , weaponCallback: () => Weapon , bulletFocusPosition: () => BulletFocusPosition , angleCallback: () => TargetRotationStrategy.CurrentAngleDegrees ) { IsShooting = true }); //Every N acts looks at the Player's position and rotates towards approximately towards him AddStrategy(new EveryNActs ( callback: () => { float angle = TargetActorAngleRotation.AngleBetweenActorsRadians(this, Field.Player, true); //Some additional variance angle += AbstractRotation.DegreesToRadians(Utility.RandomBetween(-30, 30)); TargetRotationStrategy.TargetAngleRadians = angle; } , interval: 40 )); AddStrategy(TargetRotationStrategy); //Custom Thrust new Thrust(this); //Starts moving in the opposite direction than where he spawned from if (X < Field.Size.Width / 2) { Direction += SpaceDirection.HorizontalDirection.RIGHT; } else { Direction += SpaceDirection.HorizontalDirection.LEFT; } }
public override void AddedToFieldHook() { base.AddedToFieldHook(); TargetActorAngleRotation rotationStrategy = new TargetActorAngleRotation ( owner: this , target: Field.Player , verticalOrientation: Direction.Vertical , angleDeltaCount: 100 , maxAngleDegrees: 120 ); AddStrategy(rotationStrategy); //Initialization of the default Shooting parameters via strategy AddStrategy(new Shooting ( owner: this , shootingInterval: 30 , weaponCallback: () => Weapon , bulletFocusPosition: () => BulletFocusPosition , angleCallback: () => rotationStrategy.CurrentAngleDegrees ) { IsShooting = true }); AddStrategy(new Acceleration ( owner: this , deltaSpeed: 0.01f , targetSpeed: Speed * 4 )); //Custom Thrust new Thrust(this); //Starts moving in the opposite direction than where he spawned from if (X < Field.Size.Width / 2) { Direction += SpaceDirection.HorizontalDirection.RIGHT; } else { Direction += SpaceDirection.HorizontalDirection.LEFT; } }