Example #1
0
        public Tile(Layer1TileType layer1, Layer2TileType layer2, Layer3TileType layer3)
        {
            Flammability = 0;
            Material     = 0;
            State        = FireState.Unburned;
            Smoke        = SmokeState.WithoutSmoke;

            SetLayer1(layer1);
            SetLayer2(layer2);
            SetLayer3(layer3);
        }
Example #2
0
        private void SetLayer2(Layer2TileType type)
        {
            switch (type)
            {
            case Layer2TileType.Desk:
                _texture2 = "Desk";
                SetMaterial(Global.rand.Next(5000, 6000));
                SetFlammability(.003f);
                SetSolidity(true);
                break;

            case Layer2TileType.Sofa:
                _texture2 = "Couch";
                SetMaterial(Global.rand.Next(4000, 5000));
                SetFlammability(.1f);
                SetSolidity(true);
                break;

            case Layer2TileType.Plant:
                _texture2 = "Plant";
                SetMaterial(Global.rand.Next(1000, 2000));
                SetFlammability(.0001f);
                SetSolidity(true);
                break;

            case Layer2TileType.OpenHorizontalDoor:
                _texture2 = "Open Horizontal Door";
                SetMaterial(Global.rand.Next(2000, 3000));
                SetFlammability(.0001f);
                SetSolidity(false);
                IsDoor = true;
                break;

            case Layer2TileType.OpenVerticalDoor:
                _texture2 = "Open Vertical Door";
                SetMaterial(Global.rand.Next(2000, 3000));
                SetFlammability(.0001f);
                SetSolidity(false);
                IsDoor = true;
                break;

            case Layer2TileType.ClosedHorizontalDoor:
                _texture2 = "Closed Horizontal Door";
                SetMaterial(Global.rand.Next(2000, 3000));
                Flammability = .0001f;
                SetSolidity(true);
                IsDoor = true;
                break;

            case Layer2TileType.ClosedVerticalDoor:
                _texture2 = "Closed Vertical Door";
                SetMaterial(Global.rand.Next(2000, 3000));
                Flammability = .0001f;
                SetSolidity(true);
                IsDoor = true;
                break;

            case Layer2TileType.TrashCan:
                _texture2 = "Trash Can";
                SetMaterial(Global.rand.Next(2000, 3000));
                SetFlammability(.2f);
                SetSolidity(false);
                break;

            case Layer2TileType.Newspaper:
                _texture2 = "Newspaper";
                SetMaterial(Global.rand.Next(1000, 2000));
                SetFlammability(.2f);
                SetSolidity(false);
                break;

            case Layer2TileType.Flammables:
                _texture2 = "Flammables";
                Material  = 100;      // Gas cans need to blow up fast, so override the material
                SetFlammability(1);
                SetSolidity(false);
                EXPLODES = true;
                break;

            case Layer2TileType.Empty:
                _texture2 = "Empty";
                SetMaterial(0);
                SetFlammability(0);
                SetSolidity(false);
                break;
            }
        }
Example #3
0
        public PlayState(StateManager manager, string name, Viewport viewport)
        {
            this.manager = manager;

            StreamReader reader = new StreamReader(System.Environment.CurrentDirectory + "\\Levels\\" + name + ".txt");
            string[] lines = reader.ReadToEnd().Split(new char[] { '\n' }, StringSplitOptions.RemoveEmptyEntries);
            reader.Close();

            string[] playerPosition = lines[0].Split(new char[] { ',' });
            _player = Generator.PlayerSprite(new Vector2(Convert.ToInt32(playerPosition[0].Trim()), Convert.ToInt32(playerPosition[1].Trim())));

            string[] size = lines[1].Split(new char[] { ',' });
            WorldLimits = new Vector2(Convert.ToInt32(size[0].Trim()), Convert.ToInt32(size[1].Trim()));
            Grid = new Tile[Convert.ToInt32(size[0].Trim()), Convert.ToInt32(size[1].Trim())];
            selectedNozzle = Nozzle.narrow;

            string[] victimPositions = lines[2].Split(new char[] { ';' });
            foreach (string victimPosition in victimPositions)
            {
                string[] position = victimPosition.Split(new char[] { ',' });
                Victims.Add(Generator.VictimSprite(new Vector2(Convert.ToInt32(position[0].Trim()), Convert.ToInt32(position[1].Trim()))));
            }

            string[] firePositionList = lines[3].Split(new char[] { ',' });
            Vector2 firePosition = new Vector2(Convert.ToInt32(firePositionList[0].Trim()), Convert.ToInt32(firePositionList[1].Trim()));

            for (int x = 0; x < Grid.GetLength(0); x++)
            {
                for (int y = 0; y < Grid.GetLength(1); y++)
                {
                    Layer1TileType layer1 = Layer1TileType.Outside;
                    Layer2TileType layer2 = Layer2TileType.Empty;
                    Layer3TileType layer3 = Layer3TileType.Empty;

                    switch (lines[y + 4][x])
                    {
                        case 'O': layer1 = Layer1TileType.Outside; break;
                        case '1': layer1 = Layer1TileType.Carpet1; break;
                        case '2': layer1 = Layer1TileType.Carpet2; break;
                        case '3': layer1 = Layer1TileType.Tile1; break;
                        case '4': layer1 = Layer1TileType.Tile2; break;
                        case '5': layer1 = Layer1TileType.WoodFloor; break;
                        case 'G': layer1 = Layer1TileType.GraniteWall; break;
                        case 'W': layer1 = Layer1TileType.WoodWall; break;
                    }

                    switch (lines[y + Grid.GetLength(1) + 5][x])
                    {
                        case '-': layer2 = Layer2TileType.Empty; break;
                        case 'E': layer2 = Layer2TileType.Desk; break;
                        case 'S': layer2 = Layer2TileType.Sofa; break;
                        case 'P': layer2 = Layer2TileType.Plant; break;
                        case 'C': layer2 = Layer2TileType.OpenVerticalDoor; break;
                        case 'D': layer2 = Layer2TileType.ClosedVerticalDoor; break;
                        case 'c': layer2 = Layer2TileType.OpenHorizontalDoor; break;
                        case 'd': layer2 = Layer2TileType.ClosedHorizontalDoor; break;
                        case 'T': layer2 = Layer2TileType.TrashCan; break;
                        case 'N': layer2 = Layer2TileType.Newspaper; break;
                        case 'F': layer2 = Layer2TileType.Flammables; break;
                    }

                    switch (lines[y + 2 * Grid.GetLength(1) + 6][x])
                    {
                        case 'C': layer3 = Layer3TileType.Computer; break;
                        case 'B': layer3 = Layer3TileType.Blotter; break;
                        case '-': layer3 = Layer3TileType.Empty; break;
                        case 'P': layer3 = Layer3TileType.Plant; break;
                        case 'L': layer3 = Layer3TileType.Laptop; break;
                    }

                    Grid[x, y] = new Tile(layer1, layer2, layer3);
                }
            }

            Grid[(int)firePosition.X, (int)firePosition.Y].State = FireState.Burning;

            Curve c = new Curve();
            c.Keys.Add(new CurveKey(0, 0));
            c.Keys.Add(new CurveKey(.3f, 1));
            c.Keys.Add(new CurveKey(.7f, 1));
            c.Keys.Add(new CurveKey(1, 0));

            Curve a = new Curve();
            a.Keys.Add(new CurveKey(0, 0));
            a.Keys.Add(new CurveKey(.3f, 1));
            a.Keys.Add(new CurveKey(.7f, 1));
            a.Keys.Add(new CurveKey(1, 0));
            fireHose = new ParticleSystem(Global.Textures["Water"], _player.PositionCenter, 0, 0, .5f, .7f, 500, Utils.ConstantCurve(500), .10f, Utils.ConstantCurve(0), 0, c, .05f, a, a, a, a, false, 1);

            a = new Curve();
            a.Keys.Add(new CurveKey(0, 0));
            a.Keys.Add(new CurveKey(.3f, .5f));
            a.Keys.Add(new CurveKey(.7f, .5f));
            a.Keys.Add(new CurveKey(1, 0));
            Curve preMultColor = new Curve();
            preMultColor.Keys.Add(new CurveKey(0, 1));
            preMultColor.Keys.Add(new CurveKey(.7f, 1));
            preMultColor.Keys.Add(new CurveKey(1, 0));
            fire = new ParticleSystem(Global.Textures["Fire"], new List<Vector2>(), 0, (float)Math.PI * 2, .5f, 1f, 10, Utils.ConstantCurve(100), .10f, Utils.ConstantCurve(0), 0, Utils.ConstantCurve(1), .05f, preMultColor, preMultColor, preMultColor, a, true, 1);
            explosions = new ParticleSystem(Global.Textures["Fire"], new List<Vector2>(), 0, (float)Math.PI * 2, 1f, 2f, 500, Utils.ConstantCurve(500), .10f, Utils.ConstantCurve(0), 0, Utils.ConstantCurve(1), .05f, preMultColor, preMultColor, preMultColor, a, true, 10);

            hoseSound.IsLooped = true;
            fireSound.IsLooped = true;
            fireSound.Volume = .5f;
            fireSound.Play();
            PlayVictimCount();

            _showMiniMap = true;
            camera = new Camera2D();
            this.viewport = viewport;
        }