Ejemplo n.º 1
0
        public ReadManager(Variables var, Game1 g, Enums enums) // Placement of created instances of object.
        {
            this.enums   = enums;
            enums.pClass = PlayerClass.Mage;
            im           = new InventoryManager(this);
            List <string> strings = new List <string>();
            StreamReader  sr      = new StreamReader("map.txt");

            while (!sr.EndOfStream)
            {
                strings.Add(sr.ReadLine());
            }
            sr.Close();

            tiles = new Tile[strings[0].Length, strings.Count];
            for (int i = 0; i < tiles.GetLength(0); i++)
            {
                for (int j = 0; j < tiles.GetLength(1); j++)
                {
                    if (strings[j][i] == 'f')
                    {
                        tiles[i, j] = new Tile(var.floor, new Vector2(32 * i, 32 * j), true, var.floorRec);
                        tileList.Add(tiles[i, j]);
                        gameObjects.Add(tiles[i, j]);
                    }
                    else if (strings[j][i] == '-')
                    {
                    }
                    else if (strings[j][i] == 'h')
                    {
                        if (enums.pClass == PlayerClass.Warrior)
                        {
                            warrior = new Warrior(var.hero, new Vector2(32 * i, 32 * j), false, var.heroRec, this, g.Content, var.fakeTextureHero);
                            heroes.Add(warrior);
                        }
                        else if (enums.pClass == PlayerClass.Mage)
                        {
                            mage = new Mage(var.hero, new Vector2(32 * i, 32 * j), false, var.heroRec, this, g.Content, var.fakeTextureHero);
                            heroes.Add(mage);
                        }
                    }
                    else if (strings[j][i] == 'g')
                    {
                        green = new Goblin(var.greenMonster, new Vector2(32 * i, 32 * j), false, var.greenMonsterRec, this);
                        monsters.Add(green);
                    }
                    else if (strings[j][i] == 'd')
                    {
                        devil = new Devil(var.greenMonster, new Vector2(32 * i, 32 * j), false, var.greenMonsterRec, this);
                        monsters.Add(devil);
                    }
                    else if (strings[j][i] == 'c')
                    {
                        chest = new Chests(var.chestClosed, new Vector2(32 * i, 32 * j), false, var.chestRec, im, false, false, var.chestOpen, g);
                        chestList.Add(chest);
                    }
                    else if (strings[j][i] == 'i')
                    {
                        tiles[i, j] = new Tile(var.floor, new Vector2(32 * i, 32 * j), false, var.floorRec);
                        invisibleTiles.Add(tiles[i, j]);
                    }
                    else if (strings[j][i] == 's')
                    {
                        dSpikeTrap = new DynamicSpikeTrap(var.spikeTrapSS, new Vector2(32 * i, (32 * j) + 15), false, var.spikeRec, var.fakeTextureSpike, this);
                        spikeList.Add(dSpikeTrap);
                        dGameObjects.Add(dSpikeTrap);
                    }
                    else if (strings[j][i] == 'r')
                    {
                        rBlock = new RestorationBlock(var.restoFloor, new Vector2(32 * i, 32 * j), true, var.floorRec, this);
                        restoList.Add(rBlock);
                        gameObjects.Add(rBlock);
                    }
                    else if (strings[j][i] == 'l')
                    {
                        lever = new Lever(var.leverTex, new Vector2(32 * i, (32 * j) + 15), false, var.leverRec);
                        leverList.Add(lever);
                        gameObjects.Add(lever);
                    }
                }
            }
        }