Exemplo n.º 1
0
        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;
            }
        }
Exemplo n.º 2
0
        public override void AddedToFieldHook()
        {
            base.AddedToFieldHook();

            //Is always shooting downwards
            AddStrategy(new Shooting
                        (
                            owner: this
                            , shootingInterval: 10
                            , weaponCallback: () => Weapon
                            , bulletFocusPosition: () => BulletFocusPosition
                            , angleCallback: () => Utility.RandomBetween(160, 200)
                        )
            {
                IsShooting = true
            });

            //Immediately rotates towards the vertical orientation direction
            AddStrategy(new TargetAngleRotation
                        (
                            owner: this
                            , verticalOrientation: Direction.Vertical
                            , angleDeltaCount: 1
                            , maxAngleDegrees: 0
                        )
            {
                TargetAngleRadians = AbstractRotation.DegreesToRadians(0)
            });

            AddStrategy(new EveryNActs
                        (
                            callback: () =>
            {
                var bomb   = new Doomday(Field.Player);
                bomb.X     = BulletFocusPosition.X + Utility.RandomBetween(-1, 1) * (float)bomb.Width;
                bomb.Y     = BulletFocusPosition.Y;
                bomb.Speed = 0.4f * Utility.RandomBetween(1, 5);
                Field.AddActor(bomb);
            }
                            , interval: 80
                        ));

            //Custom Thrust
            new Thrust(this);
        }
Exemplo n.º 3
0
 float VerticalSpeed(float Angle)
 {
     return(Speed * (float)Math.Cos(AbstractRotation.DegreesToRadians(Utility.NormalizeDegreeAngle(Angle))));
 }
Exemplo n.º 4
0
 //Current speed in a chosen direction based on angular calculations
 float HorizontalSpeed(float Angle)
 {
     return(Speed * (float)Math.Sin(AbstractRotation.DegreesToRadians(Utility.NormalizeDegreeAngle(Angle))));
 }
Exemplo n.º 5
0
        protected override void DrawAbstractModification(ref ICanvasImage bitmap, CanvasDrawingSession draw)
        {
            base.DrawAbstractModification(ref bitmap, draw);

            AbstractRotation.DrawModification(ref bitmap, draw, AbstractRotation.DegreesToRadians(Angle));
        }