Esempio n. 1
0
 public Storm(StartingLocation startingPosition)
 {
     //Texture = Globals.Content.Load<Texture2D>("StormLines1");
     firstLayer = new StormLayer("StormLines1", startingPosition.Position);
     secondLayer = new StormLayer("StormLines2", startingPosition.Position);
     thirdLayer = new StormLayer("StormLines3", startingPosition.Position);
     fourthLayer = new StormLayer("StormLines4", startingPosition.Position);
     fifthLayer = new StormLayer("StormLines5", startingPosition.Position);
     firstLayer.SetDepth(100);
     secondLayer.SetDepth(101);
     thirdLayer.SetDepth(102);
     fourthLayer.SetDepth(103);
     fifthLayer.SetDepth(104);
     inventoryManager = new InventoryManager(this);
     stormHealth = new Healthbar(10000, new Vector2(20));
     Position = startingPosition.Position;
     Velocity = new Vector2();
     _color = new Color(255, 255, 255, 70);
     orbitPullRange = 100;
 }
Esempio n. 2
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")
                        {

                        }
                    }
                }
            }
        }