예제 #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 LoadPressed()
        {
            if (Importing)
            {
                return;
            }

            Importing = true;
            System.Windows.Forms.OpenFileDialog Open = new System.Windows.Forms.OpenFileDialog();
            Open.Filter      = "Map Descriptor|*.mdes";
            Open.Multiselect = false;
            if (Open.ShowDialog() == System.Windows.Forms.DialogResult.OK)
            {
                MapDataLoader Loader = new MapDataLoader(Open.FileName);
                for (int y = 0; y < Loader.BlockHeight; y++)
                {
                    for (int x = 0; x < Loader.BlockWidth; x++)
                    {
                        string Block = Loader.MapFile.Blocks[x, y];
                        File.Copy(Path.Combine(Loader.FileDirectory, Block), Path.Combine(CreationScene.MapTempPath, Block), true);
                    }
                }
                string Descriptor = Loader.FileBaseName + ".mdes";
                File.Copy(Path.Combine(Loader.FileDirectory, Descriptor), Path.Combine(CreationScene.MapTempPath, Descriptor), true);
                Loader.FileDirectory = CreationScene.MapTempPath;
                JuixelGame.Shared.ChangeScene(new MapScene(Loader, Tiles, JuixelGame.Shared.CurrentScene.Size));
            }
        }
예제 #3
0
    IEnumerator SaveMapData(MapData mapData)
    {
        yield return(null);

        var texture2D = ToTexture2D(mapRenderTexture);

        MapDataLoader.SaveMap(mapData, texture2D);
    }
예제 #4
0
    IEnumerator LoadTexture()
    {
        yield return(null);

        string path = string.Format("file://{0}", MapDataLoader.PathOfMap(mapData.map_name));
        WWW    www  = new WWW(path);

        yield return(www);

        rawImage.texture = www.texture;
        Debug.LogError("Loaded Icon of map " + path);
    }
예제 #5
0
    //[Header("Debug")]
    //[SerializeField] List<MapData> defaultMapDatas = new List<MapData>();

    private void Awake()
    {
        if (Instance == null)
        {
            Instance = this;
            GameObject.DontDestroyOnLoad(this.gameObject);
            LoadData();
        }
        else
        {
            GameObject.DestroyImmediate(this.gameObject);
        }
    }
예제 #6
0
    void DoLoadMap(string map_name, bool isDefaultMap)
    {
        if (string.IsNullOrEmpty(map_name))
        {
            return;
        }
        Debug.LogError("Load Map: " + map_name);
        MapData mapData = MapDataLoader.DataOfMap(map_name, isDefaultMap);

        // convert data to map
        OnClearMap();

        StartCoroutine(DoLoadCreateMap(mapData));
    }
예제 #7
0
 public void StartAutonomousMode()
 {
     BrowseMapPopup.OpenPopup((map_name, isDefaultMap) =>
     {
         if (!string.IsNullOrEmpty(map_name))
         {
             Texture mapTexture = null;
             if (isDefaultMap)
             {
                 mapTexture = MapDataLoader.TextureOfDefaultMap(map_name);
             }
             MapDataLoader.SetInstanceMapData(MapDataLoader.DataOfMap(map_name, isDefaultMap), mapTexture);
             SceneManager.LoadScene("DesignMapAutonomous");
         }
     }, true);
 }
예제 #8
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;
            }
        }
예제 #9
0
        // DeSerialisoi kartan tiedot Xml tiedostosta SerializedMap olioksi.
        private SerializedMap LoadMapData(string mapName)
        {
            MapDataLoader mapDataLoader = new MapDataLoader(mapDepencyContainer.MapPaths);

            return(mapDataLoader.Load(mapName));
        }
예제 #10
0
파일: Data.cs 프로젝트: tousuke/TrickEmuS2
        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;
        }
예제 #11
0
        public MapScene(MapDataLoader Loader, TileData[] Tiles, Location Size) : base(Size)
        {
            Loading             = new LabelNode(Font.Default, "Loading...", 30);
            Loading.Position    = Size / 2;
            Loading.AnchorPoint = 0.5;
            AddChild(Loading);

            Map              = new Map(Loader, new IntLocation((int)Size.X, (int)Size.Y), Tiles);
            Map.OnBlockLoad += StopLoading;
            Map.Position     = Size / 2 - Map.Size / 2;
            AddChild(Map);

            OnResize += OnWindowResize;

            Zoom          = new LabelNode(Font.Default, "", 20);
            Zoom.Color    = Color.LightGray;
            Zoom.Position = new Location(100, 10);
            UI.AddChild(Zoom);

            Action          = new LabelNode(Font.Default, "", 20);
            Action.Color    = Color.LightGray;
            Action.Position = new Location(100, 30);
            UI.AddChild(Action);

            SpriteNode InfoBack = new SpriteNode(TextureLibrary.Square);

            InfoBack.Size     = new Location(220, 55);
            InfoBack.Layer    = -1;
            InfoBack.Color    = Color.Black;
            InfoBack.Alpha    = 0.4f;
            InfoBack.Position = Zoom.Position - 5;
            UI.AddChild(InfoBack);

            DrawToolPreview = new SpriteNode(new Sprite(WBGame.TileSheet, GetDrawPreviewRect()))
            {
                AnchorPoint = new Location(1, 0),
                Size        = 32,
                Position    = new Location(Size.X - 10, 10)
            };
            UI.AddChild(DrawToolPreview);

            Button BackButton = new Button(WBGame.ButtonSprite, "Back", 15, () =>
            {
                JuixelGame.Shared.ChangeScene(new SelectionScene(Size));
            });

            BackButton.Position = new Location(10 + BackButton.Size.X / 2, 10 + BackButton.Size.Y / 2);
            UI.AddChild(BackButton);

            BlockUp = new Button(WBGame.ButtonSprite, "Block Up", 15, () =>
            {
                if (Loading.Hidden)
                {
                    StartLoading();
                    Map.SaveTempBlock();
                    Map.LoadBlock(Map.BlockX, Map.BlockY + 1);
                }
            });
            BlockUp.Position = new Location(Size.X / 2, 30);
            UI.AddChild(BlockUp);

            BlockDown = new Button(WBGame.ButtonSprite, "Block Down", 15, () =>
            {
                if (Loading.Hidden)
                {
                    StartLoading();
                    Map.SaveTempBlock();
                    Map.LoadBlock(Map.BlockX, Map.BlockY - 1);
                }
            });
            BlockDown.Position = new Location(Size.X / 2, Size.Y - 30);
            UI.AddChild(BlockDown);

            BlockLeft = new Button(WBGame.ButtonSprite, "Block Left", 15, () =>
            {
                if (Loading.Hidden)
                {
                    StartLoading();
                    Map.SaveTempBlock();
                    Map.LoadBlock(Map.BlockX - 1, Map.BlockY);
                }
            });
            BlockLeft.Rotation = -90;
            BlockLeft.Position = new Location(30, Size.Y / 2);
            UI.AddChild(BlockLeft);

            BlockRight = new Button(WBGame.ButtonSprite, "Block Right", 15, () =>
            {
                if (Loading.Hidden)
                {
                    StartLoading();
                    Map.SaveTempBlock();
                    Map.LoadBlock(Map.BlockX + 1, Map.BlockY);
                }
            });
            BlockRight.Rotation = 90;
            BlockRight.Position = new Location(Size.X - 30, Size.Y / 2);
            UI.AddChild(BlockRight);

            UpdateBlockButtons();
        }