Exemplo n.º 1
0
        private void LoadLevelFile(string fileName)
        {
            string data;
            System.IO.Stream stream = TitleContainer.OpenStream(fileName);
            using (StreamReader sr = new StreamReader(stream))
            {
                while ((data = sr.ReadLine()) != null)
                {
                    dataObjects.Add(data);

                    var line = data.Split('%');

                    //Dimentions
                    //Identifier  %  Width  %  Height
                    //----------------------------------------------
                    if (line[0] == "dimentions")
                    {
                        Width = int.Parse(line[1]);
                        Height = int.Parse(line[2]);
                        _camera = new Camera(Globals.GraphicsDevice.Viewport) { Limits = new Rectangle(0, 0, int.Parse(line[1]), int.Parse(line[2])) };
                        drawableObjects.Add(new BlockerObject("1x1", new Vector2(-50, -50), new Vector2((Width + 100), 50), false)); //top
                        drawableObjects.Add(new BlockerObject("1x1", new Vector2(Width, 0), new Vector2(50, Height), false)); //right
                        drawableObjects.Add(new BlockerObject("1x1", new Vector2(-50, Height), new Vector2((Width + 100), 50), false)); //bottom
                        drawableObjects.Add(new BlockerObject("1x1", new Vector2(-50, 0), new Vector2(50, Height), false)); //left
                        _layers = new List<Layer>{
                            new Layer(_camera) { Parallax = new Vector2(1.0f, 1.0f) }
                        };
                    }

                    //Popups
                    //Identifier  %  Text  %  Trigger
                    //----------------------------------------------
                    if (line[0] == "popup")
                    {
                        popups.Add(new PopupWindow(System.Text.RegularExpressions.Regex.Unescape(line[1])));
                    }

                    //Tiles; images used for details
                    //Identifier  %  X-Coord  %  Y-Coord  %  FileName % Is Tiled
                    //"Sprite%" + Identifier + "%" + Position.X + "%" + Position.Y + "%" + Depth + "%" + scale.X + "%" + isTiled + "%" + Rotation + "%" + Collidable + "%" + _tiledWidth + "%" + _tiledHeight;
                    //----------------------------------------------
                    if (line[0] == "Sprite")
                    {
                        if (line[6] == "True")
                        {
                            _backgroundTile = line[1];
                            ChangeBackgroundTile(_backgroundTile);
                        }
                        else
                            drawableObjects.Add(new Sprite(line[1], new Vector2(float.Parse(line[2]), float.Parse(line[3])), int.Parse(line[4]), new Vector2(float.Parse(line[5]),float.Parse(line[5])), false, float.Parse(line[7]), bool.Parse(line[8]), int.Parse(line[9]), int.Parse(line[10])));
                    }

                    //Destructible Objects
                    //Identifier  %  X-Coord  %  Y-Coord
                    //"Destructible%" + Identifier + "%" + Position.X + "%" + Position.Y + "%" + frameRate + "%" + Health;
                    //----------------------------------------------
                    if (line[0] == "Destructible")
                    {
                        drawableObjects.Add(new GenericDestructible(new Vector2(float.Parse(line[2]),float.Parse(line[3])),line[1],float.Parse(line[4]), int.Parse(line[5])));
                    }

                    //Impassibles
                    //Identifier  %  X-Coord  %  Y-Coord  %  Scale
                    //"blockerobject%" + Position.X + "%" + Position.Y + "%" + scale.X + "%" + scale.Y + "%" + Invisible;
                    //----------------------------------------------
                    if (line[0] == "impassible")
                    {
                        drawableObjects.Add(new BlockerObject(line[6], new Vector2(float.Parse(line[1]), float.Parse(line[2])), new Vector2(float.Parse(line[3]), float.Parse(line[4])), string.Equals(line[5], "true")));
                    }

                    //AnimatedObjects
                    //Identifier  %  X-Coord  %  Y-Coord  %  Scale % Framerate
                    //"AnimatedObject%" + Identifier + "%" + Position.X + "%" + Position.Y + "%" + scale.X + "%" + Rotation + "%" + frameRate + Depth + collidable;
                    //----------------------------------------------
                    if (line[0] == "AnimatedObject")
                    {
                        drawableObjects.Add(new AnimatedObject(line[1], new Vector2(float.Parse(line[2]), float.Parse(line[3])), new Vector2(float.Parse(line[4]), float.Parse(line[4])), float.Parse(line[5]), float.Parse(line[6]), float.Parse(line[7]), bool.Parse(line[8])));
                    }

                    //Storm
                    //Identifier  %  X-Coord  %  Y-Coord
                    //----------------------------------------------
                    if (line[0] == "startinglocation")
                    {
                        startingLocation = new StartingLocation(new Vector2(float.Parse(line[1]), float.Parse(line[2])));
                        drawableObjects.Add(startingLocation);
                    }

                    //Item
                    //Identifier  %  X-Coord  %  Y-Coord
                    //"Item%" + type + "%" + Identifier + "%" + Position.X + "%" + Position.Y;
                    //----------------------------------------------
                    if (line[0] == "Item")
                    {
                        if (line[1] == "Debris")
                        {
                            if (line[2] == "Cow")
                                drawableObjects.Add(new Cow(new Vector2(float.Parse(line[3]), float.Parse(line[4]))));
                            if (line[2] == "largedebris")
                                drawableObjects.Add(new LargeDebris(new Vector2(float.Parse(line[3]), float.Parse(line[4]))));
                        }
                        if (line[1] == "Powerup")
                        {

                        }

                        if (line[1] == "Health")
                        {

                        }
                    }
                }
            }
        }
Exemplo n.º 2
0
 public Layer(Camera camera)
 {
     _camera = camera;
     Parallax = Vector2.One;
     Sprites = new List<DrawableObject>();
 }
Exemplo n.º 3
0
        public void LoadContent()
        {
            editorObjectList.LoadContent();

            _camera = new Camera(Globals.GraphicsDevice.Viewport) { Limits = new Rectangle(0, 0, 4000, 2000) };
            ResetManagers();

            pauseOverlayTexture = CreateRectangle(Globals.GraphicsDevice.Viewport.Width, Globals.GraphicsDevice.Viewport.Height, new Color(0, 0, 0, 150));

            GenericDestructible Walmart = new GenericDestructible(new Vector2(3360, 910), "Walmart", 1.0f, 5000);
            drawableObjects.Add(Walmart);
            objective = new Objective(Walmart);

            drawableObjects.Add(clickImage);
        }