Beispiel #1
0
    public static void SaveData(SaveItemBase dataObj, bool isSaveChild = true)
    {
        var dataType = dataObj.GetType();

        List <SaveItemBase> saveChildItems = new List <SaveItemBase>();

        SaveRoot saveRoot = new SaveRoot();

        saveRoot._SaveKey = dataObj._SaveFileName;
        if (string.IsNullOrEmpty(dataObj._SaveFileName))
        {
            Debug.LogError("SaveKey is Empty:" + dataObj.ToString());
        }
        saveRoot._ChildNode = GetNodesForSave(dataObj, saveChildItems);
        SaveRoot(saveRoot);

        if (isSaveChild)
        {
            while (saveChildItems.Count > 0)
            {
                var childItem = saveChildItems[0];
                saveChildItems.RemoveAt(0);

                SaveRoot saveChild = new SaveRoot();
                saveChild._SaveKey   = childItem._SaveFileName;
                saveChild._ChildNode = GetNodesForSave(childItem, saveChildItems);
                SaveRoot(saveChild);
            }
        }
    }
Beispiel #2
0
        public override Task FinishGetSavedAsync()
        {
            _model !.MainSets !.ClearBoard();
            LoadControls();
            int x = SaveRoot !.SetList.Count; //the first time, actually load manually.

            x.Times(items =>
            {
                DummySet thisSet = new DummySet(_command);
                _model.MainSets.CreateNewSet(thisSet);
            });
            PlayerList !.ForEach(thisPlayer =>
            {
                if (thisPlayer.AdditionalCards.Count > 0)
                {
                    thisPlayer.MainHandList.AddRange(thisPlayer.AdditionalCards); //later sorts anyways.
                    thisPlayer.AdditionalCards.Clear();                           //i think.
                }
            });
            SingleInfo = PlayerList.GetSelf(); //hopefully won't cause problems.
            SortCards();                       //has to be this way this time.
            _model.MainSets.LoadSets(SaveRoot.SetList);
            SaveRoot.LoadMod(_model);
            return(base.FinishGetSavedAsync());
        }
 public override Task FinishGetSavedAsync()
 {
     LoadControls();
     SaveRoot.LoadMod(_model);
     //anything else needed is here.
     return(base.FinishGetSavedAsync());
 }
 private void HookMod()
 {
     SaveRoot.LoadMod(_model);
     if (SaveRoot.DidDraw)
     {
         _model.CardDetails = SaveRoot.CurrentCard !.Details;
     }
 }
Beispiel #5
0
 public override Task FinishGetSavedAsync()
 {
     LoadControls();
     AfterRestoreDice();
     BoardGameSaved();         //i think.
     SaveRoot.LoadMod(_model); //we usually need this.
     _gameBoard.LoadSavedGame();
     //anything else needed is here.
     return(Task.CompletedTask);
 }
Beispiel #6
0
 public ClockSolitaireMainGameClass(ISaveSinglePlayerClass thisState,
                                    IEventAggregator aggregator,
                                    IGamePackageResolver container
                                    )
 {
     _thisState = thisState;
     Aggregator = aggregator;
     SaveRoot   = container.ReplaceObject <ClockSolitaireSaveInfo>(); //can't create new one.  because if doing that, then anything that needs it won't have it.
     SaveRoot.LoadMod(aggregator);
 }
 private void LoadControls()
 {
     if (IsLoaded == true)
     {
         return;
     }
     LoadMod();
     SaveRoot.LoadMod(_model);
     IsLoaded = true; //i think needs to be here.
 }
Beispiel #8
0
 public override Task FinishGetSavedAsync()
 {
     if (SaveRoot !.GameStatus != EnumStatusType.Beginning)
     {
         throw new BasicBlankException("No autoresume.  Therefore, had to be beginning");
     }
     LoadControls();
     SaveRoot.LoadMod(_model);
     //anything else needed is here.
     return(base.FinishGetSavedAsync());
 }
 public override Task FinishGetSavedAsync()
 {
     LoadControls();
     BoardGameSaved(); //i think.
     SaveRoot.LoadMod(_model);
     if (PlayerList.DidChooseColors() && SaveRoot.GameStatus != EnumWhatStatus.NeedChooseGender)
     {
         //if choosing gender, rethink.
         _gameBoard.LoadSavedGame();
         PlayerList !.ForEach(thisPlayer =>
         {
             var thisList = thisPlayer.Hand.ToRegularDeckDict();
             thisPlayer.Hand.Clear();
             thisList.ForEach(tempCard =>
             {
                 if (tempCard.Deck <= 9)
                 {
                     thisPlayer.Hand.Add(CardsModule.GetCareerCard(tempCard.Deck));
                 }
                 else if (tempCard.Deck <= 18)
                 {
                     thisPlayer.Hand.Add(CardsModule.GetHouseCard(tempCard.Deck));
                 }
                 else if (tempCard.Deck <= 27)
                 {
                     thisPlayer.Hand.Add(CardsModule.GetSalaryCard(tempCard.Deck));
                 }
                 else if (tempCard.Deck <= 36)
                 {
                     thisPlayer.Hand.Add(CardsModule.GetStockCard(tempCard.Deck));
                 }
                 else
                 {
                     throw new BasicBlankException("Must be between 1 and 36");
                 }
             });
         });
         if (SaveRoot.ChangePosition > 0)
         {
             _gameContainer.SpinnerPosition = SaveRoot.ChangePosition;
             _gameContainer.SpinnerRepaint();
         }
         if (SaveRoot.GameStatus == EnumWhatStatus.NeedToEndTurn)
         {
             SingleInfo = PlayerList.GetWhoPlayer();
             if (SingleInfo.Position > 0 && SingleInfo.LastMove == EnumFinal.None)
             {
                 _model.GameDetails = _boardProcesses.GetSpaceDetails(SingleInfo.Position);
             }
         }
     }
     //anything else needed is here.
     return(Task.CompletedTask);
 }
 public override Task FinishGetSavedAsync()
 {
     LoadControls();
     AfterRestoreDice();
     _gameBoard.LoadSavedGame();
     BoardGameSaved();         //i think.
     SaveRoot.LoadMod(_model); //we usually need this.
     //can't send turn because view model not created yet at this point.
     _model.Cup !.CanShowDice = SaveRoot.DiceNumber > 0;
     //anything else needed is here.
     return(Task.CompletedTask);
 }
Beispiel #11
0
 public override Task FinishGetSavedAsync()
 {
     LoadControls();
     AfterRestoreDice();
     BoardGameSaved(); //i think.
     _model.Cup !.ShowDiceListAlways = true;
     _model.Cup.Visible     = true;
     _model.Cup.CanShowDice = true;
     SaveRoot.LoadMod(_model); //we usually need this.
     //anything else needed is here.
     return(Task.CompletedTask);
 }
Beispiel #12
0
    public static void SaveRoot(SaveRoot root)
    {
        string saveStr = "";

        foreach (var child in root._ChildNode)
        {
            saveStr += DataPackSave.SaveSplitChars[0] + child.ToSaveString(1);
        }
        saveStr = saveStr.Substring(1);
        //Debug.Log("Save:" + root._SaveKey + "," + saveStr);
        LocalSave.Save(root._SaveKey, saveStr);
    }
 public override async Task SetUpGameAsync(bool isBeginning)
 {
     LoadControls();
     if (FinishUpAsync == null)
     {
         throw new BasicBlankException("The loader never set the finish up code.  Rethink");
     }
     SaveRoot !.ImmediatelyStartTurn = true; //most of the time, needs to immediately start turn.  if i am wrong, rethink.
     SaveRoot.LoadMod(_model);
     //hopefully the erasing of colors is already handled.
     await FinishUpAsync(isBeginning);
 }
 //maybe no need anymore for the populatesaveroot because i am using same address.
 private void LoadGame()
 {
     LoadMod();
     PlayerList.ForEach(player =>
     {
         if (player.RowList.Count == 0)
         {
             _scoreContainer.RowList = player.RowList.ToCustomBasicList(); //try this way.  hopefully will allow cloning back later.
             _scoreLogic.LoadBoard();
             player.RowList = _scoreContainer.RowList.ToCustomBasicList();
         }
     });
     SaveRoot.LoadMod(_model);
 }
Beispiel #15
0
        public override async Task OpenSavedGameAsync()
        {
            DeckList.OrderedObjects(); //i think
            SaveRoot = await _thisState.RetrieveSinglePlayerGameAsync <ClockSolitaireSaveInfo>();

            if (SaveRoot.DeckList.Count > 0)
            {
                var newList = SaveRoot.DeckList.GetNewObjectListFromDeckList(DeckList);
                DeckPile !.OriginalList(newList);
                //not sure if we need this or not (?)
                //DeckPile.Visible = true;
            }
            _clock1 !.LoadSavedClocks(SaveRoot.SavedClocks);
            SaveRoot.LoadMod(Aggregator);
        }
        protected override Task LastPartOfSetUpBeforeBindingsAsync() //try here instead.
        {
            var tempCard = _model !.Pile1 !.GetCardInfo();

            SaveRoot !.CurrentNumber = tempCard.Value;
            if (tempCard.DisplaySuit == EnumSuitList.None)
            {
                SaveRoot.CurrentSuit = tempCard.Suit;
            }
            else
            {
                SaveRoot.CurrentSuit = tempCard.DisplaySuit;
            }
            SaveRoot.CurrentCard = tempCard.Deck; //i think
            SaveRoot.LoadMod(_model);
            return(Task.CompletedTask);
        }
Beispiel #17
0
 protected override Task StartSetUpAsync(bool isBeginning)
 {
     LoadControls();
     _model.Beginnings1.ObjectList.Clear(); //try this way.
     _model.GolfHand1.ObjectList.Clear();   //try this too.
     PlayerList !.ForEach(thisPlayer =>
     {
         thisPlayer.FinishedChoosing = false;
         thisPlayer.Knocked          = false;
         thisPlayer.FirstChanged     = false;
         thisPlayer.SecondChanged    = false;
     });
     SaveRoot !.Round++;                             //i think.
     SaveRoot.GameStatus = EnumStatusType.Beginning; //i think.
     SaveRoot.LoadMod(_model);                       //just in case
     return(base.StartSetUpAsync(isBeginning));
 }
 public override Task FinishGetSavedAsync()
 {
     LoadControls();
     AfterRestoreDice();
     BoardGameSaved(); //i think.
     if (SaveRoot.GameStatus == EnumGameStatusList.RollDice)
     {
         _model.Cup !.CanShowDice = false;
     }
     else
     {
         _model.Cup !.CanShowDice = true;
     }
     SaveRoot.LoadMod(_model); //we usually need this.
     //anything else needed is here.
     return(Task.CompletedTask);
 }
        public override async Task OpenSavedGameAsync()
        {
            DeckList.OrderedObjects(); //i think
            SaveRoot = await _thisState.RetrieveSinglePlayerGameAsync <HeapSolitaireSaveInfo>();

            if (SaveRoot.DeckList.Count > 0)
            {
                var newList = SaveRoot.DeckList.GetNewObjectListFromDeckList(DeckList);
                DeckPile !.OriginalList(newList);
                //not sure if we need this or not (?)
                //DeckPile.Visible = true;
            }
            //anything else that is needed to open the saved game will be here.
            _model !.Main1.PileList !.ReplaceRange(SaveRoot.MainPiles !); //iffy.
            _model.Main1.RefreshInfo();
            SaveRoot.Load(Aggregator);
            _model.Waste1 !.PileList !.ReplaceRange(SaveRoot.WasteData !); //also iffy.
        }
 public ChineseCheckersMainGameClass(IGamePackageResolver resolver,
                                     IEventAggregator aggregator,
                                     BasicData basic,
                                     TestOptions test,
                                     ChineseCheckersVMData model,
                                     IMultiplayerSaveState state,
                                     IAsyncDelayer delay,
                                     CommandContainer command,
                                     ChineseCheckersGameContainer container,
                                     GameBoardProcesses gameBoard
                                     ) : base(resolver, aggregator, basic, test, model, state, delay, command, container)
 {
     _gameContainer               = container;
     _gameBoard                   = gameBoard;
     _gameContainer.Model         = model;
     _gameContainer.CanMove       = (() => !command.IsExecuting);
     _gameContainer.MakeMoveAsync = PrivateMoveAsync;
     SaveRoot.Init(_gameContainer);
 }
Beispiel #21
0
 protected void LoadMod()
 {
     SaveRoot.LoadMod(_model); //hopefully this simple (?)
 }