private void AI_Thread() { try { while (!destroyed) { Thread.Sleep(ShootDelay); Point projectileLocation = new Point(Sprite.Location.X + (Sprite.Width / 2), Sprite.Location.Y + (Sprite.Height / 2)); Missile m = new Missile(this, projectileLocation, player); if (MissileFiredEvent != null) { if (controller != null) { controller.BeginInvoke(MissileFiredEvent, m); } else//sinon, classe mère exécute évènement { MissileFiredEvent(m); } } } } catch (Exception e) { Debug.WriteLine(e); } }
private void CheckforSecond() { if (secondTimer != 60) secondTimer++; if (secondTimer >= 60) { if (currentKeyboardState.IsKeyDown(Keys.Space) || GamePad.GetState(PlayerIndex.One).Buttons.RightShoulder == ButtonState.Pressed) { if (collision.missileCount > 0) { Missile missile = new Missile(); missile.Initialize(GraphicsDevice.Viewport, missileTexture, player.Position + new Vector2(player.Width / 2, 0)); missiles.Add(missile); collision.missileCount = collision.missileCount - 1; secondTimer = 0; } } } }
private void AddMissile(Missile m) { AddGameObject(m); m.GameObjectMoved += new GameObject.MovedEventHandler(UpdateGameObjectLocation); }