Пример #1
0
        public override void Update(GameTime gameTime)
        {
            if (Status == ObjectStatus.Active)
            {
                fireTime = fireTime.Subtract(gameTime.ElapsedGameTime);
                if (fireTime.TotalSeconds <= 0)
                {
                    canFire = true;
                    PlayScreen.AddGameObject(new Bullet(this, PlayScreen.view));
                    fireTime = TimeSpan.FromSeconds(1.5);
                }

                Velocity = new Vector2(targetPlayer.Position.X - Position.X,
                                       targetPlayer.Position.Y - Position.Y);
                NormalizeVelocity();

                Velocity = Vector2.Multiply(Velocity, Speed);

                Rotation = (float)(Math.Atan2(
                                       targetPlayer.Position.Y - Position.Y,
                                       targetPlayer.Position.X - Position.X));
            }


            base.Update(gameTime);
        }
Пример #2
0
        public PauseScreen(PlayScreen playscreen)
        {
            p      = playscreen;
            Parent = p;

            resume           = new MenuEntry(this, "Resume Game :)");
            quit             = new MenuEntry(this, "Quit :(");
            TransitionOnTime = TransitionOffTime = TimeSpan.FromSeconds(0.5);
        }
Пример #3
0
 public void HandleInput(InputSystem input)
 {
     Velocity = Vector2.Zero;
     if (input.useKeyboard)
     {
         if (input.MoveUp)
         {
             Velocity = new Vector2(Velocity.X, -Speed);
         }
         if (input.MoveDown)
         {
             Velocity = new Vector2(Velocity.X, Speed);
         }
         if (input.MoveLeft)
         {
             Velocity = new Vector2(-Speed, Velocity.Y);
         }
         if (input.MoveRight)
         {
             Velocity = new Vector2(Speed, Velocity.Y);
         }
     }
     else
     {
         Velocity = new Vector2(input.mousePositionMovment.X * 40f, input.mousePositionMovment.Y * 40f);
     }
     if (input.Shoot)
     {
         if (canFire)
         {
             canFire    = false;
             timeToFire = TimeSpan.FromSeconds(0.4);
             PlayScreen.AddGameObject(new Bullet(this, PlayScreen.view));
         }
     }
 }