Example #1
0
    private SaveInfo RetrieveData()
    {
        var turns  = Results.GetResults();
        var scores = Scores.GetScores().ToArray();

        var counter = 0;

        var si = new SaveInfo {
            TurnInfos = new SaveInfo.TurnInfo[turns.Count], SelectedIndex = -1
        };

        for (var i = 0; i < turns.Count; i++)
        {
            var result = turns[i];

            if (result == Results.Selected)
            {
                si.SelectedIndex = i;
            }

            si.TurnInfos[i].FirstRow        = result.FirstRow().Select(die => die.Number).ToArray();
            si.TurnInfos[i].NumberOfReRolls = result.FirstRow().Select(die => die.AmountOfReRolls()).ToArray();
            si.TurnInfos[i].Seeds           = result.Seeds();

            si.TurnInfos[i].IndexOfConnectedTo = -1;

            if (Results.HasConnection(result))
            {
                var targetScore = Results.GetConnectedTo(result);

                for (var scoreIndex = 0; scoreIndex < scores.Length; scoreIndex++)
                {
                    if (scores[scoreIndex] == targetScore)
                    {
                        si.TurnInfos[i].IndexOfConnectedTo = scoreIndex;
                        break;
                    }
                }

                counter++;
            }
        }

        Debug.Log(counter);

        return(si);
    }