Пример #1
0
        //Will get called by the main game Collision
        public void PickUp(Game1 game1)
        {
            switch (Name)
            {
                case "Ammo":
                    //Gives 30 ammo to the maingun and 15 to the sub weapon
                    if (game1.CurGun == "winchester")
                    {
                        game1.WinAmmo += 30;
                        game1.RevolverAmmo += 15;
                    }
                    else
                    {
                        game1.WinAmmo += 15;
                        game1.RevolverAmmo += 30;
                    }
                    break;
                case "Health":
                    if (game1.player.Health <= 50)
                    {
                        game1.player.Health += 50;
                    }
                    else
                        game1.player.Health = 100;
                    break;

            }

            //Ends with Active = False;
            Active = false;
        }
Пример #2
0
 /// <summary>
 /// The main entry point for the application.
 /// </summary>
 static void Main(string[] args)
 {
     using (Game1 game = new Game1())
     {
         game.Run();
     }
 }
Пример #3
0
        public void Update(GameTime gameTime, Game1 game1)
        {
            /// <summary>
            /// Moves 100 pixel ix x or y, and in the middle of the screen otherwise. 1280x720
            /// </summary>
            //AI
            // The enemy always moves to the correct position for it's placement
            if (Action == "Moving")
            {
                if (Position.X <= 1000)
                    Position.X += MoveSpeed;
                else
                    Action = "Shooting";
            } // End Moving Action While/IF
            if (Action == "Shooting")
            {
                //Vector2 target;
                //count for 5 bullets per update

                if (count == 60)
                {
                    SniperProjectile projectileS = new SniperProjectile();
                    projectileS.Initialize(game1.GraphicsDevice.Viewport, game1.EnemyBulletTexture, Position, game1.player.Position);
                    game1.sniperBullets.Add(projectileS);
                    //public void Initialize(Viewport viewport, Texture2D texture, Vector2 position, Vector2 Target)
                    //Projectile projectile = new Projectile();
                    //projectile.Initialize(GraphicsDevice.Viewport, projectileTexture, position, new Vector2(ms.X, ms.Y));
                    //projectiles.Add(projectile);
                    count = 0;
                    //end 5 bullet count
                }
                count += 1;
            } //End If Shooting

            // If the enemy is past the screen or its health reaches 0 then deactivate it
            if (Health <= 0)
            {
                // By setting the Active flag to false, the game will remove this objet fromthe
                // active game list
                Damage = 0;
                //game1.score += Value;
                Action = "Dying";

            }
            SniperAnimation.Update(gameTime, Action, Position);

            if (SniperAnimation.currentFrame > 2)
            {
                // By setting the Active flag to false, the game will remove this objet fromthe
                // active game list
                Active = false;
            }
        }
Пример #4
0
        public void Update(GameTime gameTime, Game1 game1)
        {
            if (Health >= 1)
            {
                if (gameTime.TotalGameTime - game1.BossSpawnTime > Interval && shootStop == false)
                {

                    Action = "Shooting";
                    if (Health >= 900)
                    {
                        if (count > 15)
                        {
                            count = 0;
                            Vector2 target;
                            //count for 5 bullets per update

                            target = game1.player.Position;
                            PamBossProjectile projectile = new PamBossProjectile();
                            projectile.Initialize(game1.GraphicsDevice.Viewport, game1.pamBossProjectile, Position, target, 7);
                            game1.pamBossProjectiles.Add(projectile);
                            shootCounter++;
                        }
                    }
                    else
                    {
                        Interval = TimeSpan.FromSeconds(3.0f);
                        PamBossProjectile projectile1 = new PamBossProjectile();
                        PamBossProjectile projectile2 = new PamBossProjectile();
                        PamBossProjectile projectile3 = new PamBossProjectile();
                        PamBossProjectile projectile4 = new PamBossProjectile();
                        //Shoots in an + then x pattern
                        Vector2 target = Vector2.Zero;
                        if (attackCount == 0) //+
                        {
                            target = new Vector2(Position.X, Position.Y + 1000);
                            projectile1.Initialize(game1.GraphicsDevice.Viewport, game1.pamBossProjectile, Position, target, 8); // Add Texture to game1
                            target = new Vector2(Position.X, Position.Y - 1000);
                            projectile2.Initialize(game1.GraphicsDevice.Viewport, game1.pamBossProjectile, Position, target, 8); // Add Texture to game1
                            target = new Vector2(Position.X + 1000, Position.Y);
                            projectile3.Initialize(game1.GraphicsDevice.Viewport, game1.pamBossProjectile, Position, target, 8); // Add Texture to game1
                            target = new Vector2(Position.X - 1000, Position.Y);
                            projectile4.Initialize(game1.GraphicsDevice.Viewport, game1.pamBossProjectile, Position, target, 8); // Add Texture to game1
                            game1.pamBossProjectiles.Add(projectile1);
                            game1.pamBossProjectiles.Add(projectile2);
                            game1.pamBossProjectiles.Add(projectile3);
                            game1.pamBossProjectiles.Add(projectile4);
                            shootCounter++;
                            attackCount = 1;
                        }
                        else if (attackCount == 1) //x
                        {
                            target = new Vector2(Position.X + 1000, Position.Y + 1000);
                            projectile1.Initialize(game1.GraphicsDevice.Viewport, game1.pamBossProjectile, Position, target, 8); // Add Texture to game1
                            target = new Vector2(Position.X - 1000, Position.Y - 1000);
                            projectile2.Initialize(game1.GraphicsDevice.Viewport, game1.pamBossProjectile, Position, target, 8); // Add Texture to game1
                            target = new Vector2(Position.X + 1000, Position.Y - 1000);
                            projectile3.Initialize(game1.GraphicsDevice.Viewport, game1.pamBossProjectile, Position, target, 8); // Add Texture to game1
                            target = new Vector2(Position.X - 1000, Position.Y + 1000);
                            projectile4.Initialize(game1.GraphicsDevice.Viewport, game1.pamBossProjectile, Position, target, 8); // Add Texture to game1
                            game1.pamBossProjectiles.Add(projectile1);
                            game1.pamBossProjectiles.Add(projectile2);
                            game1.pamBossProjectiles.Add(projectile3);
                            game1.pamBossProjectiles.Add(projectile4);
                            attackCount = 2;
                            //shootCounter++;

                        }
                        else if (attackCount == 2) //swirl hopefully
                        //should adjust by a counter that increments by 1 or 5

                            //Scratch that, add a random element to target

                        {
                            x = Rando.Next(0,1280); y = Rando.Next(0,640);
                            target = new Vector2(Position.X + x, Position.Y + y);
                            projectile1.Initialize(game1.GraphicsDevice.Viewport, game1.pamBossProjectile, Position, target, 8); // Add Texture to game1
                            x = Rando.Next(0, 1280); y = Rando.Next(0, 640);
                            target = new Vector2(Position.X - x, Position.Y - y);
                            projectile2.Initialize(game1.GraphicsDevice.Viewport, game1.pamBossProjectile, Position, target, 8); // Add Texture to game1
                            x = Rando.Next(0, 1280); y = Rando.Next(0, 640);
                            target = new Vector2(Position.X + x, Position.Y - y);
                            projectile3.Initialize(game1.GraphicsDevice.Viewport, game1.pamBossProjectile, Position, target, 8); // Add Texture to game1
                            x = Rando.Next(0, 1280); y = Rando.Next(0, 640);
                            target = new Vector2(Position.X - x, Position.Y + y);
                            projectile4.Initialize(game1.GraphicsDevice.Viewport, game1.pamBossProjectile, Position, target, 8); // Add Texture to game1
                            game1.pamBossProjectiles.Add(projectile1);
                            game1.pamBossProjectiles.Add(projectile2);
                            game1.pamBossProjectiles.Add(projectile3);
                            game1.pamBossProjectiles.Add(projectile4);
                            attackCount = 0;
                            //shootCounter++;
                            x += 5;
                            y += 5;
                            if (x > 100)
                            {
                                x = -100;
                            }
                            if (y > 100)
                            {
                                y = -100;
                            }
                        }
                    }
                    count++;
                    if (shootCounter >= 10)
                    {
                        shootStop = true;

                    }
                }

                else // slow crawl after player
                {
                    if (shootCounter >= 1)
                    {
                        shootCounter = 0;
                        count = 0;
                        game1.BossSpawnTime = gameTime.TotalGameTime;
                        shootStop = false;
                    }
                    if (attackCount > 50)
                        attackCount = 0;
                    //Action = "Moving";
                    if (Position.X > game1.player.Position.X)
                    {
                        Position.X -= BossMoveSpeed;
                        Action = "Down";
                    }
                    else
                    {
                        Position.X += BossMoveSpeed;
                        Action = "Up";
                    }
                    if (Position.Y > game1.player.Position.Y)
                    {
                        Position.Y -= BossMoveSpeed / 2;
                        Action = "Right";
                    }
                    else
                    {
                        Position.Y += BossMoveSpeed / 2;
                        Action = "Left";
                    }
                    PamBossAnimation.Position = Position;
                    //Action = "Moving"
                } // End Else Timer

            }
            else
            {

                Action = "Dying";
                game1.GameState = "Victory";
                if (dyingStop == true)
                {
                    game1.BossKill = true;
                    game1.BossSpawn = false;
                    game1.score += Value;
                    Active = false;

                }
            }
            PamBossAnimation.Update(gameTime, Action, Health, Position);
        }
Пример #5
0
        public void Update(GameTime gameTime, Game1 game1)
        {
            //AI
            // The enemy always moves to the left so decrement it's xposition

            //// Update the position of the Animation
            //Enemy dodges based on time
            //Every 5 seconds
            float elapsed = (float)gameTime.ElapsedGameTime.TotalSeconds;
            timer -= elapsed;
            if (timer < 0)
            {
                //Timer expired, execute action
                timer = TIMER;   //Reset Timer

                Action = "Dodging";
            }else{
                Action = "Moving";
            }

            // Update Animation
            if (Health <= 0 )
            {
                Action = "Dying";
                Damage = 0;

            }
            else if (Action == "Moving")
            {
                if (Position.X > game1.player.Position.X)
                {
                    Position.X -= enemyMoveSpeed;
                }
                else
                {
                    Position.X += enemyMoveSpeed;
                }
                if (Position.Y > game1.player.Position.Y)
                {
                    Position.Y -= enemyMoveSpeed/2;
                }
                else
                {
                    Position.Y += enemyMoveSpeed/2;
                }
                EnemyAnimation.Position = Position;
                //Action = "Moving"
            }
            else if (Action == "Dodging")
            {
                if (game1.player.Position.Y > Position.Y/* && game1.player.Position.Y > Position.Y*/)
                {
                    Position.Y += 50;
                    EnemyAnimation.Position = Position;
                }
                if (game1.player.Position.Y < Position.Y/* && game1.player.Position.Y > Position.Y*/)
                {
                    Position.Y -= 50;
                    EnemyAnimation.Position = Position;
                }
            }

            EnemyAnimation.Update(gameTime, Action, Position, game1);
            // If the enemy is past the screen or its health reaches 0 then deactivateit
            if (Position.X < -Width || EnemyAnimation.currentFrame == 8)
            {
                // By setting the Active flag to false, the game will remove this objet fromthe
                // active game list
                Active = false;
            }
        }
Пример #6
0
        public void Update(GameTime gameTime, string Action, Vector2 Position, Game1 game1)
        {
            if (Active != false)
            {
                this.position = Position;
                sourceRect = new Rectangle(currentFrame * spriteWidth, 0, spriteWidth, spriteHeight);

                if (Action == "Dying")
                {
                    if (timesDead == 0)
                    {
                        game1.score += 100;
                        timesDead = 1;
                    }

                    interval = 1000f;
                    if (currentFrame < 6)
                        currentFrame = 6;
                    timer += (float)gameTime.ElapsedGameTime.TotalMilliseconds;

                    if (timer > interval)
                    {

                        currentFrame++;

                        if (currentFrame > 7)
                        {
                            //game1.score += 100;
                            Active = false;

                        }
                        timer = 0f;
                    }
                }
                else if (Action == "Dodging")
                {
                    if (currentFrame < 3 && currentFrame > 5)
                    {
                        currentFrame = 3;
                    }
                    timer += (float)gameTime.ElapsedGameTime.TotalMilliseconds;
                    interval = 100f;
                    if (timer > interval)
                    {

                        currentFrame++;

                        if (currentFrame >= 5)
                        {
                            currentFrame = 3;
                        }
                        timer = 0f;
                    }
                }
                else if (Action == "Moving")
                {
                    if (currentFrame > 2)
                    {
                        currentFrame = 0;
                    }
                    timer += (float)gameTime.ElapsedGameTime.TotalMilliseconds;

                    if (timer > interval)
                    {

                        currentFrame++;

                        if (currentFrame >= 3)
                        {
                            currentFrame = 0;
                        }
                        timer = 0f;
                    }

                } //end Action Ifs

                //sourceRect.Y = 0;
                //sourceRect.X = currentFrame * 50;
                origin = new Vector2(sourceRect.Width / 2, sourceRect.Height / 2);
            }
        }
Пример #7
0
        public void Update(GameTime gameTime,  Game1 game1)
        {
            /// <summary>
            /// Moves 100 pixel ix x or y, and in the middle of the screen otherwise. 1280x720
            /// </summary>
            //AI
            // The enemy always moves to the correct position for it's placement
            if (Action == "Moving")
            {
                if (Direction == "Top") //640x100
                {
                    if (Position.X != 640)
                    {
                        if (Position.X > 640)
                        {
                            Position.X -= enemyMoveSpeed;

                        }
                        else if (Position.X < 640)
                        {
                            Position.X += enemyMoveSpeed;
                        }
                    }
                    else
                        move1 = true;

                    if (Position.Y <= 100 || Position.Y > 110)
                    {
                        if (Position.Y > 100)
                        {
                            Position.Y -= enemyMoveSpeed;
                        }
                        else if (Position.Y < 100)
                        {
                            Position.Y += enemyMoveSpeed;
                        }

                    }
                    else
                        move2 = true;
                }

                if (Direction == "Bottom") //640x620
                {
                    if (Position.X <= 640 || Position.X > 650)
                    {
                        if (Position.X > 640)
                        {
                            Position.X -= enemyMoveSpeed;
                        }
                        else if (Position.X < 640)
                        {
                            Position.X += enemyMoveSpeed;
                        }
                    }
                    else
                        move1 = true;
                    if (Position.Y <= 620 || Position.Y > 630)
                    {
                        if (Position.Y > 620)
                        {
                            Position.Y -= enemyMoveSpeed;
                        }
                        else if (Position.Y < 620)
                        {
                            Position.Y += enemyMoveSpeed;
                        }
                    }
                    else
                        move2 = true;
                }

                // Left And Right 1280x720
                if (Direction == "Left") //100x360
                {
                    if (Position.X <= 100 || Position.X >= 110)
                    {
                        if (Position.X > 100)
                        {
                            Position.X -= enemyMoveSpeed;
                        }
                        else if (Position.X < 100)
                        {
                            Position.X += enemyMoveSpeed;
                        }
                    }
                    else
                        move1 = true;
                    if (Position.Y <= 360 || Position.Y >= 370)
                    {
                        if (Position.Y > 360)
                        {
                            Position.Y -= enemyMoveSpeed;
                        }
                        else if (Position.Y < 360)
                        {
                            Position.Y += enemyMoveSpeed;
                        }
                    }
                    else
                        move2 = true;
                }
                if (Direction == "Right") //1180x360
                {
                    if ((Position.X <= 1180 || Position.X >= 1190) && (Position.Y <= 360 || Position.Y >= 370))
                    {
                        if (Position.X > 1180)
                        {
                            Position.X -= enemyMoveSpeed;
                        }
                        else if (Position.X < 1180)
                        {
                            Position.X += enemyMoveSpeed;
                        }
                        if (Position.Y > 360)
                        {
                            Position.Y -= enemyMoveSpeed;
                        }
                        else if (Position.Y < 360)
                        {
                            Position.Y += enemyMoveSpeed;
                        }
                    }
                    else
                        Action = "Shooting";
                }
                if (move1 == true && move2 == true) // stops the moving of the machine
                    Action = "Shooting";

            } // End Moving Action While/IF
            if(Action == "Shooting"){
                Vector2 target;
                 //count for 5 bullets per update

                target = Targeting();
                ToastProjectile projectile = new ToastProjectile();
                projectile.Initialize(game1.GraphicsDevice.Viewport, game1.toastTexture, Position, target);
                game1.ToastProjectiles.Add(projectile);
                //public void Initialize(Viewport viewport, Texture2D texture, Vector2 position, Vector2 Target)
                //Projectile projectile = new Projectile();
                //projectile.Initialize(GraphicsDevice.Viewport, projectileTexture, position, new Vector2(ms.X, ms.Y));
                //projectiles.Add(projectile);

                 //end 5 bullet count

            } //End If Shooting

            // If the enemy is past the screen or its health reaches 0 then deactivate it
            if (Health <= 0)
            {
                // By setting the Active flag to false, the game will remove this objet fromthe
                // active game list
                Damage = 0;
                //game1.score += Value;
                Action = "Dying";

            }
            ToasterAnimation.Update(gameTime, Action, Position, game1);

            if (ToasterAnimation.currentFrame > 8)
            {
                // By setting the Active flag to false, the game will remove this objet fromthe
                // active game list
                Active = false;
            }
        }
Пример #8
0
        public void Update(GameTime gameTime, Vector2 position, string Action, Game1 game1, ref bool shootStop, ref bool dyingStop)
        {
            if (Active != false)
            {
                this.position = Position;
                sourceRect = new Rectangle(currentFrame * spriteWidth, row * spriteHeight, spriteWidth, spriteHeight);

                if (Action == "Moving")
                {
                    row = 0;
                    interval = 250f;
                    if (currentFrame >= 6)
                        currentFrame = 0;
                    timer += (float)gameTime.ElapsedGameTime.TotalMilliseconds;

                    if (timer > interval)
                    {

                        currentFrame++;

                        timer = 0f;
                    }
                }
                else if (Action == "Shooting")
                {
                    row = 1;
                    if (currentFrame < 0 || currentFrame > 13)
                    {
                        currentFrame = 0;
                    }
                    timer += (float)gameTime.ElapsedGameTime.TotalMilliseconds;
                    interval = 200f;
                    if (timer > interval)
                    {

                        currentFrame++;

                        if (currentFrame >= 13)
                        {
                            currentFrame = 0;
                            shootStop = true;
                        }
                        timer = 0f;
                    }
                }
                else if (Action == "Dying")
                {
                    row = 2;
                    interval = 500f;
                    if (currentFrame >= 6)
                    {
                        currentFrame = 0;
                        dyingStop = true;
                    }

                    timer += (float)gameTime.ElapsedGameTime.TotalMilliseconds;

                    if (timer > interval)
                    {

                        currentFrame++;

                        timer = 0f;
                    }

                }
                origin = new Vector2(sourceRect.Width / 2, sourceRect.Height / 2);
            }
        }