Пример #1
0
    private void Awake()
    {
        // MapDataLoader 클래스 인스턴스 생성 및 메모리 할당
        MapDataLoader mapDataLoader = new MapDataLoader();

        // PlayerPrefs를 이용해 디바이스에 저장되어 있는 현재 스테이지 인덱스 불러오기
        // 저장하는 값은 0부터 시작하고 스테이지는 1부터 시작하기 떄문에 +1
        int index = PlayerPrefs.GetInt("StageIndex") + 1;

        // 인덱스가 10보다 작으면 01, 02와 같이 0을 붙여주고, 10 이상이면 그대로 사용
        string currentStage = index < 10 ? $"Stage0{index}" : $"Stage{index}";

        // 현재 저장되어 있는 json 파일이 Stage01, Stage02.. 이기때문에 "Stage01" 데이터를 불러온다
        MapData mapData = mapDataLoader.Load(currentStage);

        // mapData 정보를 바탕으로 타일 형태의 맵 생성
        tilemap2D.GenerateTilemap(mapData);

        // mapData.playerPosition 정보를 바탕으로 플레이어 위치 설정
        playerController.Setup(mapData.playerPosition, mapData.mapSize.y);

        // 맵의 크기 정보(mapData.mapSize)를 바탕으로 카메라 시야 크기 설정
        cameraController.Setup(mapData.mapSize.x, mapData.mapSize.y);

        // 현재 스ㅔ이지의 정보를 UI에 출력
        stageUI.UpdateTextStage(currentStage);
    }
Пример #2
0
        private void timerLoad_Tick(object sender, EventArgs e)
        {
            try
            {
                timerLoad.Enabled = false;
                this.Cursor       = Cursors.WaitCursor;

                MapDataLoader mapDataLoader = new MapDataLoader();
                mapDataLoader.Load(mapMain.Object as IMapControl2);
                _mapOperator     = new MapOperator();
                _mapOperator.Map = mapMain.Map;
            }catch (Exception ex)
            {
                System.Diagnostics.Trace.WriteLine(ex);
            }
            finally
            {
                timerLoad.Enabled = false;
                label1.Visible    = false;
                this.Cursor       = Cursors.Default;
            }
        }
Пример #3
0
        // DeSerialisoi kartan tiedot Xml tiedostosta SerializedMap olioksi.
        private SerializedMap LoadMapData(string mapName)
        {
            MapDataLoader mapDataLoader = new MapDataLoader(mapDepencyContainer.MapPaths);

            return(mapDataLoader.Load(mapName));
        }
Пример #4
0
        public static void LoadMaps()
        {
            var xml = XElement.Load(@"E:\Trickster\kTO-2014\lifeto-xml\MapInfoEx.xml");

            foreach (var map in xml.Elements("ROW"))
            {
                var id       = int.Parse(map.Element("ID").Value);
                var name     = map.Element("Name").Value;
                var fileName = map.Element("FileName").Value;
                var npcTable = map.Element("NpcTable").Value.Trim();

                if (id < 1)
                {
                    continue;
                }

                Program.logger.Info($"Load Map - {fileName}");

                var data = MapDataLoader.Load(new BinaryReader(File.Open(@"E:\Trickster\kTO-2014\" + fileName, FileMode.Open)));

                var collision = data.ConfigLayers.Where(x => x.Type == 1).FirstOrDefault();

                if (collision == null)
                {
                    Program.logger.Error($"Collision data not found for map {fileName} / {name} ({id})");
                }
                else
                {
                    Maps[id] = new Map()
                    {
                        Id               = id,
                        Name             = name,
                        FileName         = fileName,
                        Width            = data.MapSizeX,
                        Height           = data.MapSizeY,
                        NpcTableFilename = npcTable,
                        Collision        = collision,
                        PointObjects     = data.PointObjects,
                        RangeObjects     = data.RangeObjects
                    };

                    Program.logger.Info($"{name} ({id})  Size: {data.MapSizeX}x{data.MapSizeY}  Collision Size: {collision.X}x{collision.Y}");

                    var grid   = new Grid(collision.X, collision.Y, 1.0f);
                    var iTotal = 0;

                    for (int iY = 0; iY < collision.Y; iY++)
                    {
                        for (int iX = 0; iX < collision.X; iX++)
                        {
                            if (collision.Data[iTotal] != 0x00)
                            {
                                grid.BlockCell(new Position(iX, iY));
                            }
                            iTotal++;
                        }
                    }

                    Maps[id].Grid = grid;
                }

                collision = null;

                data = null;
            }

            xml = null;
        }