示例#1
0
        /// <summary>
        /// stampを平行移動したのち、myfieldに押す。
        /// </summary>
        /// <param name="stamp">スタンプのオブジェクト</param>
        /// <param name="parallel_translation_x">x軸方向への平行移動距離</param>
        /// <param name="parallel_translation_y">y軸方向への平行移動距離</param>
        public void PressStamp(Stamp stamp,
                               short parallel_translation_x,
                               short parallel_translation_y)
        {
            foreach (var cell in stamp.GetBlackCellCoordinate())
            {
                short y = (short)(parallel_translation_y + cell.Item1);
                short x = (short)(parallel_translation_x + cell.Item2);

                // スタンプを押す場所が my field の外なら continue
                if (y < 0 || y >= this.y_size || x < 0 || x >= this.x_size)
                {
                    continue;
                }
                this.my_field[y, x] = !my_field[y, x];
            }
        }
示例#2
0
        private void AddOriginalStamp(Stamp origin_stamp, short slide_x, short slide_y)
        {
            // CombinedStampのメンバ変数の更新
            this.origin_stamp_config_list.Add(new Tuple <short, short, short>(origin_stamp.GetOriginStampIndex(), slide_x, slide_y));

            // 親クラス(Stamp)のメンバ変数の更新
            // black_cell_coordinate_listの更新
            List <Tuple <short, short> > add_stamp_black_cell_list = origin_stamp.GetBlackCellCoordinate();

            foreach (var black_cell in add_stamp_black_cell_list)
            {
                short y = (short)(black_cell.Item1 + slide_y);
                short x = (short)(black_cell.Item2 + slide_x);
                Tuple <short, short> reverse_cell = new Tuple <short, short>(y, x);

                if (this.black_cell_coordinates.Contains(reverse_cell))
                {
                    this.black_cell_coordinates.Remove(reverse_cell);
                }
                else
                {
                    this.black_cell_coordinates.Add(reverse_cell);
                }
            }
            // size_y, size_xの更新
            short black_cell_max_y = 0;
            short black_cell_max_x = 0;

            foreach (var cell in this.black_cell_coordinates)
            {
                black_cell_max_y = Math.Max(cell.Item1, black_cell_max_y);
                black_cell_max_x = Math.Max(cell.Item2, black_cell_max_x);
            }
            this.y_size = (short)(black_cell_max_y + 1);
            this.x_size = (short)(black_cell_max_x + 1);
        }