示例#1
0
        public void LoadState(MapSaver defaults)
        {
            GalaxyDisplay   = defaults.GetSetting("GD", true);
            StarDotsDisplay = defaults.GetSetting("SDD", true);

            TravelPathDisplay         = defaults.GetSetting("TPD", true);
            TravelPathStartDate       = defaults.GetSetting("TPSD", new DateTime(2014, 12, 16));
            TravelPathStartDateEnable = defaults.GetSetting("TPSDE", false);
            TravelPathEndDate         = defaults.GetSetting("TPED", DateTime.UtcNow.AddMonths(1));
            TravelPathEndDateEnable   = defaults.GetSetting("TPEDE", false);
            if (TravelPathStartDateEnable || TravelPathEndDateEnable)
            {
                travelpath.Refresh();       // and refresh it if we set the data
            }
            GalObjectDisplay = defaults.GetSetting("GALOD", true);
            SetAllGalObjectTypeEnables(defaults.GetSetting("GALOBJLIST", ""));

            EDSMRegionsEnable        = defaults.GetSetting("ERe", false);
            EDSMRegionsOutlineEnable = defaults.GetSetting("ERoe", false);
            EDSMRegionsShadingEnable = defaults.GetSetting("ERse", false);
            EDSMRegionsTextEnable    = defaults.GetSetting("ERte", false);

            EliteRegionsEnable        = defaults.GetSetting("ELe", true);
            EliteRegionsOutlineEnable = defaults.GetSetting("ELoe", true);
            EliteRegionsShadingEnable = defaults.GetSetting("ELse", false);
            EliteRegionsTextEnable    = defaults.GetSetting("ELte", true);
            gl3dcontroller.SetPositionCamera(defaults.GetSetting("POSCAMERA", ""));     // go thru gl3dcontroller to set default position, so we reset the model matrix
        }
示例#2
0
        public void SetupWithEditorMap(string newMapName)
        {
            MapSaver mapSaver = new MapSaver();

            mapSaver.LoadMap(newMapName, true);
            SetupSceneMap(mapSaver.GetMap());
        }
示例#3
0
        private void saveButton_Click(object sender, EventArgs e)
        {
            if (board.ParentControl.UserObjects.NewObjects.Count > 0)
            {
                // Flush the UserObjects cache because the map we are saving might use of those images
                if (MessageBox.Show("You have unsaved user objects (images from your computer that you added to the editor). If you proceed, the following images will be written to the WZ file:\r\n\r\n" + board.ParentControl.UserObjects.NewObjects.Select(x => x.l2).Aggregate((x, y) => x + "\r\n" + y) + "\r\n\r\nIf you want to remove some or all of them, exit the saving dialog and remove them first.\r\nProceed?", "Unsaved Objects", MessageBoxButtons.YesNo, MessageBoxIcon.Information) != DialogResult.Yes)
                {
                    return;
                }
                board.ParentControl.UserObjects.Flush();
            }
            MapType  type  = GetIdBoxMapType();
            MapSaver saver = new MapSaver(board);

            if (type == MapType.RegularMap)
            {
                int newId = int.Parse(idBox.Text);
                saver.ChangeMapTypeAndID(newId, MapType.RegularMap);
                saver.SaveMapImage();
                saver.UpdateMapLists();
                MessageBox.Show("Saved map with ID: " + newId.ToString());
            }
            else
            {
                board.MapInfo.strMapName = idBox.Text;
                ((TabItemContainer)board.TabPage.Tag).Text = board.MapInfo.strMapName;
                saver.ChangeMapTypeAndID(-1, type);
                saver.SaveMapImage();
                MessageBox.Show("Saved map: " + board.MapInfo.strMapName);
            }
            Close();
        }
示例#4
0
    public static SavedMap GetMap(string worldName, int level)
    {
        TextAsset binFile = getAssetBundle().LoadAsset(worldName + sepertor + level + fileSufix) as TextAsset;
        MapSaver  saver   = new MapSaver(binFile);

        return(saver.GetMap());
    }
示例#5
0
        private void SaveHpi(UndoableMapModel map, string filename)
        {
            // flatten before save --- only the base tile is written to disk
            map.ClearSelection();

            var randomValue  = this.rng.Next(1000);
            var tmpExtension = $".mappytemp-{randomValue}";

            var tmpFileName = Path.ChangeExtension(filename, tmpExtension);

            try
            {
                MapSaver.SaveHpi(map, tmpFileName);
                File.Delete(filename);
                File.Move(tmpFileName, filename);
            }
            catch
            {
                // Normally the temp file is deleted by File.Replace.
                // Ensure that it is always deleted if an error occurs.
                File.Delete(tmpFileName);
                throw;
            }

            map.MarkSaved(filename);
        }
示例#6
0
 // Use this for initialization
 void Start()
 {
     mapSaver = new MapSaver();
     RefManager.Instance.mapEditorName = "";
     InitMapList();
     renamePanel.GetComponent <RenamePanel>().afterSave = ResetMapList;
 }
示例#7
0
        private static void Save(UndoableMapModel map, string filename)
        {
            // flatten before save --- only the base tile is written to disk
            map.ClearSelection();

            var tntName = filename;
            var otaName = Path.ChangeExtension(filename, ".ota");

            var tmpTntName = tntName + ".mappytemp";
            var tmpOtaName = otaName + ".mappytemp";

            try
            {
                MapSaver.SaveTnt(map, tmpTntName);
                MapSaver.SaveOta(map.Attributes, tmpOtaName);
                File.Delete(tntName);
                File.Delete(otaName);
                File.Move(tmpTntName, tntName);
                File.Move(tmpOtaName, otaName);
            }
            catch
            {
                // Normally the temp files are deleted by File.Replace.
                // Ensure that they are always deleted if an error occurs.
                File.Delete(tmpTntName);
                File.Delete(tmpOtaName);
                throw;
            }

            map.MarkSaved(filename);
        }
示例#8
0
        public void Setup()
        {
            var playerSaver = new PlayerSaver("Player.data");
            var mapSaver    = new MapSaver("Map.data");
            var botsSaver   = new BotsSaver("Bots.data");

            SaveSystem.AddSaver(playerSaver);
            SaveSystem.AddSaver(mapSaver);
            SaveSystem.AddSaver(botsSaver);
        }
示例#9
0
        private void saveToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if (_map == null)
            {
                return;
            }

            byte[] mapState = _map.GetState();
            MapSaver.Save("Map.txt", mapState);
        }
示例#10
0
    /// <summary>
    /// Load a map from the RefManager
    /// </summary>
    /// <returns>return true if the function loaded map otherwise false</returns>
    private bool loadMap()
    {
        if (RefManager.Instance.mapEditorName.Length == 0)
        {
            return(false);
        }
        MapSaver mapSaver = new MapSaver(RefManager.Instance.mapEditorName, true);

        ConvertMapToGrid(mapSaver.GetMap());
        return(true);
    }
示例#11
0
 // Use this for initialization
 private void Start()
 {
     if (instance == null)
     {
         instance = this;
     }
     else
     {
         instance.gameObject.SetActive(true);
         Destroy(gameObject);
     }
 }
示例#12
0
    private void Start()
    {
        _levelParent = new GameObject("Level");
        var ui = EditorUIManager.Instance;

        _mapSaver  = GetComponent <MapSaver>();
        _mapLoader = GetComponent <MapLoader>();

        for (int i = 0; i < _placeableObjects.Count; ++i)
        {
            ui.AddButton(i);
        }
    }
示例#13
0
        public void SaveMap()
        {
            var mapSaver = new MapSaver();
            var savePath = MapFilePath;

            // if (MapFilePath.IndexOf(Constants.EditedMapTag, StringComparison.InvariantCultureIgnoreCase) == -1)
            // {
            //  int extIdx = savePath.LastIndexOf('.');
            //  // savePath = savePath.Insert(extIdx, Constants.EditedMapTag);
            //
            //  SavedMapFileName = Path.GetFileName(savePath);
            // }

            Prefs.PreviousMapPath.Set(savePath);

            mapSaver.SaveMap(Map, MapFilePath);
        }
    static void Main(string[] args)
    {
        ImportMap           importMap           = new ImportMap();
        MapTransformer      mapTrans            = new MapTransformer();
        ImportTraj          importTraj          = new ImportTraj();
        RandomMap           rand                = new RandomMap();
        TrajGenerator       trajGenerator       = new TrajGenerator();
        TrajSaver           trajSaver           = new TrajSaver();
        MapPruner           mapPruner           = new MapPruner();
        SampleNeighbourhood sampleNeighbourhood = new SampleNeighbourhood();
        MapSaver            mapSaver            = new MapSaver();
        Evaluator           eval                = new Evaluator(rand, sampleNeighbourhood);

        Map gt = importMap.ReadMap($"Chicago/Chicago-200-directed-50-100");
        Map cm = importMap.ReadMap($"Kharita/Directed/Chicago-200-50-100");

        (float, float)precall = eval.EvalNeighbourhood(gt, cm);

        Console.WriteLine(precall);
    }
示例#15
0
 public void SaveState(MapSaver defaults)
 {
     defaults.PutSetting("GD", GalaxyDisplay);
     defaults.PutSetting("SDD", StarDotsDisplay);
     defaults.PutSetting("TPD", TravelPathDisplay);
     defaults.PutSetting("TPSD", TravelPathStartDate);
     defaults.PutSetting("TPSDE", TravelPathStartDateEnable);
     defaults.PutSetting("TPED", TravelPathEndDate);
     defaults.PutSetting("TPEDE", TravelPathEndDateEnable);
     defaults.PutSetting("GALOD", GalObjectDisplay);
     defaults.PutSetting("GALOBJLIST", GetAllGalObjectTypeEnables());
     defaults.PutSetting("ERe", EDSMRegionsEnable);
     defaults.PutSetting("ERoe", EDSMRegionsOutlineEnable);
     defaults.PutSetting("ERse", EDSMRegionsShadingEnable);
     defaults.PutSetting("ERte", EDSMRegionsTextEnable);
     defaults.PutSetting("ELe", EliteRegionsEnable);
     defaults.PutSetting("ELoe", EliteRegionsOutlineEnable);
     defaults.PutSetting("ELse", EliteRegionsShadingEnable);
     defaults.PutSetting("ELte", EliteRegionsTextEnable);
     defaults.PutSetting("POSCAMERA", gl3dcontroller.PosCamera.StringPositionCamera);
 }
        public bool SaveMap(Map map, bool saveAs = false)
        {
            Debug.Assert(map != null);

            if (CurrentMapFile == null || saveAs)
            {
                var saveFileDialog = new SaveFileDialog
                {
                    DefaultExt       = ".xml",
                    Filter           = Resources.MapFileFilter,
                    InitialDirectory = Path.GetDirectoryName(CurrentMapFile) ?? ""
                };
                if (saveFileDialog.ShowDialog() == DialogResult.Cancel)
                {
                    return(false);
                }
                CurrentMapFile = saveFileDialog.FileName;
            }
            MapSaver.Save(CurrentMapFile, map);
            StatusBarMessage("Map saved.");
            return(true);
        }
示例#17
0
    /// <summary>
    /// The function that save the map after the rename panel
    /// </summary>
    /// <param name="mapName"></param>
    public void SaveMap(string mapName)
    {
        MapSaver mapSaver = new MapSaver(ConvertGridToMap());

        mapSaver.Save(mapName, true);
    }
示例#18
0
    /// <summary>
    ///  saves the map in xml
    /// </summary>
    /// <param name="path"></param>
    public static void MapSave(string path)
    {
        WorldBuilderII world = GameObject.FindGameObjectWithTag("Ground").GetComponent<WorldBuilderII>();
        MapSaver map_save = new MapSaver(world);

        var serializer = new XmlSerializer(typeof(MapSaver));
        using (var stream = new FileStream(path, FileMode.Create))
        {
            serializer.Serialize(stream, map_save);
        }
    }
示例#19
0
    void SaveMap(string fileName)
    {
        MapSaver mapSaver = new MapSaver(mapSaveProperties);

        mapSaver.SaveMap(fileName);
    }
示例#20
0
        public void Update()
        {
            switch (State)
            {
            case GameState.GeneratingMap:
                if (!InvokeAction())
                {
                    Map.SetMap(MapGenerator.ConvertWriteableBitmapToBitmapImage(Map.GetWriteableBitmap()));
                    Map.Init();
                    SetState(GameState.ReadyToInitialize);
                }
                break;

            case GameState.ReadyToInitialize:
                Initialize();
                break;

            case GameState.Initializing_FindCountries:
                if (!InvokeAction())
                {
                    if (initX == Map.Width - 1 && initY == Map.Height - 1)
                    {
                        CreateWaters();
                        RemoveUnnecessaryBorders();
                        ActionQueue.AddRange(FindNeighboursQueue);
                        SetState(GameState.Initializing_FindNeighbours);
                    }
                    else
                    {
                        do
                        {
                            if (initX == Map.Width - 1)
                            {
                                initX = 0;
                                initY++;
                            }
                            else
                            {
                                initX++;
                            }
                        } while (!(initX == Map.Width - 1 && initY == Map.Height - 1) && Map.CompletedPoints[initX, initY]);
                        if (!(initX == Map.Width - 1 && initY == Map.Height - 1))
                        {
                            ActionQueue.Insert(0, () => FloodFill(true, initX, initY, MapPixelType.STARTVALUE));
                        }
                    }
                }
                break;

            case GameState.Initializing_FindNeighbours:
                if (!InvokeAction())
                {
                    DistanceToNearestBorderFinder finder = new DistanceToNearestBorderFinder(Map, ActionQueue);
                    ActionQueue.Add(() => finder.FindDistancesToNearestBorder(NearestBorderAlgorithm.BorderSpreadFourDirections));
                    FindNeighboursQueue.Clear();
                    SetState(GameState.Initializing_FindDistancesToNearestBorder);
                }
                break;

            case GameState.Initializing_FindDistancesToNearestBorder:
                if (!InvokeAction())
                {
                    SetSelectedBorders();
                    SetCenters();
                    ConnectIslands();
                    ConnectCloseCountriesOverWater(MaxWaterConnectionDistance);
                    Map.Name = "xxx";
                    MapSaver.SaveMap(Map, MapSelection.MAP_PATH);
                    SetState(GameState.ReadyToPlay);
                }
                break;

            case GameState.Playing_Initialize:
                if (!InvokeAction(int.Parse(RunSpeed.Text)))
                {
                    SetState(GameState.Playing_Idle);
                }
                break;

            case GameState.ReadyToPlay:
                InvokeAction(int.Parse(RunSpeed.Text));
                break;

            case GameState.Playing_Idle:
                if (!InvokeAction(int.Parse(RunSpeed.Text)) && AutoRun.IsChecked == true)
                {
                    NextTurn();
                }
                CheckGameOver();
                break;

            case GameState.Playing_DistrubutionPhase:
                if (!InvokeAction(int.Parse(RunSpeed.Text)))
                {
                    ActionQueue.Add(() => attackAgain = Players[currentPlayer].DoTurn(this));
                    SetState(GameState.Playing_AttackPhase);
                }
                break;

            case GameState.Playing_AttackPhase:
                if (!InvokeAction(int.Parse(RunSpeed.Text)))
                {
                    if (attackAgain)
                    {
                        ActionQueue.Add(() => attackAgain = Players[currentPlayer].DoTurn(this));
                    }
                    else
                    {
                        ActionQueue.Add(() => Players[currentPlayer].EndTurn(this));
                        SetState(GameState.Playing_MovePhase);
                    }
                }
                break;

            case GameState.Playing_MovePhase:
                if (!InvokeAction(int.Parse(RunSpeed.Text)))
                {
                    Player next;
                    do
                    {
                        currentPlayer = (currentPlayer + 1) % Players.Count;
                        next          = Players[currentPlayer];
                        UIManager.SetupPlayerOrderGrid(Players, currentPlayer);
                    } while (!next.Alive);
                    SetState(GameState.Playing_Idle);
                }
                break;
            }
        }
示例#21
0
 // Use this for initialization
 void Start()
 {
     mapSaver       = new MapSaver();
     warningManager = warningManagerObj.GetComponent <WarningManager>();
 }
示例#22
0
 private void Awake()
 {
     _instance = this;
 }