Example #1
0
        /// <summary>
        /// フィールド情報を与えられたStringBuilderに追加します。
        /// </summary>
        /// <param name="sb">コンテキストを表すStringBuilder</param>
        /// <param name="field">フィールド</param>
        /// <param name="isBreak">繰り返し完了を判定するメソッド</param>
        private static void AddField(StringBuilder sb, ulong[] context, FieldContextCollection collection, Func<int, bool> isBreak)
        {
            string line = string.Empty;
            for (var i = 0; i < 64; i++)
            {
                // 条件に合致したら終了
                if (isBreak(i)) { break; }

                // フィールド外は除外
                if ((i % 8) < 2) { continue; }

                var movableField = context[(int)collection.MovableField];
                if ((context[(int)collection.ColorFields[SlimeColor.Blue]] & (1ul << i)) > 0ul)
                {
                    line = ((movableField & (1ul << i)) > 0ul) ? SimpleText.MovableSlimeBlue.ToString() + line : SimpleText.SlimeBlue + line;
                }
                else if ((context[(int)collection.ColorFields[SlimeColor.Red]] & (1ul << i)) > 0ul)
                {
                    line = ((movableField & (1ul << i)) > 0ul) ? SimpleText.MovableSlimeRed.ToString() + line : SimpleText.SlimeRed + line;
                }
                else if ((context[(int)collection.ColorFields[SlimeColor.Green]] & (1ul << i)) > 0ul)
                {
                    line = ((movableField & (1ul << i)) > 0ul) ? SimpleText.MovableSlimeGreen.ToString() + line : SimpleText.SlimeGreen + line;
                }
                else if ((context[(int)collection.ColorFields[SlimeColor.Yellow]] & (1ul << i)) > 0ul)
                {
                    line = ((movableField & (1ul << i)) > 0ul) ? SimpleText.MovableSlimeYellow.ToString() + line : SimpleText.SlimeYellow + line;
                }
                else if ((context[(int)collection.ColorFields[SlimeColor.Purple]] & (1ul << i)) > 0ul)
                {
                    line = ((movableField & (1ul << i)) > 0ul) ? SimpleText.MovableSlimePurple.ToString() + line : SimpleText.SlimePurple + line;
                }
                else
                {
                    line = SimpleText.SlimeNone.ToString() + line;
                }

                // 改行
                if ((i % 8) == 7)
                {
                    sb.AppendLine(line);
                    line = string.Empty;
                }
            }
        }
Example #2
0
 /// <summary>
 /// 上部コレクションを作成します。
 /// </summary>
 /// <returns>上部コレクション</returns>
 private static FieldContextCollection CreateUpperCollection()
 {
     var collection = new FieldContextCollection();
     collection.OccupiedField = FieldContext.OccupiedUpper;
     collection.MovableField = FieldContext.MovableUpper;
     collection.ColorFields = GetUpperColorCollection();
     return collection;
 }