Example #1
0
        private static Tile LoadTile(XmlTextReader xml)
        {
            int    x, y;
            string type;
            Tile   tile = null;

            x    = Int32.Parse(xml.GetAttribute("x"));
            y    = Int32.Parse(xml.GetAttribute("y"));
            type = xml.GetAttribute("type");

            if (type.Equals("LightRubble"))
            {
                tile = new LightRubblePile(x, y);
            }
            else if (type.Equals("MediumRubble"))
            {
                tile = new MediumRubblePile(x, y);
            }
            else if (type.Equals("HeavyRubble"))
            {
                tile = new HeavyRubblePile(x, y);
            }

            return(tile);
        }
Example #2
0
        public Terrain(int width, int height)
        {
            bool test = false;

            this.width  = width;
            this.height = height;

            tiles        = new Tile[this.width, this.height];
            collisionMap = new ByteMap(this.width, this.height);

            if (test)
            {
                int n = 0;

                for (int i = 0; i < tiles.GetLength(0); i++)
                {
                    for (int j = 0; j < tiles.GetLength(1); j++)
                    {
                        switch (n % 4)
                        {
                        case 0:
                            tiles[i, j] = new FloorTile();
                            break;

                        case 1:
                            tiles[i, j] = new LightRubblePile();
                            break;

                        case 2:
                            tiles[i, j] = new MediumRubblePile();
                            break;

                        case 3:
                            tiles[i, j] = new HeavyRubblePile();
                            break;
                        }

                        n++;
                    }
                }
            }
            else
            {
                for (int i = 0; i < tiles.GetLength(0); i++)
                {
                    for (int j = 0; j < tiles.GetLength(1); j++)
                    {
                        tiles[i, j] = new FloorTile();
                    }
                }
            }

            GenerateCollisionMap();
        }
Example #3
0
        public Terrain(int width, int height)
        {
            bool test = false;
            this.width = width;
            this.height = height;

            tiles = new Tile[this.width, this.height];
            collisionMap = new ByteMap(this.width, this.height);

            if (test)
            {
                int n = 0;

                for (int i = 0; i < tiles.GetLength(0); i++)
                {
                    for (int j = 0; j < tiles.GetLength(1); j++)
                    {
                        switch (n % 4)
                        {
                            case 0:
                                tiles[i, j] = new FloorTile();
                                break;

                            case 1:
                                tiles[i, j] = new LightRubblePile();
                                break;

                            case 2:
                                tiles[i, j] = new MediumRubblePile();
                                break;

                            case 3:
                                tiles[i, j] = new HeavyRubblePile();
                                break;
                        }

                        n++;
                    }
                }
            }
            else
            {
                for (int i = 0; i < tiles.GetLength(0); i++)
                {
                    for (int j = 0; j < tiles.GetLength(1); j++)
                    {
                        tiles[i, j] = new FloorTile();
                    }
                }
            }

            GenerateCollisionMap();
        }
Example #4
0
        private static Tile LoadTile(XmlTextReader xml)
        {
            int x, y;
            string type;
            Tile tile = null;

            x = Int32.Parse(xml.GetAttribute("x"));
            y = Int32.Parse(xml.GetAttribute("y"));
            type = xml.GetAttribute("type");

            if (type.Equals("LightRubble"))
                tile = new LightRubblePile(x, y);
            else if (type.Equals("MediumRubble"))
                tile = new MediumRubblePile(x, y);
            else if (type.Equals("HeavyRubble"))
                tile = new HeavyRubblePile(x, y);

            return tile;
        }