Пример #1
0
        public void Move(HostileSub sub, int scrollingPosition)
        {
            if (sub.Position.X < (scrollingPosition + sub.Subby.Position.X + 200))
            {
                sub.MoveRight();
            }
            if (sub.Position.X > (scrollingPosition + sub.Subby.Position.X + 800))
            {
                sub.MoveLeft();
            }
            if (sub.Position.Y < sub.Boundaries.Top + 100)
            {
                sub.MoveDown();
            }
            if (sub.Position.Y > sub.Boundaries.Bottom - 100)
            {
                sub.MoveUp();
            }

            sub.Position += sub.Velocity;

            float dX = sub.Position.X - (scrollingPosition + sub.Subby.Position.X);
            float dY = sub.Position.Y - sub.Subby.Position.Y;

            sub.Rotation = (float)Math.Atan2(dY, dX);
        }
Пример #2
0
 public void Move(HostileSub sub, int scrollingPosition)
 {
     sub.Rotation = 0;
     if (sub.Position.X < (scrollingPosition + sub.Subby.Position.X + 400))
     {
         sub.MoveRight();
     }
     if (sub.Position.X > (scrollingPosition + sub.Subby.Position.X + 430))
     {
         sub.StopMoveSideways();
         if (sub.Velocity.Y == 0)
         {
             sub.MoveDown();
         }
     }
     if (sub.Position.Y < sub.Boundaries.Top + 30)
     {
         sub.MoveDown();
     }
     if (sub.Position.Y > sub.Boundaries.Bottom - 30)
     {
         sub.MoveUp();
     }
     sub.Position += sub.Velocity;
 }
Пример #3
0
 public bool Shoot(HostileSub sub, float totalTime)
 {
     if (totalTime > sub.ShootTimer)
     {
         sub.ShootTimer += 3;
         return true;
     }
     return false;
 }