public bonus(Vector2 location, Game1 game)
        {
            this.game = game;
            this.center = location;
            lastmovetime = game.time;

            speed=new Vector2(0,game.currentgame.generator.Next(50,100));
            type = game.currentgame.generator.Next(0, 9); //0 universal upgrade 1 missles 2rays 3machine gun, 4random,5shield,6speed,7 health, 8 power

            size.X = game.resources.bonus[type,1].Width;
            size.Y = game.resources.bonus[type,1].Height;
        }
 public sstring(Game1 game,Texture2D napis, bool ruchomy, int x, int y)
 {
     time = game.time;
     this.wave = 0;
     this.game = game;
     this.ruchomy = ruchomy;
     this.x = x;
     this.y = y;
     this.napis = napis;
     a = new Color(255, 255, 255, 255);
     steps=0;
     todelete = 0;
 }
        public smoke(int type, Vector2 center, Game1 game)
        {
            todelete = false;
            this.type = type;
            this.center = center;
            this.game = game;
            currentframe = 0;
            maxframe = 5;
            frametime = 150;
            if (type == 3 || type == 4 || type == 5)
            {
                maxframe = 17;
                frametime = 50;
            }

            if (type == 2)
            {
                frametime = 100;
            }
            lastframetime = game.time;
        }
 public settingsmenu(Game1 game)
 {
     this.game = game;
     back = new button(0, game);
 }
 public enemyship(Game1 game, int type)
 {
     color = new Color(255, 255, 255);
     this.game = game;
     destlocation = new Vector2(240, 150);
     center = new Vector2(240, -100);
     this.type = type+10;
     speed1d = 40;
     hp = 7000+(type*1000);
     fullhp = hp;
     speed1d = 200;
     maxframe = 15;
     currentframe = 1;
     lastframetime = game.time;
     lastmovetime = game.time;
     direction = game.methods.getdirection(center, destlocation);
     destdirection = direction;
     speed = game.methods.getspeed(speed1d, direction);
     this.size.X = game.resources.enemyship1[this.type, 1].Width;
     this.size.Y = game.resources.enemyship1[this.type, 1].Height-30;
     if (type == 12)
     {
         maxframe = 17;
     }
     if (type == 13)
     {
         maxframe = 19;
     }
 }
        public button(int type, Game1 game)
        {
            this.type = type;
            name = null;
            this.game = game;
            width = game.resources.specialbutton[type].Width;
            height = game.resources.specialbutton[type].Height;
            this.x = 460 - width;
            switch (type)
            {
                case 0:
                    this.y = 800-48;
                    this.x = 0;
                    break;
                case 1:
                    this.y = 260;
                    break;
                case 2:
                    this.y = 290 + 60;
                    break;
                case 3:
                    this.y = 290 + 180 ;
                    break;
                case 4:
                    this.y = 290 + 120;
                    break;
                case 5:
                    this.y = 290 + 240;
                    break;
                case 6:
                    this.y = 290 + 300;
                    break;

            }
        }
 public statemgr(Game1 gra)
 {
     currentstate = 1;
 }
 public playership(Game1 game)
 {
     power = 0;
     maxpower = 0.5f;
     suse = true;
     sactivatetime = game.time;
     susingtime = 5000;
     destroyed = false;
     this.game = game;
     timeofresp = 1000;
     speed = new Vector2(0,0);
     location = new Vector2(240, 500);
     minx = 10;
     miny = 10;
     maxx = 480;
     maxy = 600;
     currentframe = 0;
     maxframe = 0;
     a = 20;
     maxa = 70;
     maxspeed = 15;
     guntype = 1;
     gunlevel = 2;
     maxgunlvl = 3;
 }
        public enemymissle(Game1 game, Vector2 location, int type, bool rot)
        {
            roting=rot;
            this.type = type;
            center = location;
            this.game = game;
            Random a = new Random();
            speed1d = 100;
            speed = game.methods.getspeed(speed1d,game.methods.getdirection(center,game.currentgame.ship.location));

            size.X = game.resources.enemybulet[type].Width;
            size.Y = game.resources.enemybulet[type].Height;
        }
 public Menu(Game1 game)
 {
     this.game = game;
     game.aboutMenu = new aboutmenu(game);
     game.settings = new settingsmenu(game);
     game.scores = new hiscoremenu(game);
 }
 public missle(Game1 game,Vector2 location,int type, float kierunek)
 {
     speed1d = 0;
     this.type = type;
     a = 40;
     this.kierunek = kierunek;
     this.game = game;
     this.size.X = game.resources.missle1[type].Width;
     this.size.Y = game.resources.missle1[type].Height;
     this.location.X = location.X - 0.5f * size.X;
     this.location.Y = location.Y + 0.5f * size.Y;
     center = location;
     todelete = false;
     speed = new Vector2();
     switch (type) //type 0,1,2 missles, 3,4,rays 5 machinegun
     {
         case 0:
             power = 100+(int)(game.currentgame.ship.power*30f);
             maxspeed = 120;
             color = Color.White;
             break;
         case 1:
             power = 150 + (int)(game.currentgame.ship.power * 60f);
             maxspeed = 110;
             color = Color.White;
             break;
         case 2:
             power = 100 + (int)(game.currentgame.ship.power * 50f);
             maxspeed = 200;
             color = Color.White;
             break;
         case 3:
             power = 30 + (int)(game.currentgame.ship.power * 10f);
             maxspeed = 300;
             color = Color.White;
             size.X = 5;
             break;
         case 4:
             power = 40 + (int)(game.currentgame.ship.power * 10f);
             maxspeed = 330;
             color = Color.White;
             size.X = 5;
             break;
         case 5:
             power = 8 + (int)(game.currentgame.ship.power * 10f);
             maxspeed = 1000;
             color = Color.White;
             break;
     }
     speed = game.methods.getspeed(speed1d, kierunek);
 }
        public hiscoremenu(Game1 game)
        {
            scores = new int[5];
            this.game = game;
            back = new button(0, game);
            string datafolder = "Data";
            string filename = "scores.txt";
            bool freshfolder = false;
            using(IsolatedStorageFile file = IsolatedStorageFile.GetUserStoreForApplication())
            {
                string filepath = System.IO.Path.Combine(datafolder, filename);
                if (file.FileExists(filepath)==false)
                {
                    file.CreateDirectory(datafolder);
                    freshfolder = true;
                }

                if (freshfolder==true)
                {
                    using (IsolatedStorageFileStream s = file.CreateFile(filepath))
                    {

                            StreamWriter writer = new StreamWriter(s);
                            writer.WriteLine("0");
                            writer.WriteLine("0");
                            writer.WriteLine("0");
                            writer.WriteLine("0");
                            writer.WriteLine("0");
                            writer.Close();

                    }
                }
                using (IsolatedStorageFileStream s2 = file.OpenFile(filepath, System.IO.FileMode.Open))
                {
                    StreamReader reader = new StreamReader(s2);
                    scores[0] = Convert.ToInt32(reader.ReadLine());
                    scores[1] = Convert.ToInt32(reader.ReadLine());
                    scores[2] = Convert.ToInt32(reader.ReadLine());
                    scores[3] = Convert.ToInt32(reader.ReadLine());
                    scores[4] = Convert.ToInt32(reader.ReadLine());
                    reader.Close();
                }
            }
        }
 public gamehud(Game1 game)
 {
     shortstrings = new List<sstring>();
        this.game = game;
        lasttime = this.game.time;
        laptime = 30;
        backgroundposition = -800;
        backgroundposition2 = 0;
 }
        public Game1()
        {
            ApplicationId = "a522c0b8-602d-445c-af77-94601b8f83a3";
            AdUnitId = "115278";
            pausetime = 0;
            time = 0;
            soundtime = 0;
            soundvolume = 3;
            dificulity = 1;
            fireplace = 1;
            graphics = new GraphicsDeviceManager(this);
            Content.RootDirectory = "Content";
            game = this;
            start = new startscreen(game);
            statemenager = new statemgr(game);
            hud = new gamehud(game);
            resources = new resourcesmgr();
            resources.getgame(game);
            methods = new usefullmethods();
            // Frame rate is 30 fps by default for Windows Phone.
            TargetElapsedTime = TimeSpan.FromTicks(333333);
            graphics.PreferredBackBufferWidth = 480;
            graphics.PreferredBackBufferHeight = 800;
            // Extend battery life under lock.
            InactiveSleepTime = TimeSpan.FromSeconds(1);
            using (IsolatedStorageFile file = IsolatedStorageFile.GetUserStoreForApplication())
            {
                string path = "full.txt";
                using (IsolatedStorageFileStream s = new IsolatedStorageFileStream(path, FileMode.OpenOrCreate, file))
                {
                    if (file.FileExists(path))
                    {
                        StreamReader reader = new StreamReader(s);
                        full = Convert.ToBoolean(reader.ReadLine());
                        reader.Close();
                    }
                    else
                    {
                        StreamWriter writer = new StreamWriter(s);
                        writer.WriteLine("0"); /////////////////////// 0 for lite, 1 for full
                        full = false;
                    }

                }

            }
        }
        public enemyship(Game1 game, int type, int lvl, Vector2 dest, Vector2 location)
        {
            this.noofsteps = 10;
            todelete = false;
            this.game = game;
            switch (type)
            {
                case 1:
                    rotationspeed = 1f;  //rozowy zwykly
                    shotrate = 0.002f* (1+game.dificulity);
                    speed1d = 50*(1+game.dificulity);
                    kamikadze = false;
                    naprowadzane = false;
                    break;
                case 2: //waz  w zarowce
                    rotationspeed = 1f;
                    shotrate = 0.002f*(1+game.dificulity);
                    speed1d = 50*(1+game.dificulity);
                    kamikadze = false;
                    naprowadzane = false;
                    break;
                case 3://pajak
                    rotationspeed = 0;
                    shotrate = 0.0005f*(1+game.dificulity);
                    speed1d = 70*(1+game.dificulity);;
                    kamikadze = false;
                    naprowadzane = false;
                    break;
                case 4://superman
                    rotationspeed = 0;
                    shotrate = 0;
                    speed1d = 0;
                    kamikadze = false;
                    naprowadzane = false;
                    break;
                case 5://czerwoneobracajace;
                    rotationspeed = 0;
                    shotrate = 0;
                    speed1d = 0;
                    kamikadze = false;
                    naprowadzane = false;
                    break;
                case 6://ufo
                    rotationspeed = 0;
                    shotrate = 0;
                    speed1d = 0;
                    kamikadze = false;
                    naprowadzane = false;
                    break;
                case 7://4katne obracajace
                    rotationspeed = 0;
                    shotrate = 0;
                    speed1d = 0;
                    kamikadze = false;
                    naprowadzane = false;
                    break;
                case 8://czarodzeij w ufo
                    rotationspeed = 0;
                    shotrate = 0;
                    speed1d = 0;
                    kamikadze = false;
                    naprowadzane = false;
                    break;
                case 9:// zolty statek
                    rotationspeed = 0;
                    shotrate = 0;
                    speed1d = 0;
                    kamikadze = false;
                    naprowadzane = false;
                    break;

            }

            hp = 100+(lvl*10);
            fullhp = hp;
            this.type = type;
            color = new Color(255, 255, 255, 255);
            lastmovetime = game.time;
            lastframetime = game.time+game.currentgame.generator.Next(0,850);
            currentframe = game.currentgame.generator.Next(1, 6);
            maxframe = 6;
            center = location;
            currentstep = 1;
            destlocation = dest;
            direction = game.methods.getdirection(center, dest);
            speed = game.methods.getspeed(speed1d, direction);

                this.size.X = game.resources.enemyship1[type, 1].Width;
                this.size.Y = game.resources.enemyship1[type, 1].Height;
        }
 public enemymissle(Game1 game, Vector2 location, float direction, bool rot)
 {
     roting = rot;
     type = 0;
     center = location;
     this.game = game;
     Random a = new Random();
     speed1d = 50 * (game.dificulity + 1) ;
     speed = game.methods.getspeed(speed1d, direction);
     size.X = game.resources.enemybulet[0].Width;
     size.Y = game.resources.enemybulet[0].Height;
 }
 public startscreen(Game1 game)
 {
     this.game = game;
 }
 public void getgame(Game1 game)
 {
     this.game = game;
     strikes = new strike[3];//no of strikes;
     int l1 = 0;
     do
     {
         strikes[l1] = new strike();
         l1 = l1 + 1;
     } while (l1 < 3);//no of strikes;
 }
 public aboutmenu(Game1 game)
 {
     this.game = game;
     back = new button(0, game);
 }
 public rubbish(Game1 game, Vector2 center)
 {
     this.game = game;
     Random generator = new Random();
     type = (byte)generator.Next(0, 2);
     rotationspeed = 0.2f * (float)MathHelper.Pi;
     todelete = false;
     dir = (short)generator.Next(0, 1);
     speed = new Vector2((float)generator.Next(-50, 50), 160);
     this.center = center;
     lastmovetime = game.time;
     magicx = (int)center.X;
 }
 public GAME(Game1 game)
 {
     end = false;
     y = new int[4];
     y[0] = 800;
     y[1] = 900;
     y[2] = 1000;
     y[3] = 1100;
     pause = false;
     adbonus = false;
     maxlevels = 10;
     noofbosses = 0;
     dificulity = game.dificulity;
     lifes = 3;
     generator = new Random();
     lx = 1;
       this.game = game;
       noofships = 0;
     missles= new List<missle>();
     currentstrike = 0;
     ships = new List<enemyship>();
     smokes = new List<smoke>();
     bonusses = new List<bonus>();
     rubbish = new List<rubbish>();
     emissles = new List<enemymissle>();
     ship = new playership(game);
     scores = 0;
     scorestodraw = 0;
 }
        int type; /// 0 back, 1 resume,2 play,3 options, 4 hi scores,5 about,6 exit; 

        #endregion Fields

        #region Constructors

        public button(int x,int y,int width,int height, Game1 game, string name)
        {
            this.game = game;
            this.x = x;
            this.y = y;
            this.width = width;
            this.height = height;
            this.name = name;
            type = 999;
        }