public Projectile Shoot(Projectile.ProjectileType pt, Direction d)
        {
            Point projectileLocation = new Point(Sprite.Location.X + (Sprite.Width / 2), Sprite.Location.Y + (Sprite.Height / 2));
            Projectile pr = new Projectile();
            switch (pt)
            {
                case Projectile.ProjectileType.Bullet:
                    pr = new Bullet(this, projectileLocation);
                    pr.Direction = d;
                    pr.SetController(controller);
                    pr.StartMoving();
                    break;

                case Projectile.ProjectileType.Laser:
                    if (d != Direction.Stop)
                    {
                        pr = new Laser(this, projectileLocation, d);
                        pr.SetController(controller);
                        pr.StartMoving();
                    }
                    break;

                //case Projectile.ProjectileType.Missile:
                //    pr = new Missile(this, projectileLocation, GetRandomEnemy(this));
                //    pr.SetController(controller);
                //    pr.StartMoving();
                //    break;
            }
            return pr;
        }
Exemple #2
0
 private void AddProjectile(Vector2 position)
 {
     Projectile projectile = new Projectile();
     projectile.Initialize(GraphicsDevice.Viewport, projectileTexture, position);
     projectiles.Add(projectile);
 }
 private void UpdatePorParser(string parsa)
 {
     if (!string.IsNullOrEmpty(parsa))
     {
         string[] arr = parsa.Split('@');
         string p1 = arr[0];
         string p2 = arr[1];
         if (!string.IsNullOrEmpty(p1))
         {
             arr = p1.Split('*');
             string balas1 = arr[0];
             string dp1 = arr[1];
             arr = dp1.Split('%');
             player.Health = Convert.ToInt32(arr[1]);
             string[] pos = arr[0].Split(',');
             player.Position.X = Convert.ToInt32(pos[0]);
             player.Position.Y = Convert.ToInt32(pos[1]);
             arr = balas1.Split('|');
             List<Projectile> lista = new List<Projectile>();
             for(int i = 0;i<arr.Length;i++){
                 string []tmp = arr[i].Split(',');
                 Projectile projectile = new Projectile();
                 projectile.Initialize(GraphicsDevice.Viewport, projectileTexture, new Vector2(Convert.ToInt32(arr[0]), Convert.ToInt32(arr[1])), 1);
                 lista.Add(projectile);
             }
             projectiles = lista;
         }
         if (!string.IsNullOrEmpty(p2))
         {
             arr = p2.Split('*');
             string balas2 = arr[0];
             string dp2 = arr[1];
             arr = dp2.Split('%');
             player2.Health = Convert.ToInt32(arr[1]);
             string[] pos = arr[0].Split(',');
             player2.Position.X = Convert.ToInt32(pos[0]);
             player2.Position.Y = Convert.ToInt32(pos[1]);
             arr = balas2.Split('|');
             List<Projectile> lista = new List<Projectile>();
             for (int i = 0; i < arr.Length; i++)
             {
                 string[] tmp = arr[i].Split(',');
                 Projectile projectile = new Projectile();
                 projectile.Initialize(GraphicsDevice.Viewport, projectileTexture, new Vector2(Convert.ToInt32(arr[0]), Convert.ToInt32(arr[1])), 1);
                 lista.Add(projectile);
             }
             projectiles2 = lista;
         }
     }
 }
Exemple #4
0
 private void AddProjectile(Vector2 position)
 {
     Projectile projectile = new Projectile();
     projectile.Initialize(GraphicsDevice.Viewport, projectileTexture, position);
     projectile.xmove = currentGamePadState.ThumbSticks.Right.X * 10.0f;
     projectile.ymove = currentGamePadState.ThumbSticks.Right.Y * 10.0f;
     projectiles.Add(projectile);
 }
Exemple #5
0
        private void AddProjectile(Vector2 position)
        {
            Projectile projectile = new Projectile();
            projectile.Initialize(GraphicsDevice.Viewport, projectileTexture, position);
            projectiles.Add(projectile);

            /*
            if(levelUp == true)
            {
                projectile.Damage = projectile.Damage + 20;
                projectile.projectileMoveSpeed = projectile.projectileMoveSpeed + 2;
            }
             */
        }
Exemple #6
0
        /// <summary>
        /// Allows the game to run logic such as updating the world,
        /// checking for collisions, gathering input, and playing audio.
        /// </summary>
        /// <param name="gameTime">Provides a snapshot of timing values.</param>
        protected override void Update(GameTime gameTime)
        {
            KeyboardState keys = Keyboard.GetState();

            if(startScreenIsOn == true)
            {
                if (keys.IsKeyDown(Keys.Enter))
                {
                    startScreenIsOn = false;
                    LoadContent();
                }
            }

            if(endScreenIsOn == true)
            {
                if (keys.IsKeyDown(Keys.Escape))
                {
                    Initialize();
                }
            }

            if (startScreenIsOn == false && endScreenIsOn == false)
            {
                // Allows the game to exit
                if (GamePad.GetState(PlayerIndex.One).Buttons.Back == ButtonState.Pressed)
                    this.Exit();

                // Save the previous state of the keyboard and game pad so we can determinesingle key/button presses
                // previousGamePadState = currentGamePadState;
                previousKeyboardState = currentKeyboardState;

                // Read the current state of the keyboard and gamepad and store it
                currentKeyboardState = Keyboard.GetState();
                //currentGamePadState = GamePad.GetState(PlayerIndex.One);

                UpgradeObject upgradeObject2 = new UpgradeObject();
                Enemy enemy2 = new Enemy();
                Projectile projectile2 = new Projectile();

                UpdateUpgradeSprite(gameTime);

                //Update the player
                UpdatePlayer(gameTime);

                // Update the parallaxing background
                bgLayer1.Update();
                //bgLayer2.Update();

                // Update the enemies
                UpdateEnemies(gameTime);

                if (score >= metScore)
                {
                    levelChange();
                }

                UpdateCollision();

                // Update the projectiles
                UpdateProjectiles();

                UpdateUpgradeObjects(gameTime);

                // Update the explosions
                UpdateExplosions(gameTime);

                base.Update(gameTime);
            }
        }
Exemple #7
0
        private void AddProjectile(Vector2 position)
        {
            Projectile projectile;
            switch (nivelTiro)
            {
                case 0:
                case 1:
                    projectile = new Projectile();
                    projectile.Initialize(GraphicsDevice.Viewport, projectileTexture, position + new Vector2(100,35));
                    projectiles.Add(projectile);
                    break;

                case 2:
                    projectile = new Projectile();
                    projectile.Initialize(GraphicsDevice.Viewport, projectileTexture, position + new Vector2(100,0));
                    projectiles.Add(projectile);

                    projectile = new Projectile();
                    projectile.Initialize(GraphicsDevice.Viewport, projectileTexture, position + new Vector2(100,70));
                    projectiles.Add(projectile);

                    break;

                case 3:
                    projectile = new Projectile();
                    projectile.Initialize(GraphicsDevice.Viewport, projectileTexture, position + new Vector2(100,0));
                    projectiles.Add(projectile);

                    projectile = new Projectile();
                    projectile.Initialize(GraphicsDevice.Viewport, projectileTexture, position + new Vector2(100,35));
                    projectiles.Add(projectile);

                    projectile = new Projectile();
                    projectile.Initialize(GraphicsDevice.Viewport, projectileTexture, position + new Vector2(100,70));
                    projectiles.Add(projectile);

                    break;
            }
        }
Exemple #8
0
 private void AddProjectile(Vector2 position)
 {
     Projectile pro = new Projectile();
     pro.Initialize(projectileTexture, position);
     projectiles.Add(pro);
     laserSound.Play();
 }