Esempio n. 1
0
        public static void ParseRoomCSVFile()
        {
            string cwdPath = Directory.GetCurrentDirectory();

            string roomPath = "";

            if (roomNumber < storage.singleDigitRoomCap)
            {
                roomPath = @"0" + (roomNumber.ToString()) + ".csv";
            }
            else
            {
                roomPath = @"" + (roomNumber.ToString()) + ".csv";
            }

            cwdPath = cwdPath.Replace(@"\bin\Debug\netcoreapp3.1", @"\Classes\Level\RoomCSV");
            cwdPath = Path.Combine(cwdPath, roomPath);
            string[] lines = System.IO.File.ReadAllLines(cwdPath);

            foreach (string line in lines)
            {
                string[] segments = line.Split(new string[] { "," },
                                               StringSplitOptions.None);
                Vector2 position = new Vector2(0, 0);
                switch (segments[0])
                {
                case "Block":
                    position = utility.GetBlockSecondaryItemPosition(windowWidthFloor, windowHeightFloor, float.Parse(segments[2]), float.Parse(segments[1]));
                    BlockTile block;
                    tiles.Add(block    = new BlockTile(game, new TileSpriteFactory(game), position));
                    block.drawLocation = position;
                    break;

                case "Event":
                    position = utility.GetBlockSecondaryItemPosition(windowWidthFloor, windowHeightFloor, float.Parse(segments[2]), float.Parse(segments[1]));
                    EventTile eventTile;
                    tiles.Add(eventTile    = new EventTile(game, new TileSpriteFactory(game), position));
                    eventTile.drawLocation = position;
                    break;

                case "Pushable":
                    position = utility.GetPushablePosition(windowWidthFloor, windowHeightFloor, float.Parse(segments[2]), float.Parse(segments[1]));
                    PushableTile pushable;
                    tiles.Add(pushable    = new PushableTile(game, new TileSpriteFactory(game), position));
                    pushable.drawLocation = position;
                    break;

                case "Stair":
                    position = utility.GetBlockSecondaryItemPosition(windowWidthFloor, windowHeightFloor, float.Parse(segments[2]), float.Parse(segments[1]));
                    TPTile stair;
                    tiles.Add(stair    = new TPTile(game, new TileSpriteFactory(game), position));
                    stair.drawLocation = position;
                    break;

                case "Compass":
                    position = utility.GetBlockSecondaryItemPosition(windowWidthFloor, windowHeightFloor, float.Parse(segments[2]), float.Parse(segments[1]));
                    Compass compass;
                    items.Add(compass    = new Compass(game, new ItemSpriteFactory(game), position));
                    compass.drawLocation = position;
                    break;

                case "Heart":
                    position = utility.GetHeartPosition(windowWidthFloor, windowHeightFloor, float.Parse(segments[2]), float.Parse(segments[1]));
                    Heart heart;
                    items.Add(heart = new Heart(game, new ItemSpriteFactory(game), position));
                    heart.position  = position;
                    break;

                case "Key":
                    position = utility.GetCommonItemPosition(windowWidthFloor, windowHeightFloor, float.Parse(segments[2]), float.Parse(segments[1]));
                    Key key;
                    items.Add(key = new Key(game, new ItemSpriteFactory(game), position));
                    key.position  = position;
                    break;

                case "BlueRupee":
                    position = utility.GetCommonItemPosition(windowWidthFloor, windowHeightFloor, float.Parse(segments[2]), float.Parse(segments[1]));
                    BlueRupee blueRupee;
                    items.Add(blueRupee = new BlueRupee(game, new ItemSpriteFactory(game), position));
                    blueRupee.position  = position;
                    break;

                case "Bomb":
                    position = utility.GetBombPosition(windowWidthFloor, windowHeightFloor, float.Parse(segments[2]), float.Parse(segments[1]));
                    Bomb bomb;
                    items.Add(bomb = new Bomb(game, new ItemSpriteFactory(game), position));
                    bomb.position  = position;
                    break;

                case "Boomerang":
                    position = utility.GetCommonItemPosition(windowWidthFloor, windowHeightFloor, float.Parse(segments[2]), float.Parse(segments[1]));
                    Boomerang boomerang;
                    items.Add(boomerang = new Boomerang(game, new ItemSpriteFactory(game), position));
                    boomerang.position  = position;
                    break;

                case "Bow":
                    position = utility.GetCommonItemPosition(windowWidthFloor, windowHeightFloor, float.Parse(segments[2]), float.Parse(segments[1]));
                    Bow bow;
                    items.Add(bow = new Bow(game, new ItemSpriteFactory(game), position));
                    bow.position  = position;
                    break;

                case "HeartContainer":
                    position = utility.GetHeartContainerPosition(windowWidthFloor, windowHeightFloor, float.Parse(segments[2]), float.Parse(segments[1]));
                    HeartContainer heartContainer;
                    items.Add(heartContainer = new HeartContainer(game, new ItemSpriteFactory(game), position));
                    heartContainer.position  = position;
                    break;

                case "Map":
                    position = utility.GetCommonItemPosition(windowWidthFloor, windowHeightFloor, float.Parse(segments[2]), float.Parse(segments[1]));
                    Map map;
                    items.Add(map = new Map(game, new ItemSpriteFactory(game), position));
                    map.position  = position;
                    break;

                case "Fairy":
                    position = utility.GetCommonItemPosition(windowWidthFloor, windowHeightFloor, float.Parse(segments[2]), float.Parse(segments[1]));
                    Fairy fairy;
                    items.Add(fairy = new Fairy(game, new ItemSpriteFactory(game), position));
                    fairy.position  = position;
                    break;

                case "Triforce":
                    position = utility.GetTriforceOldPosition(windowWidth, windowHeightFloor);
                    Triforce triforce;
                    items.Add(triforce = new Triforce(game, new ItemSpriteFactory(game), position));
                    triforce.position  = position;
                    break;

                case "YellowRupee":
                    position = utility.GetCommonItemPosition(windowWidthFloor, windowHeightFloor, float.Parse(segments[2]), float.Parse(segments[1]));
                    YellowRupee yellowRupee;
                    items.Add(yellowRupee = new YellowRupee(game, new ItemSpriteFactory(game), position));
                    yellowRupee.position  = position;
                    break;

                case "Goriya":
                    position = utility.GetEnemyPosition(windowWidthFloor, windowHeightFloor, float.Parse(segments[2]), float.Parse(segments[1]));
                    enemies.Add(new EnemyGoriya(game, position));
                    break;

                case "Aquamentus":
                    position = utility.GetEnemyPosition(windowWidthFloor, windowHeightFloor, float.Parse(segments[2]), float.Parse(segments[1]));
                    enemies.Add(new EnemyAquamentus(game, position));
                    break;

                case "Roshi":
                    position = utility.GetEnemyPosition(windowWidthFloor, windowHeightFloor, float.Parse(segments[2]), float.Parse(segments[1]));
                    enemies.Add(new EnemyRoshi(game, position));
                    break;

                case "BladeTrap":
                    position = utility.GetEnemyPosition(windowWidthFloor, windowHeightFloor, float.Parse(segments[2]), float.Parse(segments[1]));
                    enemies.Add(new EnemyBladeTrap(game, position, new Vector2(storage.bladeTrapX, storage.bladeTrapY), game.link));
                    break;

                case "Gel":
                    position = utility.GetEnemyPosition(windowWidthFloor, windowHeightFloor, float.Parse(segments[2]), float.Parse(segments[1]));
                    enemies.Add(new EnemySlime(game, position));
                    break;

                case "Keese":
                    position = utility.GetEnemyPosition(windowWidthFloor, windowHeightFloor, float.Parse(segments[2]), float.Parse(segments[1]));
                    enemies.Add(new EnemyKeese(game, position));
                    break;

                case "Stalfos":
                    position = utility.GetEnemyPosition(windowWidthFloor, windowHeightFloor, float.Parse(segments[2]), float.Parse(segments[1]));
                    enemies.Add(new EnemyStalfos(game, position));
                    break;

                case "Wallmaster":
                    position = utility.GetEnemyPosition(windowWidthFloor, windowHeightFloor, float.Parse(segments[2]), float.Parse(segments[1]));
                    enemies.Add(new EnemyWallmaster(game, position));
                    break;

                case "Redead":
                    position = utility.GetEnemyPosition(windowWidthFloor, windowHeightFloor, float.Parse(segments[2]), float.Parse(segments[1]));
                    enemies.Add(new EnemyRedead(game, position));
                    break;

                case "FogOfWar":
                    enemies.Add(new FogOfWar(game));
                    break;

                default:
                    break;
                }
            }
        }
Esempio n. 2
0
        public static void ParseDoorsCSVFile()
        {
            string cwdPath = Directory.GetCurrentDirectory();

            cwdPath = Directory.GetCurrentDirectory();
            string[] lines;
            int      doorvalue = storage.doorValueDefault;

            cwdPath = cwdPath.Replace(@"\bin\Debug\netcoreapp3.1", @"\Classes\Level\RoomCSV");
            cwdPath = Path.Combine(cwdPath, "doors.csv");
            lines   = System.IO.File.ReadAllLines(cwdPath);
            Vector2        wallPos  = new Vector2(0, 0);
            Vector2        stairPos = new Vector2(0, 0);
            Vector2        tpPos    = new Vector2(0, 0);
            GateKeeperTile gatekeeper;
            StairsTile     stair;
            TPTile         tptile;
            bool           locked;
            bool           isLockedDoor;
            bool           isPortal;

            foreach (string line in lines)
            {
                string[] segments = line.Split(new string[] { "," },
                                               StringSplitOptions.None);
                if (int.Parse(segments[0]) == roomNumber)
                {
                    for (int i = 0; i < storage.numberOfDoors; i++)
                    {
                        doorvalue    = i * storage.doorKeyScaleValue + int.Parse(segments[i + 1]);
                        locked       = true;
                        isLockedDoor = false;
                        isPortal     = false;
                        if (int.Parse(segments[i + 1]) == storage.openDoorValue)
                        {
                            locked = false;
                        }
                        if (int.Parse(segments[i + 1]) == storage.lockedDoorValue)
                        {
                            isLockedDoor = true;
                        }
                        if (int.Parse(segments[i + 1]) == storage.portalDoorValue)
                        {
                            isLockedDoor = true;
                            isPortal     = true;
                        }
                        switch (i)
                        {
                        case 0:
                            doors.Add(new TopDoor(game, new RoomTextureStorage(game), doorvalue));
                            wallPos = utility.GetBlockSecondaryItemPosition(windowWidthFloor, windowHeightFloor, storage.topDoorLeftPos, 0);

                            tiles.Add(gatekeeper    = new GateKeeperTile(game, new TileSpriteFactory(game), wallPos, locked, isLockedDoor, isPortal));
                            gatekeeper.drawLocation = wallPos;

                            wallPos = utility.GetBlockSecondaryItemPosition(windowWidthFloor, windowHeightFloor, storage.topDoorRightPos + 1, 0);
                            tiles.Add(gatekeeper    = new GateKeeperTile(game, new TileSpriteFactory(game), wallPos, locked, isLockedDoor, isPortal));
                            gatekeeper.drawLocation = wallPos;

                            if (roomNumber == storage.undergroundRoomNumber)
                            {
                                tpPos                   = utility.GetTopStairPosition(windowWidthFloor, windowHeightFloor, storage.undergroundXPos, storage.undergroundYPos);
                                tiles.Add(stair         = new StairsTile(game, new TileSpriteFactory(game), tpPos));
                                stair.drawLocation      = tpPos;
                                wallPos                 = utility.GetBlockSecondaryItemPosition(windowWidthFloor, windowHeightFloor, storage.undergroundWallXPos, storage.undergroundYPos);
                                tiles.Add(gatekeeper    = new GateKeeperTile(game, new TileSpriteFactory(game), wallPos, false, false, false));
                                gatekeeper.drawLocation = wallPos;
                            }
                            else if (roomNumber == storage.outsideRoomNumber)
                            {
                                tpPos               = utility.GetTopStairPosition(windowWidthFloor, windowHeightFloor, storage.outsideStairX, storage.outsideStairY);
                                tiles.Add(tptile    = new TPTile(game, new TileSpriteFactory(game), tpPos));
                                tptile.drawLocation = tpPos;
                            }
                            else
                            {
                                stairPos           = utility.GetTopStairPosition(windowWidthFloor, windowHeightFloor, storage.topDoorX, 0);
                                tiles.Add(stair    = new StairsTile(game, new TileSpriteFactory(game), stairPos));
                                stair.drawLocation = stairPos;
                            }
                            break;

                        case 1:
                            doors.Add(new LeftDoor(game, new RoomTextureStorage(game), doorvalue));
                            wallPos = utility.GetBlockSecondaryItemPosition(windowWidthFloor, windowHeightFloor, 0, storage.leftDoorY);

                            tiles.Add(gatekeeper    = new GateKeeperTile(game, new TileSpriteFactory(game), wallPos, locked, isLockedDoor, isPortal));
                            gatekeeper.drawLocation = wallPos;

                            stairPos           = utility.GetLeftStairPosition(windowWidthFloor, windowHeightFloor, 0, storage.leftDoorY);
                            tiles.Add(stair    = new StairsTile(game, new TileSpriteFactory(game), stairPos));
                            stair.drawLocation = stairPos;
                            break;

                        case 2:
                            doors.Add(new RightDoor(game, new RoomTextureStorage(game), doorvalue));

                            wallPos = utility.GetBlockSecondaryItemPosition(windowWidthFloor, windowHeightFloor, storage.rightDoorX, storage.rightDoorY);

                            tiles.Add(gatekeeper    = new GateKeeperTile(game, new TileSpriteFactory(game), wallPos, locked, isLockedDoor, isPortal));
                            gatekeeper.drawLocation = wallPos;

                            stairPos           = utility.GetRightStairPosition(windowWidthFloor, windowHeightFloor, storage.rightDoorX, storage.rightDoorY);
                            tiles.Add(stair    = new StairsTile(game, new TileSpriteFactory(game), stairPos));
                            stair.drawLocation = stairPos;
                            break;

                        case 3:
                            doors.Add(new BottomDoor(game, new RoomTextureStorage(game), doorvalue));

                            wallPos = utility.GetBlockSecondaryItemPosition(windowWidthFloor, windowHeightFloor, storage.bottomDoorX, storage.bottomDoorY);

                            tiles.Add(gatekeeper    = new GateKeeperTile(game, new TileSpriteFactory(game), wallPos, locked, isLockedDoor, isPortal));
                            gatekeeper.drawLocation = wallPos;
                            wallPos = utility.GetBlockSecondaryItemPosition(windowWidthFloor, windowHeightFloor, storage.bottomDoorWallX, storage.bottomDoorY);

                            tiles.Add(gatekeeper    = new GateKeeperTile(game, new TileSpriteFactory(game), wallPos, locked, isLockedDoor, isPortal));
                            gatekeeper.drawLocation = wallPos;

                            stairPos           = utility.GetBotStairPosition(windowWidthFloor, windowHeightFloor, storage.bottomDoorX, storage.bottomDoorY);
                            tiles.Add(stair    = new StairsTile(game, new TileSpriteFactory(game), stairPos));
                            stair.drawLocation = stairPos;
                            break;

                        default:
                            break;
                        }
                    }
                }
            }
        }