示例#1
0
		public TitleMenu(GraphicsContext g, Vector2 scales) : base(g, scales, new Vector4(73, 102, 192, 255)) {
			font1 = new Font(new Vector4(255, 255, 255, 255), true, scales, g);
			font2 = new Font(new Vector4(255, 255, 0, 255), true, scales, g);
			
			sl = new SpriteLoader();
			sl.cargarImagen(cursor);
			sl.setImage(sl.getImage().Resize(new ImageSize((int)(sl.getImage().Size.Width*scales.X), (int)(sl.getImage().Size.Height*scales.Y))));
			cu = sl.ImageToSprite(g);
			
			sl.cargarImagen(background);
			sl.setImage(sl.getImage().Resize(new ImageSize((int)(sl.getImage().Size.Width*scales.X), (int)(sl.getImage().Size.Height*scales.Y))));
			bg = sl.ImageToSprite(g);
			
			sl.cargarImagen(dyna);
			sl.setImage(sl.getImage().Resize(new ImageSize((int)(sl.getImage().Size.Width*scales.X), (int)(sl.getImage().Size.Height*scales.Y))));
			dy = sl.ImageToSprite(g);
				
			sl.cargarImagen(blaster);
			sl.setImage(sl.getImage().Resize(new ImageSize((int)(sl.getImage().Size.Width*scales.X), (int)(sl.getImage().Size.Height*scales.Y))));
			bl = sl.ImageToSprite(g);	
			
			backgroundColor = Textures.CreateTexture(g.Screen.Width, g.Screen.Height, g, bgColor);
			bg.Position.X = graphics.Screen.Width / 2 - bg.Width / 2;
			bg.Position.Y = graphics.Screen.Height;
			
			this.sound = new MP3Player("/Application/res/sound/title.mp3");
			sound.play();
	
		}
示例#2
0
        public SetupMenu(Menu menu, GraphicsContext g, Vector2 scales) : base(g, scales, new Vector4(73, 102, 192, 255))
        {
            this.menu = menu;

            font1 = new Font(new Vector4(255, 255, 255, 255), true, scales, g);
            font2 = new Font(new Vector4(255, 255, 0, 255), true, scales, g);

            sl = new SpriteLoader();
            sl.cargarImagen(cursor);
            sl.setImage(sl.getImage().Resize(new ImageSize((int)(sl.getImage().Size.Width *scales.X), (int)(sl.getImage().Size.Height *scales.Y))));
            cu = sl.ImageToSprite(g);

            sl.cargarImagen(background);
            sl.setImage(sl.getImage().Resize(new ImageSize((int)(sl.getImage().Size.Width *scales.X), (int)(sl.getImage().Size.Height *scales.Y))));
            bg = sl.ImageToSprite(g);

            sl.cargarImagen(dyna);
            sl.setImage(sl.getImage().Resize(new ImageSize((int)(sl.getImage().Size.Width *scales.X), (int)(sl.getImage().Size.Height *scales.Y))));
            dy = sl.ImageToSprite(g);

            sl.cargarImagen(blaster);
            sl.setImage(sl.getImage().Resize(new ImageSize((int)(sl.getImage().Size.Width *scales.X), (int)(sl.getImage().Size.Height *scales.Y))));
            bl = sl.ImageToSprite(g);

            backgroundColor = Textures.CreateTexture(g.Screen.Width, g.Screen.Height, g, bgColor);

            //MP3Player.title.play();
        }
示例#3
0
        public Score(int score, int w, int h, GraphicsContext g, Vector2 scale)
        {
            this.g     = g;
            this.scale = scale;
            int pos = 0;

            if (score % 1000 == 0)
            {
                pos = (int)(Math.Log(score / 1000) / Math.Log(2)) + 7;
            }
            else
            {
                pos = (int)(Math.Log(score / 100) / Math.Log(2));
            }

            this.sl = new SpriteLoader();
            this.sl.cargarImagen(this.score);
            this.sl.setImage(sl.getImage().Resize(new ImageSize((int)(sl.getImage().Size.Width *scale.X),
                                                                (int)(sl.getImage().Size.Height *scale.Y))));
            this.ss = new SpriteSheet(this.sl.getImage());

            scoreImg = ss.obtenerSprite((int)(pos * W * scale.X), 0, (int)(W * scale.X), (int)(H * scale.Y));

            scoreFinal = new Image(ImageMode.Rgba, new ImageSize((int)(w * scale.X), (int)(h * scale.Y)), new ImageColor(0, 0, 0, 0));
            scoreFinal.DrawImage(scoreImg, new ImagePosition((int)(w * scale.X / 2 - W * scale.X / 2),
                                                             (int)(h * scale.Y / 2 - H * scale.Y / 2)));

            Texture2D texture = new Texture2D(scoreFinal.Size.Width, scoreFinal.Size.Height, false, PixelFormat.Rgba);

            texture.SetPixels(0, scoreFinal.ToBuffer(), PixelFormat.Rgba);
            scoreSprite = new Sprite(g, texture);
        }
示例#4
0
        public Font(Vector4 color, bool shadows, Vector2 scale, GraphicsContext g)
        {
            this.scale   = scale;
            this.color   = color;
            this.shadows = shadows;
            this.g       = g;
            SpriteLoader loader      = new SpriteLoader();
            Image        spriteSheet = loader.cargarImagen(FONT_SPRITE);

            tileset = new SpriteSheet(spriteSheet);
            loadTiles();
        }
示例#5
0
        public MapMenu(int level, int map, GraphicsContext g, Vector2 scales) : base(g, scales, new Vector4(0, 0, 0, 255))
        {
            this.sl = new SpriteLoader();
            this.sl.cargarImagen(sprites);
            this.sl.setImage(sl.getImage().Resize(new ImageSize((int)(sl.getImage().Size.Width *scales.X),
                                                                (int)(sl.getImage().Size.Height *scales.Y))));
            this.ss = new SpriteSheet(this.sl.getImage());

            this.stage      = ss.obtenerSprite(0, 0, (int)(79 * scales.X), (int)(13 * scales.Y), g);
            this.game_start = ss.obtenerSprite(0, (int)(14 * scales.Y), (int)(107 * scales.X), (int)(13 * scales.Y), g);
            this.level      = ss.obtenerSprite((int)(8 * level * scales.X), (int)(28 * scales.Y), (int)(6 * scales.X), (int)(13 * scales.Y), g);
            this.map        = ss.obtenerSprite((int)(8 * map * scales.X), (int)(28 * scales.Y), (int)(6 * scales.X), (int)(13 * scales.Y), g);

            sound = new MP3Player("/Application/res/sound/map_start.mp3");
            sound.play();
            //MP3Player.map_start.play();
            this.clock = new Stopwatch();
            this.clock.Start();
        }
示例#6
0
        public PasswordMenu(TitleMenu titleMenu, GraphicsContext g, Vector2 scales) : base(g, scales, new Vector4(73, 102, 192, 255))
        {
            this.menu = titleMenu;
            //this.scale = scale;
            this.font1    = new Font(new Vector4(255, 255, 255, 255), true, scales, g);
            this.password = new String[8];

            this.sl = new SpriteLoader();
            this.sl.cargarImagen(cursor);
            this.sl.setImage(sl.getImage().Resize(new ImageSize((int)(sl.getImage().Size.Width *scales.X),
                                                                (int)(sl.getImage().Size.Height *scales.Y))));

            this.ss = new SpriteSheet(this.sl.getImage());

            Sprite[] bomb = { ss.obtenerSprite(0,                    0, (int)(20 * scales.X), (int)(23 * scales.Y), g),
                              ss.obtenerSprite((int)(20 * scales.X), 0, (int)(20 * scales.X), (int)(23 * scales.Y), g),
                              ss.obtenerSprite((int)(40 * scales.X), 0, (int)(22 * scales.X), (int)(23 * scales.Y), g) };
            this.bomb = new Animation(bomb, 10);

            passwords = new String[8, 8];

            using (StreamReader sr = new StreamReader(File.OpenRead("/Application/res/maps/definitions/passwords.txt")))
            {
                for (int i = 0; i < 8; i++)
                {
                    for (int j = 0; j < 8; j++)
                    {
                        string line = Convert.ToString(sr.ReadLine());
                        passwords[i, j] = line.Substring(line.Length - 8);
                    }
                }
                sr.Dispose();
            }

            backgroundColor = Textures.CreateTexture(g.Screen.Width, g.Screen.Height, g, bgColor);

            this.bomb.start();
        }
示例#7
0
        public Map(String s, int tileSize, Vector2 scale, GraphicsContext graphics)
        {
            if (s != null)
            {
                this.mapPath  = path1 + s + path2;
                this.tileSize = tileSize;
                this.graphics = graphics;
                this.scale    = scale;

                try {
                    using (StreamReader sr = new StreamReader(File.OpenRead(mapPath)))
                    {
                        this.mapWidth  = Convert.ToInt32(sr.ReadLine());
                        this.mapHeight = Convert.ToInt32(sr.ReadLine());
                        this.map       = new int[mapHeight, mapWidth];

                        for (int row = 0; row < mapHeight; row++)
                        {
                            String   line   = sr.ReadLine();
                            String[] tokens = line.Split((char[])null, StringSplitOptions.RemoveEmptyEntries);
                            for (int col = 0; col < mapWidth; col++)
                            {
                                this.map[row, col] = Convert.ToInt32(tokens[col]);
                            }
                        }
                    }
                } catch (Exception e) {
                    Console.Error.Write(e.Message);
                }
            }

            String map = null;

            switch (s)
            {
            case "map1_2_square":
            case "map1_2_height":
                map = "/Application/res/maps/map1.png";
                break;

            case "map2_width":
            case "map2_square":
            case "map2_height":
                map = "/Application/res/maps/map2.png";
                break;

            case "map3_width":
            case "map3_height":
                map = "/Application/res/maps/map3.png";
                break;

            case "map4_width":
            case "map4_height":
                map = "/Application/res/maps/map4.png";
                break;

            case "map5_width":
            case "map5_height":
                map = "/Application/res/maps/map5.png";
                break;

            case "map6_width":
            case "map6_height":
                map = "/Application/res/maps/map6.png";
                break;

            case "map7_width":
            case "map7_height":
                map = "/Application/res/maps/map7.png";
                break;

            case "map8_width":
            case "map8_height":
                map = "/Application/res/maps/map8.png";
                break;

            default:
                map = "/Application/res/maps/map1.png";
                break;
            }

            SpriteLoader loader      = new SpriteLoader();
            Image        spriteSheet = loader.cargarImagen(map);
            SpriteSheet  ss          = new SpriteSheet(spriteSheet);

            loadTiles(ss);
            saveImagetoFile(scale);
        }
示例#8
0
        public LevelMenu(int level, GraphicsContext g, Vector2 scales) : base(g, scales, new Vector4(0, 0, 0, 0))
        {
            this.lev = level;

            this.sl = new SpriteLoader();
            this.sl.cargarImagen(sprites);
            this.sl.setImage(sl.getImage().Resize(new ImageSize((int)(sl.getImage().Size.Width *scales.X),
                                                                (int)(sl.getImage().Size.Height *scales.Y))));
            this.ss = new SpriteSheet(this.sl.getImage());

            this.bg    = ss.obtenerSprite(0, 0, (int)(256 * scales.X), (int)(160 * scales.Y), g);
            this.round = ss.obtenerSprite((int)(76 * scales.X), (int)(161 * scales.Y), (int)(49 * scales.X), (int)(14 * scales.Y), g);
            this.level = ss.obtenerSprite((int)(12 * (level - 1) * scales.X + 134 * scales.X), (int)(160 * scales.Y),
                                          (int)(12 * scales.X), (int)(14 * scales.Y), g);

            // TODO Arreglar parpadeo de ronda y nivel
            int    scale    = 2;
            Sprite levelaux = ss.obtenerSprite(12 * (level - 1) * scale + 134 * scale, 160 * scale, 12 * scale, 14 * scale, g);

            levelaux.SetColor(new Vector4(0, 0, 0, 255));
            Sprite roundaux = ss.obtenerSprite(76 * scale, 161 * scale, 49 * scale, 14 * scale, g);

            roundaux.SetColor(new Vector4(0, 0, 0, 255));

            Sprite[] roundFlicker = { this.round, roundaux };
            Sprite[] levelFlicker = { this.level, levelaux };
            Sprite[] head         = { ss.obtenerSprite(1,            (int)(160 * scales.Y), (int)(23 * scales.X), (int)(23 * scales.Y), g),
                                      ss.obtenerSprite((int)(23 * scales.X), (int)(160 * scales.Y), (int)(24 * scales.X), (int)(23 * scales.Y), g),
                                      ss.obtenerSprite((int)(48 * scales.X), (int)(160 * scales.Y), (int)(24 * scales.X), (int)(23 * scales.Y), g) };

            this.head         = new Animation(head, 12);
            this.roundFlicker = new Animation(roundFlicker, 5);
            this.levelFlicker = new Animation(levelFlicker, 5);

            switch (level)
            {
            case 1:
                this.x = (int)(graphics.Screen.Width / 2 - this.bg.Width / 2 + 18 * scales.X);
                this.y = (int)(134 * scales.Y);
                break;

            case 2:
                this.x = (int)(graphics.Screen.Width / 2 - this.bg.Width / 2 + 48 * scales.X);
                this.y = (int)(112 * scales.Y);
                break;

            case 3:
                this.x = (int)(graphics.Screen.Width / 2 - this.bg.Width / 2 + 66 * scales.X);
                this.y = (int)(168 * scales.Y);
                break;

            case 4:
                this.x = (int)(graphics.Screen.Width / 2 - this.bg.Width / 2 + 104 * scales.X);
                this.y = (int)(128 * scales.Y);
                break;

            case 5:
                this.x = (int)(graphics.Screen.Width / 2 - this.bg.Width / 2 + 154 * scales.X);
                this.y = (int)(120 * scales.Y);
                break;

            case 6:
                this.x = (int)(graphics.Screen.Width / 2 - this.bg.Width / 2 + 210 * scales.X);
                this.y = (int)(138 * scales.Y);
                break;

            case 7:
                this.x = (int)(graphics.Screen.Width / 2 - this.bg.Width / 2 + 210 * scales.X);
                this.y = (int)(104 * scales.Y);
                break;

            case 8:
                this.x = (int)(graphics.Screen.Width / 2 - this.bg.Width / 2 + 210 * scales.X);
                this.y = (int)(62 * scales.Y);
                break;
            }
            this.head.start();
            this.roundFlicker.start();
            this.levelFlicker.start();

            //MP3Player.level_start.play();
            this.sound = new MP3Player("/Application/res/sound/level_start.mp3");
            this.sound.play();

            this.clock = new Stopwatch();
            this.clock.Start();
        }
示例#9
0
        public GameOverMenu(int lives, int level, int map, GraphicsContext g, Vector2 scales) : base(g, scales, new Vector4(0, 97, 146, 255))
        {
            this.lives       = lives;
            this.level       = level;
            this.map         = map;
            this.options[0] += " " + lives;
            this.font        = new Font(new Vector4(255, 255, 255, 255), true, scales, g);

            // Ultimo continue
            if (lives == -1)
            {
                options[0] = "Continue last";
                this.font  = new Font(new Vector4(255, 0, 0, 255), true, scales, g);
            }

            // No hay mas continues
            if (lives == -2)
            {
                options = new String[] { "End" };
            }

            // Buscar password
            using (StreamReader sr = new StreamReader(File.OpenRead("/Application/res/maps/definitions/passwords.txt")))
            {
                for (int i = 0; i < 8; i++)
                {
                    for (int j = 0; j < 8; j++)
                    {
                        if (level == i + 1 && map == j + 1)
                        {
                            string line = Convert.ToString(sr.ReadLine());
                            this.password = line.Substring(line.Length - 8);
                            goto found;
                        }
                        //else
                        //sr.Read();
                    }
                }
            }

            found : this.sl = new SpriteLoader();
            this.sl.cargarImagen(sprites);
            this.sl.setImage(sl.getImage().Resize(new ImageSize((int)(sl.getImage().Size.Width *scales.X),
                                                                (int)(sl.getImage().Size.Height *scales.Y))));

            this.ss = new SpriteSheet(this.sl.getImage());

            this.bg    = ss.obtenerSprite(0, 0, (int)(193 * scales.X), (int)(65 * scales.Y), g);
            this.title = ss.obtenerSprite(0, (int)(65 * scales.Y), (int)(156 * scales.X), (int)(27 * scales.Y), g);

            this.sl.cargarImagen(cursor);
            this.sl.setImage(sl.getImage().Resize(new ImageSize((int)(sl.getImage().Size.Width *scales.X),
                                                                (int)(sl.getImage().Size.Height *scales.Y))));
            this.ss = new SpriteSheet(this.sl.getImage());

            this.cu = this.sl.ImageToSprite(g);

            backgroundColor = Textures.CreateTexture(g.Screen.Width, g.Screen.Height, g, bgColor);

            this.passfont = new Font(new Vector4(255, 255, 255, 255), true, scales, g);
            //MP3Player.no_continue.play();
        }