private SaveMap BeforeSaveEntities(SaveMap saveMap)
        {
            // Only save selected DTO types
            var badType = saveMap.Keys
                          .FirstOrDefault(k => k != typeof(Customer) && k != typeof(Product));

            if (badType != null)
            {
                throw new InvalidOperationException("Cannot save changes to type " + badType.Name);
            }

            // Need a new NorthwindDtoRepository for reading;
            // Can't use the existing one during a save because for unknown reason
            // EF DbContext crashes with nullref exception.
            var readRepo = new NorthwindDtoRepository {
                UserSessionId = UserSessionId
            };

            _customerMapper = new CustomerMapper(readRepo);
            _productMapper  = new ProductMapper();


            // convert DTO types to corresponding server types
            saveMap.ConvertBeforeSaveMap(
                _contextProvider.CreateEntityInfo, _entitySaveGuard.BeforeSaveEntity,
                _customerMapper, _productMapper);

            // Now ready to apply server model validation
            _entitySaveGuard.BeforeSaveEntities(saveMap);

            return(saveMap);
        }
Beispiel #2
0
        /// <summary>
        /// Load a saved map and create a real game map with it
        /// </summary>
        /// <param name="name">Path of saved map file</param>
        public void loadTileMap(string name)
        {
            SaveMap sm = Serializer <SaveMap> .Load(name);

            tileMap   = sm.tileMap.ConvertAll(BlockObject.LoadBlock);
            platforms = sm.platforms.ConvertAll(MapPlatform.LoadPlatform);
        }
        /// <summary>
        /// Creates a <see cref="SaveResult"/>.
        /// </summary>
        /// <returns>The save result.</returns>
        public SaveResult ToSaveResult()
        {
            var entities    = new List <object>();
            var deletedKeys = new List <EntityKey>();

            foreach (var entityInfo in SaveMap.SelectMany(o => o.Value))
            {
                var state = entityInfo.EntityState;
                if (state != EntityState.Detached)
                {
                    entities.Add(entityInfo.ClientEntity);
                }

                if (state == EntityState.Deleted || state == EntityState.Detached)
                {
                    deletedKeys.Add(new EntityKey(
                                        BreezeHelper.GetBreezeTypeFullName(entityInfo.EntityType),
                                        entityInfo.GetIdentifierValues()));
                }
            }

            return(new SaveResult
            {
                Entities = entities,
                KeyMappings = KeyMappings,
                DeletedKeys = deletedKeys
            });
        }
 public SaveResult ToSaveResult()
 {
     WasUsed = true; // try to prevent reuse in subsequent SaveChanges
     if (EntityErrors != null)
     {
         return(new SaveResult()
         {
             Errors = EntityErrors.Cast <object>().ToList()
         });
     }
     else
     {
         var entities = SaveMap.SelectMany(kvp => kvp.Value.Where(ei => (ei.EntityState != EntityState.Detached))
                                           .Select(entityInfo => entityInfo.Entity)).ToList();
         var deletes = SaveMap.SelectMany(kvp => kvp.Value
                                          .Where(ei => (ei.EntityState == EntityState.Deleted || ei.EntityState == EntityState.Detached))
                                          .Select(entityInfo =>
                                                  new EntityKey(entityInfo.Entity, ContextProvider.GetKeyValues(entityInfo))))
                       .ToList();
         return(new SaveResult()
         {
             Entities = entities, KeyMappings = KeyMappings, DeletedKeys = deletes
         });
     }
 }
        //Save and Load Methods
        //--------
        public static void Save(string _path, TileWorldCreator _creator)
        {
            saveMapContent = "";

            if (_path == "")
            {
                return;
            }


            for (int i = 0; i < _creator.configuration.worldMap.Count; i++)
            {
                bool[] _tmpMapSingle     = new bool[_creator.configuration.worldMap[i].cellMapSingle.Length];
                bool[] _tmpMaskMapSingle = new bool[_creator.configuration.worldMap[i].maskMapSingle.Length];

                _tmpMapSingle     = _creator.configuration.worldMap[i].cellMapSingle;
                _tmpMaskMapSingle = _creator.configuration.worldMap[i].maskMapSingle;

                SaveMap _map = new SaveMap(_tmpMapSingle, _tmpMaskMapSingle, _creator.configuration.global.width, _creator.configuration.global.height, _creator.configuration.worldMap[i].useMask, _creator.configuration.worldMap[i].selectedMask);


                AddData <SaveMap>(_map);
            }


            FileStream   _fs = new FileStream(_path, FileMode.Create, FileAccess.Write);
            StreamWriter _sw = new StreamWriter(_fs);

            _sw.Write(saveMapContent);

            _sw.Flush();
            _sw.Close();
        }
Beispiel #6
0
        public SaveResult ToSaveResult()
        {
            WasUsed = true; // try to prevent reuse in subsequent SaveChanges
            if (EntityErrors != null)
            {
                return(new SaveResult()
                {
                    Errors = EntityErrors.Cast <Object>().ToList()
                });
            }
            else
            {
                var entities = SaveMap.SelectMany(kvp => kvp.Value.Where(ei => (ei.EntityState != EntityState.Detached))
                                                  .Select(entityInfo => entityInfo.Entity)).ToList();

                // we want to stub off any navigation properties here, but how to do it quickly.
                // entities.ForEach(e => e
                var deletes = SaveMap.SelectMany(kvp => kvp.Value.Where(ei => (ei.EntityState == EntityState.Deleted || ei.EntityState == EntityState.Detached))
                                                 .Select(entityInfo => new EntityKey(entityInfo.Entity, ContextProvider.GetKeyValues(entityInfo)))).ToList();
                return(new SaveResult()
                {
                    Entities = entities, KeyMappings = KeyMappings, DeletedKeys = deletes
                });
            }
        }
Beispiel #7
0
        public static SaveMap AuditMap(this SaveMap saveMap, int loggedInUserId)
        {
            var predicate =
                saveMap
                .Where(map => typeof(IAuditable)
                       .IsAssignableFrom(map.Key))
                .SelectMany(map => map.Value)
                .Select(info => info);

            foreach (var info in predicate)
            {
                var auditable = info.Entity as IAuditable;

                Contract.Assert(auditable != null);

                auditable.ModifiedById = loggedInUserId;
                auditable.ModifiedDate = DateTime.Now;

                if (info.OriginalValuesMap == null)
                {
                    continue;
                }

                info.OriginalValuesMap["ModifiedById"] = null;
                info.OriginalValuesMap["ModifiedDate"] = null;
            }

            return(saveMap);
        }
Beispiel #8
0
        public static SaveMap SoftDeleteMap(this SaveMap saveMap, int loggedInUserId)
        {
            var predicate =
                saveMap
                .Where(map => typeof(ISoftDelete)
                       .IsAssignableFrom(map.Key))
                .SelectMany(map => map.Value)
                .Select(info => info);

            foreach (var info in predicate)
            {
                var softDeletable = info.Entity as ISoftDelete;

                Contract.Assert(softDeletable != null);

                softDeletable.DeletedById = loggedInUserId;
                softDeletable.DeletedDate = DateTime.Now;
                softDeletable.IsDeleted   = true;

                if (info.OriginalValuesMap == null)
                {
                    continue;
                }

                info.OriginalValuesMap["DeletedById"] = null;
                info.OriginalValuesMap["DeletedDate"] = null;
                info.OriginalValuesMap["IsDeleted"]   = null;
            }

            return(saveMap);
        }
Beispiel #9
0
        //Save and Load Methods
        //--------


        public static void Save(string _path, TileWorldCreator _creator)
        {
            saveMapContent = "";

            if (_path == "")
            {
                return;
            }


            for (int i = 0; i < _creator.configuration.worldMap.Count; i++)
            {
                bool[] _tmpMapSingle     = new bool[_creator.configuration.worldMap[i].cellMapSingle.Length];
                bool[] _tmpMaskMapSingle = new bool[_creator.configuration.worldMap[i].maskMapSingle.Length];

                _tmpMapSingle     = _creator.configuration.worldMap[i].cellMapSingle;
                _tmpMaskMapSingle = _creator.configuration.worldMap[i].maskMapSingle;

                SaveMap _map = new SaveMap(_tmpMapSingle, _tmpMaskMapSingle, _creator.configuration.global.width, _creator.configuration.global.height, _creator.configuration.global.layerPresetIndex[i], _creator.configuration.worldMap[i].useMask, _creator.configuration.worldMap[i].selectedMask);


                AddData <SaveMap>(_map);
            }


            byte[] bytes = SerializationUtility.SerializeValue(saveMapContent, DataFormat.Binary);
            File.WriteAllBytes(_path, bytes);
        }
Beispiel #10
0
    // 存檔.
    public void Save()
    {
        SaveMap Temp = new SaveMap();

        Temp.DataRoad = DataRoad.ToArray();
        Temp.DataObjt = DataObjt.Values.ToArray();

        PlayerPrefs.SetString(GameDefine.szSaveMap, Json.ToString(Temp));
    }
Beispiel #11
0
        public static SaveMap RemoveMaps(this SaveMap saveMap, List <KeyValuePair <Type, List <EntityInfo> > > unauthorizedTypes)
        {
            foreach (var uat in unauthorizedTypes)
            {
                saveMap.Remove(uat.Key);
            }

            return(saveMap);
        }
Beispiel #12
0
    // Start is called before the first frame update
    void Carregue()
    {
        ContainerPlusMap p = new ContainerPlusMap(
            JsonUtility.FromJson <JsonMapContainer>(
                SaveMap.CarregarArquivoParaJson(bPath.GetPath)));

        p.CreateScenario(bPath.GetFileName, xvar, yvar);
        //p.testeGetTexture(bPath.GetFileName, mytex);
        //p.MostrarCoresDoDicionario();
    }
        private void AfterSaveEntities(SaveMap saveMap, List <KeyMapping> keyMappings)
        {
            // Apply server model post-save actions first
            _entitySaveGuard.AfterSaveEntities(saveMap, keyMappings);

            // Now convert from server types to corresponding client types
            saveMap.ConvertAfterSaveMap(
                keyMappings, _contextProvider.CreateEntityInfo,
                _customerMapper, _productMapper);
        }
        public SaveMap BeforeSaveEntities(SaveMap saveMap)
        {
            var unAuthorizedMaps = saveMap.Where(map => map.Key != _tWg &&
                                                 map.Key != _tFacComment &&
                                                 map.Key != _tFacStratResp &&
                                                 map.Key != _tFacSpResp &&
                                                 map.Key != _tStudCommentFlag &&
                                                 map.Key != _tFacCommentFlag)
                                   .ToList();

            //.Select(map => map.Key);

            saveMap.RemoveMaps(unAuthorizedMaps);

            var courseMonitorEntities = saveMap.MonitorCourseMaps()?.ToList();

            //if (courseMonitorEntities != null) ProcessCourseMonitoredMaps(courseMonitorEntities);

            var workGroupMonitorEntities = saveMap.MonitorWgMaps()?.ToList();

            //if (workGroupMonitorEntities != null) ProcessWorkGroupMonitoredMaps(workGroupMonitorEntities);

            //moved processing for monitored entities to monitoredguard
            if (courseMonitorEntities != null || workGroupMonitorEntities != null)
            {
                var monitoredGuard = new MonitoredGuard(ctxManager);

                if (courseMonitorEntities != null)
                {
                    monitoredGuard.ProcessCourseMonitoredMaps(courseMonitorEntities);
                }

                if (workGroupMonitorEntities != null)
                {
                    monitoredGuard.ProcessFacultyWorkGroupMonitoredMaps(workGroupMonitorEntities);
                }
            }

            if (saveMap.ContainsKey(_tWg))
            {
                var workGroupMap = ProcessWorkGroup(saveMap[_tWg]);
                saveMap.MergeMap(workGroupMap);
            }

            if (saveMap.ContainsKey(_tFacComment))
            {
                ProcessComments(saveMap[_tFacComment]);
            }

            saveMap.AuditMap(loggedInUser.PersonId);
            saveMap.SoftDeleteMap(loggedInUser.PersonId);
            return(saveMap);
        }
Beispiel #15
0
 /// <summary>
 /// Convert the post-save server entities into client entities.
 /// </summary>
 /// <remarks>
 /// See <see cref="EntitySaveMapper{STYPE, CTYPE}.ConvertAfterSaveMap "/> for details
 /// </remarks>
 public static SaveMap ConvertAfterSaveMap(
     this SaveMap saveMap,
     List <KeyMapping> keyMappings,
     EntityInfoCreator entityInfoCreator,
     params IEntitySaveMapper[] saveMappers)
 {
     foreach (var saveMapper in saveMappers)
     {
         saveMapper.ConvertAfterSaveMap(saveMap, keyMappings, entityInfoCreator);
     }
     return(saveMap);
 }
Beispiel #16
0
 /// <summary>
 /// Convert an <see cref="EntityInfo"/> "SaveMap" with
 /// one or more <see cref="IEntitySaveMapper"/> instances.
 /// </summary>
 /// <remarks>
 /// See <see cref="EntitySaveMapper{STYPE, CTYPE}.ConvertBeforeSaveMap "/> for details
 /// </remarks>
 public static SaveMap ConvertBeforeSaveMap(
     this SaveMap saveMap,
     EntityInfoCreator entityInfoCreator,
     BeforeSaveEntityDelegate beforeSaveEntity,
     params IEntitySaveMapper[] saveMappers)
 {
     foreach (var saveMapper in saveMappers)
     {
         saveMapper.ConvertBeforeSaveMap(saveMap, entityInfoCreator, beforeSaveEntity);
     }
     return(saveMap);
 }
Beispiel #17
0
        public static IEnumerable <EntityInfo> MonitorCourseMaps(this SaveMap saveMap)
        {
            //Is there anything to monitored?
            var anyCourseMonitors = saveMap.Keys.Where(key => typeof(ICourseMonitored).IsAssignableFrom(key)).ToList();

            if (!anyCourseMonitors.Any())
            {
                return(null);
            }

            return(saveMap.Where(map => anyCourseMonitors.Contains(map.Key))
                   .SelectMany(info => info.Value));
        }
    /*
     * public int[,,] Map;
     * public char[,,] PathMap;
     * public int xsize;
     * public int ysize;
     * public int zsize;
     * public int yscale;
     * public int level;
     * public int yslices;
     * public List<Thing> ThingList;
     * public List<MonsterThing> MonsterThingList;
     */

    public SaveMap Save()
    {
        SaveMap saveMap = new SaveMap();

        saveMap.Map     = new int[xsize * ysize * zsize];  //Map;
        saveMap.PathMap = new char[xsize * ysize * zsize]; //PathMap;

        for (int k = 0; k < ysize; k++)
        {
            for (int j = 0; j < zsize; j++)
            {
                for (int i = 0; i < xsize; i++)
                {
                    saveMap.Map[i + j * xsize + k * xsize * zsize]     = Map[i, k, j];
                    saveMap.PathMap[i + j * xsize + k * xsize * zsize] = PathMap[i, k, j];
                }
            }
        }

        saveMap.xsize   = xsize;
        saveMap.ysize   = ysize;
        saveMap.zsize   = zsize;
        saveMap.yscale  = yscale;
        saveMap.level   = level;
        saveMap.yslices = yslices;
        GameObject[] objlist;
        string[]     tags = { "Items", "Decorations", "Plant", "Ladder", "Stairs", "Monster" };
        foreach (string thistag in tags)
        {
            objlist = GameObject.FindGameObjectsWithTag(thistag);
            if (objlist.Length > 0)
            {
                foreach (GameObject thisobj in objlist)
                {
                    if (thisobj.transform.parent == null)
                    {
                        if (thistag == "Monster")
                        {
                            saveMap.AddMonsterThing(thisobj);
                        }
                        else
                        {
                            saveMap.AddThing(thisobj);
                        }
                    }
                }
            }
        }
        return(saveMap);
    }
        public void Update(float deltaTime)
        {
            if (Keyboard.GetState().IsKeyDown(Keys.F1) && lastKeyboard.IsKeyUp(Keys.F1))
            {
                SaveFileDialog saveFile = new SaveFileDialog()
                {
                    Filter = "Xml files|*.xml|All Files|*.*"
                };
                if (saveFile.ShowDialog() == true)
                {
                    SaveMap.Save(saveFile.FileName);
                }
            }

            lastKeyboard = Keyboard.GetState();
        }
Beispiel #20
0
        /// <summary>
        /// Convert the SaveMap <see cref="EntityInfo"/> entries of the <see cref="CType"/>
        /// into EntityInfo entries for the <see cref="SType"/>.
        /// </summary>
        /// <param name="saveMap">
        /// The "SaveMap" passed into the <see cref="ContextProvider.BeforeSaveEntities"/> method.
        /// </param>
        /// <param name="entityInfoCreator">
        /// Function that creates a new <see cref="EntityInfo"/> for a
        /// given entity and optional <see cref="EntityState"/>.
        /// See <see cref="ContextProvider.CreateEntityInfo"/>.
        /// </param>
        /// <param name="beforeSaveEntity">
        /// Optional function to validate an individual entity before it can save;
        /// see <see cref="ContextProvider.BeforeSaveEntity"/>"/>;
        /// </param>
        /// <remarks>
        /// Updates the "SaveMap" by converting those <see cref="EntityInfo"/> objects
        /// constructed from the JSON "saveBundle" in terms of the client's entity type
        /// into corresponding EntityInfos expressed in terms of the server entity type.
        /// Converts with the <see cref="MapEntityToServer"/>.
        /// <para>
        /// Call it inside your <see cref="ContextProvider.BeforeSaveEntities"/>
        /// override or delegate method.
        /// </para>
        /// </remarks>
        public SaveMap ConvertBeforeSaveMap(
            SaveMap saveMap,
            EntityInfoCreator entityInfoCreator,
            BeforeSaveEntityDelegate beforeSaveEntity = null)
        {
            List <EntityInfo> cGroup, sGroup;

            if (saveMap.TryGetValue(cType, out cGroup))
            {
                saveMap.Remove(cType); // don't save CType entities
            }
            else
            {
                return(saveMap); // this CType is not in the saveMap
            }

            if (!saveMap.TryGetValue(sType, out sGroup))
            {
                sGroup = new List <EntityInfo>();
                saveMap.Add(sType, sGroup);
            }

            foreach (var cEntityInfo in cGroup)
            {
                var sEntity = MapEntityToServer(cEntityInfo);
                if (sEntity == null)
                {
                    continue;
                }

                var mappedEntityInfo = entityInfoCreator(sEntity, cEntityInfo.EntityState);
                mappedEntityInfo.OriginalValuesMap = MapOriginalValues(cEntityInfo.OriginalValuesMap);
                mappedEntityInfo.AutoGeneratedKey  = MapAutoGeneratedKey(sEntity, cEntityInfo.AutoGeneratedKey);
                mappedEntityInfo.ForceUpdate       = cEntityInfo.ForceUpdate;

                // TODO: Fix this deficiency
                // Unfortunately, UnmappedValuesMap is "protected internal" right now so can't copy
                //mappedEntityInfo.UnmappedValuesMap = entityInfo.UnmappedValuesMap;

                if (beforeSaveEntity == null || beforeSaveEntity(mappedEntityInfo))
                {
                    sGroup.Add(mappedEntityInfo);
                }
            }
            return(saveMap);
        }
Beispiel #21
0
        public SaveMap Save(string saveName)
        {
            SaveMap save = new SaveMap()
            {
                name        = "New :)",
                crossPoints = new SaveGridNode[gridNodes.Count]
            };

            int i = 0;

            foreach (Node n in useNodes)
            {
                save.crossPoints[i++] = n.Save();
            }

            return(save);
        }
Beispiel #22
0
        public static SaveMap MergeMap(this SaveMap saveMap, SaveMap newMap)
        {
            foreach (var map in newMap)
            {
                List <EntityInfo> infos;

                var hasKey = saveMap.TryGetValue(map.Key, out infos);
                if (hasKey)
                {
                    saveMap[map.Key].AddRange(infos);
                }
                else
                {
                    saveMap.Add(map.Key, map.Value);
                }
            }
            return(saveMap);
        }
Beispiel #23
0
 public SaveResult ToSaveResult()
 {
     if (EntityErrors != null)
     {
         return(new SaveResult()
         {
             Errors = EntityErrors.Cast <Object>().ToList()
         });
     }
     else
     {
         var entities = SaveMap.SelectMany(kvp => kvp.Value.Select(entityInfo => entityInfo.Entity)).ToList();
         return(new SaveResult()
         {
             Entities = entities, KeyMappings = KeyMappings
         });
     }
 }
Beispiel #24
0
 public void Load(SaveMap save)
 {
     /*
      * for (int i = 0 ; i < save.crossPoints.Length ; ++i)
      * {
      *      SaveGridNode node = save.crossPoints[i];
      *      RaycastHit hit;
      *
      *      if (Physics.Raycast(node.position + Vector3.up, Vector3.down, out hit, LayerMask.GetMask(Constante.Layer.GridNode)))
      *      {
      *              Node gridNode = hit.transform.GetComponent<Node>();
      *              if (gridNode == null)
      *                      continue;
      *              gridNode.SetType(node.type);
      *      }
      * }
      * /**/
 }
Beispiel #25
0
 public SaveResult ToSaveResult()
 {
     WasUsed = true; // try to prevent reuse in subsequent SaveChanges
     if (EntityErrors != null)
     {
         return(new SaveResult()
         {
             Errors = EntityErrors.Cast <Object>().ToList()
         });
     }
     else
     {
         var entities = SaveMap.SelectMany(kvp => kvp.Value.Select(entityInfo => entityInfo.Entity)).ToList();
         return(new SaveResult()
         {
             Entities = entities, KeyMappings = KeyMappings
         });
     }
 }
Beispiel #26
0
        /// <summary>
        /// Convert the post-save <see cref="SType"/> entities into the <see cref="CType"/> entities
        /// that the client is expecting.
        /// </summary>
        /// <param name="saveMap">
        /// The <see cref="SaveResult"/> returned by <see cref="ContextProvider.SaveChanges"/>
        /// </param>
        /// <param name="keyMappings">
        /// The <see cref="SaveResult"/> returned by <see cref="ContextProvider.SaveChanges"/>
        /// </param>
        /// <param name="entityInfoCreator">
        /// Function that creates a new <see cref="EntityInfo"/> for a
        /// given entity and optional <see cref="EntityState"/>.
        /// See <see cref="ContextProvider.CreateEntityInfo"/>.
        /// </param>
        /// <remarks>
        /// Converts the <see cref="SType"/> entities in the "SaveMap" and <see cref="KeyMapping"/> list
        /// passed to the <see cref="ContextProvider.AfterSaveEntities"/> after
        /// the <see cref="ContextProvider.SaveChangesCore"/>.
        /// It uses the <see cref="MapEntityToClient"/> to convert the <see cref="SType"/> entities into
        /// corresponding <see cref="CType"/> entities.
        /// Use <see cref="MapEntityToClient"/> to convert the <see cref="SType"/> entities in
        /// <see cref="SaveResult.Entities"/> with
        /// <para>
        /// Call it in your wrapper around the <see cref="ContextProvider.SaveChanges"/>
        /// where it can fixup the SaveResult before it is serialized to the client.
        /// </para>
        /// </remarks>
        public SaveMap ConvertAfterSaveMap(
            SaveMap saveMap, List <KeyMapping> keyMappings, EntityInfoCreator entityInfoCreator)
        {
            List <EntityInfo> cGroup, sGroup;

            if (saveMap.TryGetValue(SType, out sGroup))
            {
                saveMap.Remove(sType); // don't return SType entities to client
            }
            else
            {
                return(saveMap); // this SType is not in the saveMap
            }

            if (!saveMap.TryGetValue(cType, out cGroup))
            {
                cGroup = new List <EntityInfo>();
                saveMap.Add(cType, cGroup);
            }

            foreach (var sEntityInfo in sGroup)
            {
                var cEntity = MapEntityToClient(sEntityInfo);
                if (cEntity != null)
                {
                    var mappedEntityInfo = entityInfoCreator(cEntity, sEntityInfo.EntityState);
                    // No other conversions are needed.
                    cGroup.Add(mappedEntityInfo);
                }
            }

            var sName = SType.FullName;
            var cName = CType.FullName;

            keyMappings.ForEach(km => {
                if (km.EntityTypeName == sName)
                {
                    km.EntityTypeName = cName;
                }
            });
            return(saveMap);
        }
Beispiel #27
0
    public void SaveGame(int level)
    {
        SavePlayer savePlayer = new SavePlayer(player);
        SaveMap    saveMap    = MapGen.mapinstance.Save();

        if (!Directory.Exists(Application.persistentDataPath + saveslot))
        {
            Directory.CreateDirectory(Application.persistentDataPath + saveslot);
        }

        // Write playersave
        string json = JsonUtility.ToJson(savePlayer);

        Debug.Log(Application.persistentDataPath + saveslot + playerfilename);
        File.WriteAllText(Application.persistentDataPath + saveslot + playerfilename, json);

        // Write mapsave
        json = JsonUtility.ToJson(saveMap);
        Debug.Log(Application.persistentDataPath + saveslot + level.ToString() + mapfilename);
        File.WriteAllText(Application.persistentDataPath + saveslot + level.ToString() + mapfilename, json);
    }
Beispiel #28
0
        public SaveMap BeforeSaveEntities(SaveMap saveMap)
        {
            var unAuthorizedMaps = saveMap.Where(map => map.Key != _tPerson &&
                                                 map.Key != _tProfileExternal &&
                                                 map.Key != _tProfileFaculty &&
                                                 map.Key != _tProfileStudent &&
                                                 map.Key != _tProfileSecurity &&
                                                 map.Key != _tProfileStaff &&
                                                 map.Key != _tCogResponse &&
                                                 map.Key != _tCogEcpeResult &&
                                                 map.Key != _tCogEsalbResult &&
                                                 map.Key != _tCogEtmpreResult &&
                                                 map.Key != _tCogEcmspeResult &&
                                                 map.Key != _tRoadRunner)
                                   .ToList();

            saveMap.RemoveMaps(unAuthorizedMaps);

            saveMap.AuditMap(loggedInUser.PersonId);
            saveMap.SoftDeleteMap(loggedInUser.PersonId);
            return(saveMap);
        }
Beispiel #29
0
    public static IEnumerable <IntVec2> Fill(IntVec2 s, IntVec2 t, SaveMap saveMap)
    {
        var ret = new HashSet <IntVec2>();

        var cells = new Queue <IntVec2>();

        cells.Enqueue(t);

        while (cells.Count() > 0 && ret.Count() < 15000)
        {
            var cell = cells.Dequeue();
            if (cell.x < 0 || cell.y < 0 || cell.x >= saveMap.Width || cell.y >= saveMap.Height)
            {
                continue;
            }
            if (ret.Contains(cell))
            {
                continue;
            }

            var addFlag       = false;
            var neighborsFlag = false;

            if (addFlag)
            {
                ret.Add(cell);
            }
            if (neighborsFlag)
            {
                cells.Enqueue(cell + IntVec2.North);
                cells.Enqueue(cell + IntVec2.East);
                cells.Enqueue(cell + IntVec2.South);
                cells.Enqueue(cell + IntVec2.West);
            }
        }

        return(ret);
    }
Beispiel #30
0
    // 讀檔.
    public bool Load()
    {
        if (PlayerPrefs.HasKey(GameDefine.szSaveMap) == false)
        {
            return(false);
        }

        SaveMap Temp = Json.ToObject <SaveMap>(PlayerPrefs.GetString(GameDefine.szSaveMap));

        if (Temp == null)
        {
            return(false);
        }

        DataRoad = new List <MapCoor>(Temp.DataRoad);

        foreach (MapObjt Itor in Temp.DataObjt)
        {
            DataObjt.Add(Itor.Pos.ToVector2(), Itor);
        }

        return(true);
    }
 public void AfterSaveEntities(SaveMap saveMap, List<KeyMapping> keyMappings)
 {
   // Nothing to do
 }
 public SaveMap BeforeSaveEntities(SaveMap saveMap) 
 {
   return saveMap; // Nothing to do
 }