using System;
using System.Collections.Generic;
using System.Linq;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Audio;
using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework.GamerServices;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input;
using Microsoft.Xna.Framework.Media;
using Microsoft.Xna.Framework.Net;
using Microsoft.Xna.Framework.Storage;


namespace WindowsGame1
{
    /// <summary>
    /// This is a game component that implements IUpdateable.
    /// </summary>

    public class bandit_data : Microsoft.Xna.Framework.GameComponent
    {
        public Texture2D monster;
        Random rnd1 = new Random();
        double end = 0;
        GraphicsDeviceManager graphics;
        public Rectangle[,] srcRect1 = new Rectangle[10, 11];
        double mon = 0;
        double StepDuration = 0;
        public int monsterW = 80;//怪物寬
        public int monsterH = 80;//怪物高
        public int[] monsterx = {1200,1200,1200,1200,1200,1200,1200};//怪物高
        public int[] monstery = new int[7];//怪物高
        public int[] monsterhp = {30, 30, 30, 30, 30, 30, 30};
        public Vector2 pos;
        SpriteBatch spriteBatch;
        public int monsterSeq = 0; // 
        public int[] monsterbool = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
      
        public int monsterStatus = 1;

        public bandit_data(Game game)
            : base(game)
        {


            for (int i = 0; i < 10; i++)
                for (int j = 0; j < 10; j++)
                {
                    srcRect1[i, j] = new Rectangle(j * monsterW, i * monsterH, monsterW, monsterH);
                }
            // TODO: Construct any child components here
        }

        /// <summary>
        /// Allows the game component to perform any initialization it needs to before starting
        /// to run.  This is where it can query for any required services and load content.
        /// </summary>
        public override void Initialize()
        {
            // TODO: Add your initialization code here

            base.Initialize();
        }


        /// <summary>
        /// Allows the game component to update itself.
        /// </summary>
        /// <param name="gameTime">Provides a snapshot of timing values.</param>
        public override void Update(GameTime gameTime)
        {
            end += gameTime.ElapsedGameTime.TotalSeconds;
            mon += gameTime.ElapsedGameTime.TotalSeconds;
            StepDuration += gameTime.ElapsedGameTime.TotalMilliseconds;
            if (StepDuration > 150)
            {
                StepDuration = 0;
                monsterSeq++;
                //monsterSeq = monsterSeq % 4;
            }
            
            for (int i = 0; i < 7; i++)
            {
                if (monsterbool[i] != 0 && monsterx[i]>=190 &&monsterhp[i]!=0)
                {
                    monsterx[i] = monsterx[i] - 1;
                }
            }
            if (mon >= 3 && end <= 50)
            {
                for (int i = 0; i < 7; i++)
                {
                    if (monsterbool[i] == 0 )
                    {
                        monstery[i] = 385 + (150 * rnd1.Next(0,4))-300;
                        monsterbool[i] = 1;
                        break;
                    }
                }
                mon = 0;
            }
            // TODO: Add your update code here

            base.Update(gameTime);
        }

      
    }

}
