Пример #1
0
        internal void Load(SaveGameData mapdata)
        {
            Clear();
            if (mapdata == null)
            {
                return;
            }
            MapNoteEventArgs mapNoteEventArgs = new MapNoteEventArgs(null, null);
            Int32            num = mapdata.Get <Int32>("MapCount", 0);

            for (Int32 i = 0; i < num; i++)
            {
                String       text         = mapdata.Get <String>("Map" + i, null);
                SaveGameData saveGameData = mapdata.Get <SaveGameData>("Notes" + i, null);
                if (text != null && saveGameData != null)
                {
                    MapNoteCollection mapNoteCollection = new MapNoteCollection();
                    m_MapNotes.Add(text, mapNoteCollection);
                    Int32 num2 = saveGameData.Get <Int32>("Count", 0);
                    for (Int32 j = 0; j < num2; j++)
                    {
                        Int32  num3  = saveGameData.Get <Int32>("Nx" + j, -1);
                        Int32  num4  = saveGameData.Get <Int32>("Ny" + j, -1);
                        String text2 = saveGameData.Get <String>("Nt" + j, null);
                        if (num3 != -1 && num4 != -1 && !String.IsNullOrEmpty(text2))
                        {
                            MapNote mapNote = new MapNote(text, new Position(num3, num4), text2);
                            mapNoteCollection.Add(new Position(num3, num4), mapNote);
                            if (AddedMapNote != null)
                            {
                                mapNoteEventArgs.MapID   = text;
                                mapNoteEventArgs.MapNote = mapNote;
                                AddedMapNote(this, mapNoteEventArgs);
                            }
                        }
                    }
                }
            }
        }
Пример #2
0
        private void RemoveAllNotes(String mapId, MapNoteCollection collection)
        {
            MapNoteEventArgs mapNoteEventArgs = new MapNoteEventArgs(null, null);

            while (collection.Count > 0)
            {
                Dictionary <Position, MapNote> .Enumerator enumerator = collection.GetEnumerator();
                if (enumerator.MoveNext())
                {
                    KeyValuePair <Position, MapNote> keyValuePair = enumerator.Current;
                    collection.Remove(keyValuePair.Key);
                    if (RemovedMapNote != null)
                    {
                        mapNoteEventArgs.MapID = mapId;
                        MapNoteEventArgs mapNoteEventArgs2             = mapNoteEventArgs;
                        KeyValuePair <Position, MapNote> keyValuePair2 = enumerator.Current;
                        mapNoteEventArgs2.MapNote = keyValuePair2.Value;
                        RemovedMapNote(this, mapNoteEventArgs);
                    }
                }
            }
            collection.Clear();
        }