Exemplo n.º 1
0
        /// <summary>
        /// NEXTスライムの変換を行います。
        /// </summary>
        /// <param name="value">フィールドを示す文字列</param>
        /// <returns>NEXTスライムの情報</returns>
        private static Slime[][][] ParseNextSlimes(string value)
        {
            var nextSlimes = new Slime[Player.Length][][];
            Action <Player.Index> initialize = (player) =>
            {
                nextSlimes[(int)player] = new Slime[NextSlime.Length][];
                nextSlimes[(int)player][(int)NextSlime.Index.First]  = new Slime[MovableSlime.Length];
                nextSlimes[(int)player][(int)NextSlime.Index.Second] = new Slime[MovableSlime.Length];
            };

            initialize(Player.Index.First);
            initialize(Player.Index.Second);

            var values = SplitNewLine(value);

            for (var i = 0; i < values.Length; i++)
            {
                if (!SimpleText.ContainsNextSlimeInfo(i))
                {
                    // NEXTスライム情報が存在しない行なのでスキップ
                    continue;
                }

                var nextSlimeLine = values[i].Split(SimpleText.Separator.Player)[(int)FieldIndex.NextSlime].ToCharArray();
                Debug.Assert(nextSlimeLine.Length == NextSlime.Length, "NEXTスライムの数が不正です。数:" + nextSlimeLine.Length);
                var nextSlimeIndex        = SimpleText.ConvertNextSlimeIndex(i);
                var movableSlimeUnitIndex = SimpleText.ConvertMovableSlimeUnitIndex(i);
                nextSlimes[(int)Player.Index.First][(int)nextSlimeIndex][(int)movableSlimeUnitIndex]  = SimpleText.ConvertSlime(nextSlimeLine[(int)Player.Index.First]);
                nextSlimes[(int)Player.Index.Second][(int)nextSlimeIndex][(int)movableSlimeUnitIndex] = SimpleText.ConvertSlime(nextSlimeLine[(int)Player.Index.Second]);
            }

            return(nextSlimes);
        }