Exemplo n.º 1
0
        public void setLevel(int level)
        {
            Blocks.Clear();
            images.Clear();
            map.Clear();

            this.level = level;
            string strlevel = @"Content/maps/level" + level + ".txt";

            using (StreamReader r = new StreamReader(strlevel))
            {
                string line = string.Empty;
                while ((line = r.ReadLine()) != null)
                {
                    map.Add(line);
                }
            }
            Model cube  = content.Load <Model>("Models/cube");
            bool  sseen = false;

            for (int i = 0; i < map.Count; i++)
            {
                for (int j = 0; j < map[i].Length; j++)
                {
                    char here = map[i][j];
                    switch (here)
                    {
                    case 'W':
                    {
                        Blocks.Add(new Sprite3D(cube, new Vector3(i * Consts.WORLDSCALE * 2, 0, j * Consts.WORLDSCALE * 2)));

                        break;
                    }

                    case 's':
                    {
                        if (sseen)
                        {
                            continue;
                        }

                        playerstartpos = new Vector3(i * Consts.WORLDSCALE * 2, 0, j * Consts.WORLDSCALE * 2);
                        Blocks.Add(new Sprite3D(cube, new Vector3(i * Consts.WORLDSCALE * 2, Consts.WORLDSCALE * 2, j * Consts.WORLDSCALE * 2)));
                        cam.setPosition(playerstartpos);
                        sseen = true;

                        images.Add(new Image3D(content.Load <Texture2D>("Textures/f**k"), new Vector3(i * Consts.WORLDSCALE * 2, 0, j * Consts.WORLDSCALE * 2), true));
                        images[images.Count - 1].move(new Vector3(0, -Consts.WORLDSCALE, 0));

                        break;
                    }

                    case ' ':
                    {
                        Blocks.Add(new Sprite3D(cube, new Vector3(i * Consts.WORLDSCALE * 2, Consts.WORLDSCALE * 2, j * Consts.WORLDSCALE * 2)));
                        images.Add(new Image3D(content.Load <Texture2D>("Textures/f**k"), new Vector3(i * Consts.WORLDSCALE * 2, 0, j * Consts.WORLDSCALE * 2), true));
                        images[images.Count - 1].move(new Vector3(0, -Consts.WORLDSCALE, 0));
                        break;
                    }

                    default:
                    {
                        continue;
                    }
                    }
                }
            }
        }