예제 #1
0
        public void AddSaveModifier(string saveShortName, int modifier)
        {
            if (Saves.Count == 0)
            {
                Saves.Add(saveShortName, modifier);
            }
            else
            {
                foreach (var save in Saves)
                {
                    if (save.Key == saveShortName)
                    {
                        if (modifier == 0)
                        {
                            Saves.Remove(saveShortName);
                            return;
                        }
                        else
                        {
                            Saves[saveShortName] = modifier;
                            return;
                        }
                    }
                }

                Saves.Add(saveShortName, modifier);
            }
        }
예제 #2
0
        public void Update(SectionView view)
        {
            if (Saves.Keys.Contains(view.SectionId))
            {
                Saves.Remove(view.SectionId);
            }

            Saves.Add(view.SectionId, new SectionSave(view, _cx));
        }
        public LoadGameScreenViewModel(IMessenger messenger)
        {
            MessengerInstance = messenger;

            DeleteSaveInViewMessage.Register(MessengerInstance, this, item => { Saves.Remove(item); });

            // disconnect the messenger of this one from the messenger of the game screen
            BoardViewModel = new BoardViewModel(new Messenger(), MockUtil.AnyGame(7, 0).State)
            {
                UnlockedPlayer = null
            };

            BackToMainMenuCommand = new RelayCommand(() => ShowMainMenuMessage.Send(MessengerInstance));
        }
예제 #4
0
        /// <summary>
        /// </summary>
        /// <param name="i"></param>
        /// <returns></returns>
        public GameState this[int i]
        {
            get { return(GameStates[i]); }            //ToDo: Sort by date
            set
            {
                //There is no "Add new slot" it only overrides what's already present
                //GameState[] s = new GameState[Saves.Count];
                //Saves.CopyTo(s);
                //s[i] = value;
                //Saves = new HashSet<GameState>(s);

                //Rewrote to override old save file with new one
                if (Saves.Contains(value))
                {
                    Saves.Remove(value);
                }
                if (value.TimeCreated.Ticks != new DateTime().Ticks || (value.TrainerID != 0 && value.SecretID != 0))
                {
                    Saves.Add(value);
                }
            }
        }
예제 #5
0
        public SaveManager(IMessenger messenger)
        {
            MessengerInstance = messenger;

            Messages.SaveGameMessage.Register(MessengerInstance, this, tuple => {
                var(id, memento) = tuple;
                RegisterForSave(id, memento);
            });

            Messages.DeleteSaveInManagerMessage.Register(MessengerInstance, this, id => Saves.Remove(id));
        }