Exemple #1
0
 void CreateNewChart(Texture2D map)
 {
     chart      = ChartStatic.Construct(map);
     chart.name = "New Chart";
     LoadChart(chart);
     SaveChart();
 }
Exemple #2
0
 void CreateNewChart(Texture2D map)
 {
     properties.chart      = ChartStatic.Construct(map);
     properties.chart.name = "New Chart";
     LoadChart(properties.chart);
     SaveChart();
 }
Exemple #3
0
 ChartStatic CarveEntrancesIntoChart(RawChart chart, Maze maze, Coord coord)
 {
     IEnumerable<MapEntrance> entrances = GetEntrances(maze, coord);
     chart.Seed = seed;
     var staticModule = MapGenStaticMap.Construct(chart.Map);
     var carvedModule = MapGenEntranceCarver.Construct(staticModule, entrances);
     return ChartStatic.ReplaceMap(carvedModule.Generate(seed), chart);
 }
Exemple #4
0
        /// <summary>
        /// Replaces the map in the chart, creating a new static chart with the same markers and metadata as the original.
        /// Note that the copy may be shallow.
        /// </summary>
        public static ChartStatic ReplaceMap(Map map, RawChart chart)
        {
            ChartStatic newChart = Construct(map);

            newChart.name     = chart.name;
            newChart.markers  = chart.Markers.ToList();
            newChart.metaData = chart.MetaData;
            return(newChart);
        }
Exemple #5
0
        void DrawChartField()
        {
            EditorGUI.BeginChangeCheck();
            var newChart = (ChartStatic)EditorGUILayout.ObjectField(chart, typeof(ChartStatic), false);

            if (EditorGUI.EndChangeCheck())
            {
                MarkChartDirty();
                chart = newChart;
                LoadChart(chart);
            }
        }
Exemple #6
0
        public static ChartStatic Construct(Map map)
        {
            if (map == null)
            {
                throw new ArgumentNullException();
            }

            Texture2D   mapTexture = map.ToTexture();
            ChartStatic chart      = Construct(mapTexture);

            chart.cachedMap = map;
            return(chart);
        }
Exemple #7
0
 void LoadChart(ChartStatic chart)
 {
     if (chart == null)
     {
         markers.Clear();
         chartName = string.Empty;
     }
     else
     {
         markers   = chart.Markers.Select(m => MarkerNode.Construct(m)).ToList();
         chartName = chart.name;
     }
 }
Exemple #8
0
        public static ChartStatic Construct(Texture2D map)
        {
            if (map == null)
            {
                throw new ArgumentNullException();
            }

            ChartStatic chart = CreateInstance <ChartStatic>();

            chart.texture  = map;
            chart.metaData = new MetaData();
            chart.markers  = new List <RawMarker>();
            return(chart);
        }
Exemple #9
0
        void Load()
        {
            var save = ChartEditorSave.Load();

            if (save != null)
            {
                chart                     = save.chart;
                customPalette             = save.palette;
                scale                     = save.scale;
                showGrids                 = save.showGrids;
                snapSetting               = save.snapSetting;
                panelChartFoldout         = save.panelChartFoldout;
                panelEditorOptionsFoldout = save.panelEditorOptionsFoldout;
                panelMarkerOptionsFoldout = save.panelMarkerOptionsFoldout;
            }
        }
Exemple #10
0
        public override Dictionary <Coord, RawChart> GetCharts(Maze maze)
        {
            ValidateCharts();
            random = new System.Random(seed);
            Coord[] cells         = maze.GetCells();
            var     chartsByCoord = new Dictionary <Coord, RawChart>();

            for (int i = 0; i < cells.Length; i++)
            {
                Coord         cell            = cells[i];
                ChartStatic[] candidateCharts = DetermineChartCandidates(maze, cell);
                RawChart      chart           = candidateCharts[random.Next(0, candidateCharts.Length)];
                ChartStatic   carvedChart     = CarveEntrancesIntoChart(chart, maze, cell);
                chartsByCoord[cell] = carvedChart;
            }
            return(chartsByCoord);
        }
Exemple #11
0
 static void CopyMarkers(UnityEditor.MenuCommand command)
 {
     _copyContext = (ChartStatic)command.context;
 }