Beispiel #1
0
 public override void Update()
 {
     if (Position != Target)
     {
         float targetRotation = VectorHelpers.GetRotationToFace(PositionVector, new Vector2(Target.X, Target.Y)) ?? Rotation;
         if (Rotation == targetRotation)
         {
             PositionVector = VectorHelpers.MoveInDirection(PositionVector, targetRotation, MovementSpeed);
         }
         Rotation = targetRotation;
     }
 }
Beispiel #2
0
        public override void Draw(SpriteBatch spriteBatch)
        {
            int x = Position.X - Sprites.A10.Width / 2;
            int y = Position.Y - Sprites.A10.Height / 2;

            spriteBatch.Draw(Sprites.Shadow.Texture, new Rectangle(x, y + FlyingHeight, Sprites.Shadow.Width, Sprites.Shadow.Height), Color.White);

            if (TsGame.DebugEnabled)
            {
                SpriteHelper.DrawLine(spriteBatch, PositionVector, VectorHelpers.MoveInDirection(PositionVector, Rotation, 50), Color.White, ZOrder.Debug);
            }

            base.Draw(spriteBatch);
        }
Beispiel #3
0
        public override void Update()
        {
            Point   target = TargetEntity != null ? TargetEntity.Position : Target;
            Vector2 targetPositionVector = new Vector2(target.X, target.Y);

            float rotationDiff = VectorHelpers.FindRotationAdjustment(PositionVector, targetPositionVector, Rotation);
            float turnFactor   = Math.Min(TurnRate / Math.Abs(rotationDiff), 1);
            float amountToTurn = rotationDiff * turnFactor;

            Rotation += amountToTurn;

            float distanceToTarget = Vector2.Distance(targetPositionVector, PositionVector);
            float distanceToFly    = Math.Min(distanceToTarget, MovementSpeed);

            PositionVector = VectorHelpers.MoveInDirection(PositionVector, Rotation, distanceToFly);

            if (Vector2.Distance(targetPositionVector, PositionVector) < ExplosionRadius)
            {
                Explode();
            }
        }
Beispiel #4
0
        public override void Update()
        {
            A10   a10           = World.GetEntities <A10>().First();
            float a10Distance   = Vector2.Distance(a10.PositionVector, PositionVector);
            float rotationToA10 = VectorHelpers.GetRotationToFace(PositionVector, a10.PositionVector) ?? Rotation;

            if (a10Distance < ShootRange && State != InfantryState.Shoot && World.Ticks >= LastShotTicks + TicksBetweenShots)
            {
                State             = InfantryState.Shoot;
                EnteredStateTicks = World.Ticks;
                LastShotTicks     = World.Ticks;
            }
            else if (a10Distance < ShootRange && State != InfantryState.Shoot && State != InfantryState.Aiming && World.Ticks < LastShotTicks + TicksBetweenShots)
            {
                State             = InfantryState.Aiming;
                EnteredStateTicks = World.Ticks;
            }
            else if (a10Distance < ChaseRange && State == InfantryState.Stand)
            {
                State             = InfantryState.Run;
                EnteredStateTicks = World.Ticks;
            }
            else if (a10Distance < ChaseRange && a10Distance > ShootRange && (State == InfantryState.Shoot || State == InfantryState.Aiming))
            {
                State             = InfantryState.Run;
                EnteredStateTicks = World.Ticks;
            }
            else if (a10Distance > ChaseRange && State != InfantryState.Stand)
            {
                State             = InfantryState.Stand;
                EnteredStateTicks = World.Ticks;
                Rotation          = MathHelper.Pi;
            }

            if (State == InfantryState.Stand)
            {
                // ?
            }
            else if (State == InfantryState.Run)
            {
                Rotation       = rotationToA10;
                PositionVector = VectorHelpers.MoveInDirection(PositionVector, Rotation, MovementPerTick);
            }
            else if (State == InfantryState.Aiming)
            {
                Rotation = rotationToA10;
            }
            else if (State == InfantryState.Shoot)
            {
                Rotation = rotationToA10;
                if ((World.Ticks - EnteredStateTicks) % 64 == 48)
                {
                    Point        missileStartPosition = new Point(Position.X, Position.Y - 6);
                    SmallMissile smallMissile         = new SmallMissile(World, Player.Two, missileStartPosition, a10);
                    World.AddProjectile(smallMissile);
                    Sounds.Bazooka.Play();
                }
                if ((World.Ticks - EnteredStateTicks) % 64 == 63)
                {
                    State = InfantryState.Aiming;
                }
            }
        }
Beispiel #5
0
 public override void Update()
 {
     PositionVector = VectorHelpers.MoveInDirection(PositionVector, Rotation, MovementSpeed);
 }