예제 #1
0
        private void Awake()
        {
            IsFull = new BoolReactiveProperty();

            Rows      = new List <IEnumerable <GridSlot> >();
            Cols      = new List <IEnumerable <GridSlot> >();
            Diagonals = new List <IEnumerable <GridSlot> >();

            //rows
            Rows = Rows.Append(Slots.Take(3));
            Rows = Rows.Append(Slots.Skip(3).Take(3));
            Rows = Rows.Append(Slots.Skip(6).Take(3));

            //cols
            Cols = Cols.Append(Slots.ByIndexes(0, 3, 6));
            Cols = Cols.Append(Slots.ByIndexes(1, 4, 7));
            Cols = Cols.Append(Slots.ByIndexes(2, 5, 8));

            //diagonals
            Diagonals = Diagonals.Append(Slots.ByIndexes(0, 4, 8));
            Diagonals = Diagonals.Append(Slots.ByIndexes(2, 4, 6));

            //display rows, cols, diagonals for debug purpose
            Debug.LogFormat("Rows: [{0}]", Rows.Aggregate("", (current, row) => current + "(" + string.Join(",", row.Select(s => s.name)) + ")"));
            Debug.LogFormat("Cols: [{0}]", Cols.Aggregate("", (current, col) => current + "(" + string.Join(",", col.Select(s => s.name)) + ")"));
            Debug.LogFormat("Diagonals: [{0}]", Diagonals.Aggregate("", (current, diagonal) => current + "(" + string.Join(",", diagonal.Select(s => s.name)) + ")"));
        }