Beispiel #1
0
        private Dictionary <int, int> getCombos(CellColor color)
        {
            var combos = new Dictionary <int, int>();

            combos.Add(1, 0);
            combos.Add(2, 0);
            combos.Add(3, 0);
            combos.Add(4, 0);
            for (int i = 0; i < this.columns.Count; i++)
            {
                for (int j = 0; j < this.columns[i].cells.Count; j++)
                {
                    if (this.columns[i].cells[j].color == color ||
                        this.columns[i].cells[j].color == CellColor.empty)
                    {
                        var newCombos = getCombosForCell(i, j, color);
                        combos[1] += newCombos[1];
                        combos[2] += newCombos[2];
                        combos[3] += newCombos[3];
                        combos[4] += newCombos[4];
                    }
                    if (this.columns[i].cells[j].color == CellColor.empty)
                    {
                        //if we have reached the end then we stop
                        break;
                    }
                }
            }
            return(combos);
        }
Beispiel #2
0
        public static int GetCellValue(CellColor cell, CellColor enemy)
        {
            switch (enemy)
            {
            case CellColor.Blue:
                return(cell == CellColor.Green ? 20 : cell == CellColor.Red ? 5 : 10);

            case CellColor.Green:
                return(cell == CellColor.Red ? 20 : cell == CellColor.Blue ? 5 : 10);

            case CellColor.Red:
                return(cell == CellColor.Blue ? 20 : cell == CellColor.Green ? 5 : 10);

            case CellColor.Light:
                return(cell == CellColor.Dark ? 20 : cell == CellColor.Light ? 5 : 10);

            case CellColor.Dark:
                return(cell == CellColor.Dark ? 20 : cell == CellColor.Dark ? 5 : 10);

            case CellColor.None:
                return(3);
            }

            return(0);
        }
        void Attack(CellColor color)
        {
            foreach (GameObject anotherCell in currentOutLines)
            {
                if (CellManager.amountOfSeeds >= CellManager.maxAmountOfSeeds)
                {
                    return;
                }

                Vector3 target = anotherCell.transform.position;
                target.z = 0f;

                target.x = target.x - transform.position.x;
                target.y = target.y - transform.position.y;

                float      angle    = Mathf.Atan2(target.y, target.x) * Mathf.Rad2Deg;
                Quaternion rotation = Quaternion.Euler(new Vector3(0, 0, angle));

                Instantiate(GetSeed(anotherCell, this.sprite.color), transform.position, rotation);

                CellManager.amountOfSeeds++;
            }

            sendTimer = 0f;
        }
Beispiel #4
0
        public void DrawCellText(Cell cell, Rectangle location, string text, CellColor color)
        {
            mContext.SelectFont("Helvetica Neue", 16.0f, CGTextEncoding.MacRoman);

            // Get the reverse color of the background
            float sumOfComponents = 0;
            float r, g, b, a;

            color.UIColor.GetRGBA(out r, out g, out b, out a);
            sumOfComponents = r + g + b;

            UIColor textColor = UIColor.Black;

            if (sumOfComponents < 0.25f)
            {
                textColor = UIColor.White;
            }
            else
            {
                textColor = UIColor.Black;
            }

            mContext.SetFillColor(textColor.CGColor);

            // Careful with the coordinates!!!
            // Remember it's a real mess because it's inverted
            mContext.ShowTextAtPoint(location.X + mParent.CellSize / 3, location.Y + 2 * mParent.CellSize / 3, text);
        }
        void GetColor(CellColor color)
        {
            Color32 customBlue   = new Color(25 / 255f, 75 / 255f, 155 / 255f);
            Color32 customOrange = new Color(190 / 255f, 120 / 255f, 55 / 255f);
            Color32 customRed    = new Color(155 / 255f, 25f / 255f, 25 / 255f);
            Color32 customGrey   = new Color(115 / 255f, 115 / 255f, 115 / 255f);
            Color32 customGreen  = new Color(55 / 255f, 175 / 255f, 60 / 255f);

            switch (color)
            {
            case CellColor.Blue:
                sprite.color = customBlue;
                break;

            case CellColor.Orange:
                sprite.color = customOrange;
                break;

            case CellColor.Player:
                sprite.color = customGreen;
                break;

            case CellColor.Red:
                sprite.color = customRed;
                break;

            case CellColor.Neutral:
                sprite.color = customGrey;
                break;
            }
        }
Beispiel #6
0
        private DataCell[,] CreateDataGrid(ReportTableModel reportTable)
        {
            if (reportTable.TableData == null || reportTable.TableData.Count == 0)
            {
                return(null);
            }

            DataCell[,] result = new DataCell[reportTable.TableData.Count + 1, reportTable.Header.Count];
            for (int i = 0; i < reportTable.Header.Count; i++)
            {
                result[0, i] = new DataCell(reportTable.Header[i]);
            }
            for (int i = 0; i < reportTable.TableData.Count; i++)
            {
                ReportTableRow row = reportTable.TableData[i];
                for (int j = 0; j < row.Count; j++)
                {
                    string value = row[j].Value;
                    if (value == null)
                    {
                        value = string.Empty;
                    }
                    CellColor cellColor = row[j].Color;
                    result[i + 1, j] = new DataCell(value,
                                                    Color.FromArgb(255, cellColor.Red, cellColor.Green, cellColor.Blue));
                }
            }
            return(result);
        }
Beispiel #7
0
        public static CellColor GetEnemyColor(Bitmap bmp, int size)
        {
            var dic = _enemyCirclesSmall;

            switch (size)
            {
            case 2: dic = _enemyCirclesMed;
                break;

            case 3: dic = _enemyCirclesLarge;
                break;
            }

            double    max       = 0;
            CellColor color     = CellColor.None;
            var       testImage = new Image <Bgr, byte>(bmp);

            foreach (var testColor in dic)
            {
                GetTemplatePosition(testImage, testColor.Value, 0.5, out var diff);
                if (max < diff)
                {
                    color = testColor.Key;
                    max   = diff;
                }
            }

            return(color);
        }
Beispiel #8
0
        public void Refresh(CellColor[,] cellColors)
        {
            StringBuilder tempBuffer = new StringBuilder();

            for (int y = 0 ; y < cellColors.GetLength(1) ; ++y) {
                for (int x = 0 ; x < cellColors.GetLength(0) ; ++x)  {
                    CellColor color = cellColors[x, y];
                    if (color == CellColor.Empty) {
                        tempBuffer.Append("□");
                    }
                    else if (color == CellColor.White) {
                        tempBuffer.Append("■");
                    }
                }
                tempBuffer.Append("\n");
            }

            if (buffer == null) {
                buffer = tempBuffer;
            }
            else {
                if (buffer.ToString() == tempBuffer.ToString()) {
                    return;
                }
                buffer = tempBuffer;
            }

            Console.Clear();
            Console.WriteLine(buffer);
        }
Beispiel #9
0
 public ChessboardItem(BoardSquare boardSquare, Player?player, Piece?piece, CellColor color)
 {
     this.boardSquare = boardSquare;
     this.player      = player;
     this.piece       = piece;
     this.color       = color;
 }
Beispiel #10
0
 public OptimizedCell(int _x, int _y, CellColor _color, bool _isPoint)
 {
     x       = _x;
     y       = _y;
     color   = _color;
     isPoint = _isPoint;
 }
 /// <summary>
 /// Column constructor.
 /// </summary>
 /// <param name="title">Title text.</param>
 /// <param name="width">Width.</param>
 public ExcelColumn(string title, int width, CellColor style, string group)
 {
     Title = title;
     Width = width;
     Style = style;
     Group = group;
 }
Beispiel #12
0
    public void init(CellType _cellType,BombType _cellBombType,CellColor _cellColor)
    {
        string spritePath = _cellType.ToString() +_cellBombType.ToString()+ _cellColor.ToString();

        Sprite newSprite = Resources.Load("Sprite/Cells/"+spritePath,typeof(Sprite)) as Sprite;
        GetComponent<SpriteRenderer>().sprite = newSprite;
    }
        //---------------------------------------------------------------------------------------------
        // 各セルの Saturation および Brightness 値をリストに格納する
        // このメソッドは、userControl_Loaded イベント内で 1 回だけ呼ばれる
        private void SetSVList(int hue)
        {
            int          n = 0;
            const double N = 0.0625;

            SVList = new List <CellColor>(289);            // = 17 x 17

            for (double v = 1.0; v >= 0.0; v -= N)
            {
                for (double s = 0.0; s <= 1.0; s += N)
                {
                    var sv = new CellColor();
                    sv.H     = hue;
                    sv.S1    = s;
                    sv.S2    = s + N;
                    sv.V1    = v;
                    sv.V2    = v - N;
                    sv.Color = ColorUtility.HsvToColor(hue, s, v);

                    ++n;

                    SVList.Add(sv);
                }
            }
        }
Beispiel #14
0
        private void loadContent(string image)
        {
            // Create an empty texture
            BlankTexture = new Texture2D(SharedGraphicsDeviceManager.Current.GraphicsDevice, 1, 1, false, SurfaceFormat.Color);
            Color[] color = new Color[1] {
                Color.White
            };
            BlankTexture.SetData(color);

            // Load font
            Font = contentManager.Load <SpriteFont>("font");

            // Read image
            Texture2D puzzleImage = contentManager.Load <Texture2D>(image);

            // Width and height
            int imageWidth  = puzzleImage.Width;
            int imageHeight = puzzleImage.Height;

            // Colors pixel by pixel
            Color[] colors1D = new Color[puzzleImage.Width * puzzleImage.Height];
            puzzleImage.GetData(colors1D);
            Color[,] colors2D = new Color[puzzleImage.Width, puzzleImage.Height];
            for (int x = 0; x < puzzleImage.Width; x++)
            {
                for (int y = 0; y < puzzleImage.Height; y++)
                {
                    colors2D[x, y] = colors1D[x + y * puzzleImage.Width];
                }
            }

            grid = new PathGridXna(this, imageWidth, imageHeight);
            grid.GridCompleted += grid_GridCompleted;
            grid.CreateGrid(0, 0, grid);
            grid.LoadContent(contentManager);

            CellColor[][] colors = new CellColor[imageWidth][];

            for (int x = 0; x < imageWidth; x++)
            {
                colors[x] = new CellColor[imageHeight];

                for (int y = 0; y < imageHeight; y++)
                {
                    CellColor c;
                    c = new CellColor()
                    {
                        A = colors2D[x, y].A / 255f,
                        R = colors2D[x, y].R / 255f,
                        G = colors2D[x, y].G / 255f,
                        B = colors2D[x, y].B / 255f
                    };

                    colors[x][y] = c;
                }
            }

            grid.SetupGrid(colors);
        }
Beispiel #15
0
 public Cell(Cell other)
 {
     this.color = other.color;
     this.locked = other.locked;
     this.loose = other.loose;
     this.matched = other.matched;
     this.visited = other.visited;
 }
Beispiel #16
0
 public Cell()
 {
     this.color = CellColor.BLACK;
     this.locked = false;
     this.loose = false;
     this.matched = false;
     this.visited = false;
 }
Beispiel #17
0
 public DataCell(int row_index, int col_index, int max_index, CellColor color, DataMatrix matrix, CellExtraData ex_data)
 {
     Position    = new Grid(row_index, col_index, max_index);
     Color       = color;
     root_matrix = matrix;
     ExData      = ex_data;
     Marks       = new Dictionary <string, string>();
 }
Beispiel #18
0
        public int getScore(CellColor color)
        {
            int score  = 0;
            var combos = this.getCombos(color);

            score = combos[1] + combos[2] * 5 + combos[3] * 20 + combos[4] * 10000;
            return(score);
        }
Beispiel #19
0
 public bool addDisk(CellColor color)
 {
     if (this.isFull)
     {
         return(false);             //failed
     }
     this._cells.First(x => x.color == CellColor.empty).color = color;
     return(true);
 }
Beispiel #20
0
 public void Clear()
 {
     color = CellColor.BLACK;
     direction = Direction.NONE;
     visited = false;
     loose = false;
     matched = false;
     locked = false;
 }
Beispiel #21
0
        bool IsEnemyColoredCell(int x, int y, CellColor enemyColor)
        {
            if (!IsValidPoint(x, y))
            {
                return(false);
            }

            return(grid.GetCell(x, y) == enemyColor);
        }
Beispiel #22
0
        public void DrawPath(Cell cell, Rectangle pathRect, Point direction, CellColor color)
        {
            mContext.DrawImage(pathRect, UIImageEx.GetImageWithOverlayColor(mPathImage, color.UIColor).CGImage);

            // The old drawing code for perfect paths
//			context.SetFillColor (color.UIColor.CGColor);

            // Draw in 2 parts:
            // First a rect
//			context.FillRect (pathRect);
//
//			// Then an arc to the end
//			if (direction.X < 0) {
//				context.MoveTo (pathRect.Right, pathRect.Top);
//				context.AddCurveToPoint (
//					pathRect.Right + pathRect.Width / 3,
//					pathRect.Top + pathRect.Height / 3,
//					pathRect.Right + pathRect.Width / 3,
//					pathRect.Top + 2 * pathRect.Height / 3,
//					pathRect.Right,
//					pathRect.Bottom
//					);
//			} else if (direction.X > 0) {
//				context.MoveTo (pathRect.Left, pathRect.Top);
//				context.AddCurveToPoint (
//					pathRect.Left - pathRect.Width / 3,
//					pathRect.Top + pathRect.Height / 3,
//					pathRect.Left - pathRect.Width / 3,
//					pathRect.Top + 2 * pathRect.Height / 3,
//					pathRect.Left,
//					pathRect.Bottom
//					);
//			}
//			if (direction.Y < 0) {
//				context.MoveTo (pathRect.Left, pathRect.Bottom);
//				context.AddCurveToPoint (
//					pathRect.Left + pathRect.Width / 3,
//					pathRect.Bottom + pathRect.Height / 3,
//					pathRect.Left + 2 * pathRect.Width / 3,
//					pathRect.Bottom + pathRect.Height / 3,
//					pathRect.Right,
//					pathRect.Bottom
//					);
//			} else if (direction.Y > 0) {
//				context.MoveTo (pathRect.Left, pathRect.Top);
//				context.AddCurveToPoint (
//					pathRect.Left + pathRect.Width / 3,
//					pathRect.Top - pathRect.Height / 3,
//					pathRect.Left + 2 * pathRect.Width / 3,
//					pathRect.Top - pathRect.Height / 3,
//					pathRect.Right,
//					pathRect.Top
//					);
//			}
//
//			context.FillPath ();
        }
Beispiel #23
0
    private void LogState(CellColor color1, CellColor color2, CellColor resultColor)
    {
        if (color1 == color2)
        {
            Debug.Log("[Game of Life Cruel #" + moduleId + "] Steady " + color1 + " = " + resultColor);
        }

        Debug.Log("[Game of Life Cruel #" + moduleId + "] Flashing " + color1 + " and " + color2 + " = " + resultColor);
    }
Beispiel #24
0
    private bool IsColor(int i, CellColor color1, CellColor?color2 = null)
    {
        if (color2 == null)
        {
            return(BtnColor1[i] == color1 && BtnColor2[i] == color1);
        }

        return(BtnColor1[i] == color1 && BtnColor2[i] == color2 || BtnColor1[i] == color2 && BtnColor2[i] == color1);
    }
Beispiel #25
0
 public void Initialize(Vector3Int boardSize, int goalNum)
 {
     Assert.IsTrue(IsBoardSizeValid(boardSize, goalNum));
     boardCells       = new CellColor[boardSize.x, boardSize.y, boardSize.z];
     cellsHeight      = new int[boardSize.x, boardSize.z];
     turnCellColor    = CellColor.Blue;
     winningCellColor = CellColor.None;
     this.boardSize   = boardSize;
     this.goalNum     = goalNum;
 }
Beispiel #26
0
    public Move(CellColor _color, bool _isPoint, int _fromX, int _fromY, int _toX, int _toY)
    {
        color   = _color;
        isPoint = _isPoint;
        fromX   = _fromX;
        fromY   = _fromY;

        toX = _toX;
        toY = _toY;
    }
Beispiel #27
0
 public static ConsoleColor ChangeCellColorIntoConsoleColor(CellColor color)
 {
     if (color == CellColor.White)
     {
         return(ConsoleColor.White);
     }
     else
     {
         return(ConsoleColor.Red);
     }
 }
Beispiel #28
0
 private void InitTopMatrix(int row, int col)
 {
     TopMatrix = new CellColor[row, col];
     for (int i = 0; i < row; i++)
     {
         for (int j = 0; j < col; j++)
         {
             TopMatrix[i, j] = CellColor.WHITE;
         }
     }
 }
Beispiel #29
0
 public static Color CellColor2Color(CellColor color)
 {
     try
     {
         return colorDictionary[color];
     }
     catch
     {
         return Color.Transparent;
     }
 }
Beispiel #30
0
 private void Add(CellColor color, double weight)
 {
     Node node = new Node();
     if (sums.Count == 0) {
         node.sum = weight;
     } else {
         node.sum = sums[sums.Count - 1].sum + weight;
     }
     node.color = color;
     sums.Add(node);
 }
Beispiel #31
0
 public void AddBall(CellColor color, bool isPoint)
 {
     if (color == CellColor.Black)
     {
         blackBallsLeft.Add(new OptiBall(isPoint, color));
     }
     else
     {
         whiteBallsLeft.Add(new OptiBall(isPoint, color));
     }
 }
Beispiel #32
0
        public CellHandler(int cellIdx, CellColor cellType, CellState cellState, ISelectionController selectionController)
        {
            CellIdx   = cellIdx;
            CellColor = cellType;
            CellState = cellState;
            IsEnabled = cellType == CellColor.Black;

            IsSelected = false;

            _selectionController = selectionController;
        }
Beispiel #33
0
 /// <summary>
 /// Set number and color of spin result.
 /// </summary>
 /// <param name="number"></param>
 public RouletteSpinEventArgs(int number)
 {
     Number = number;
     if (number == 0)
     {
         Color = CellColor.Green;
     }
     else
     {
         Color = RedColorNumbers.Contains(number) ? CellColor.Red : CellColor.Black;
     }
 }
Beispiel #34
0
 public void RotateLeft()
 {
     CellColor[,] temp = new CellColor[width, height];
     for (int x = 0; x < width; ++x)
     {
         for (int y = 0; y < height; ++y)
         {
             temp[x, y] = colors[height - y - 1, x];
         }
     }
     colors = temp;
 }
Beispiel #35
0
 private CellColor[,] CreateEmptyCellColors()
 {
     CellColor[,] colors = new CellColor[WiDTH, HEIGHT];
     for (int x = 0; x < WiDTH; ++x)
     {
         for (int y = 0; y < HEIGHT; ++y)
         {
             colors[x, y] = CellColor.Empty;
         }
     }
     return(colors);
 }
Beispiel #36
0
        public Block(int blockCellCnt, int colorCnt)
        {
            if (blockCellCnt < 1 || ROW_SIZE * COL_SIZE < blockCellCnt)
            {
                throw new Exception("Can't MakeRandomBlock");
            }

            cells = new Cell[ROW_SIZE, COL_SIZE];

            int cnt = COL_SIZE * ROW_SIZE - 1;
            int remain = blockCellCnt - 1;

            int numberOfColors = 2;
            CellColor[] blockColorCand = new CellColor[numberOfColors];

            for (int i = 0; i < numberOfColors; i++)
            {
                bool dupFlg;
                do
                {
                    dupFlg = false;
                    blockColorCand[i] = (CellColor)Core.Random.rand(1, colorCnt + 1);
                    for (int j = 0; j < i; j++)
                    {
                        if (blockColorCand[i] == blockColorCand[j])
                        {
                            dupFlg = true;
                        }
                    }
                } while (dupFlg);
            }
            for (int i = 0; i < ROW_SIZE; i++)
            {
                for (int j = 0; j < COL_SIZE; j++)
                {
                    if (i == ROW_SIZE / 2 && j == COL_SIZE / 2)
                    {
                        cells[i, j] = new BlockCell(blockColorCand[Core.Random.rand(0, numberOfColors)]);
                        continue;
                    }
                    if (Core.Random.rand(cnt) < remain)
                    {
                        cells[i, j] = new BlockCell(blockColorCand[Core.Random.rand(0, numberOfColors)]);
                        remain--;
                    }
                    else
                    {
                        cells[i, j] = new BlankCell();
                    }
                    cnt--;
                }
            }
        }
Beispiel #37
0
    public WinningPattern(WinningPattern toCopy)
    {
        cells = new Vector2[5];

        for (int i = 0; i < cells.Length; ++i)
        {
            cells[i] = toCopy.cells[i];
        }

        type  = toCopy.type;
        color = toCopy.color;
    }
Beispiel #38
0
        public CellColor CombatCheck(CellColor attacker, CellColor defender)
        {
            switch (determineWinner(attacker, defender))
            {
            case true: Console.WriteLine("Player1 won the fight!");
                return(attacker);

            default:
                Console.WriteLine("Player2 won the fight!");
                return(defender);
            }
        }
Beispiel #39
0
 public Token GetRandomToken(Board board, CellColor color1, CellColor color2, Random random)
 {
     if (sums.Count == 0) {
         throw new Exception("Tried to get a random token from the empty set.");
     }
     double number = random.NextDouble() * sums[sums.Count - 1].sum;
     for (int i = 0; i < sums.Count - 1; ++i) {
         if (number < sums[i].sum) {
             return sums[i].factory(board, color1, color2);
         }
     }
     return sums[sums.Count - 1].factory(board, color1, color2);
 }
Beispiel #40
0
 public TwoPieceToken(Board board, int row, int column, CellColor color1, CellColor color2)
 {
     piece = new TokenPiece[2];
     Cell cell1 = new Cell();
     Cell cell2 = new Cell();
     cell1.color = color1;
     cell2.color = color2;
     cell1.direction = Cell.Direction.RIGHT;
     cell2.direction = Cell.Direction.LEFT;
     piece[0] = new TokenPiece(board, row, column, cell1);
     piece[1] = new TokenPiece(board, row, column + 1, cell2);
     orientation = 0;
 }
Beispiel #41
0
 private void ConnectVertically(double row, double col, CellColor a, CellColor b, Color color)
 {
     if (a == b)
     {
         GL.Disable(EnableCap.Texture2D);
         GL.Color4(color);
         GL.Vertex2(20 * (col) + 1, 20 * (row + 1) - 1);
         GL.Vertex2(20 * (col + 1) - 1, 20 * (row + 1) - 1);
         GL.Vertex2(20 * (col + 1) - 1, 20 * (row + 1) + 1);
         GL.Vertex2(20 * (col) + 1, 20 * (row + 1) + 1);
         GL.Enable(EnableCap.Texture2D);
     }
 }
 public ThreePieceElbowToken(Board board, int row, int column, CellColor color1, CellColor color2, CellColor color3)
 {
     piece = new TokenPiece[3];
     Cell cell1 = new Cell();
     Cell cell2 = new Cell();
     Cell cell3 = new Cell();
     cell1.color = color1;
     cell2.color = color2;
     cell3.color = color3;
     cell1.direction = Cell.Direction.RIGHT;
     cell2.direction = Cell.Direction.LEFT | Cell.Direction.DOWN;
     cell3.direction = Cell.Direction.UP;
     piece[0] = new TokenPiece(board, row, column, cell1);
     piece[1] = new TokenPiece(board, row, column + 1, cell2);
     piece[2] = new TokenPiece(board, row + 1, column + 1, cell3);
     orientation = 0;
 }
Beispiel #43
0
	public void TintColor(CellColor c)
	{
		// sanity check
		if(render == null)	return;
		
		switch(c)
		{
		case CellColor.Blue: render.color = new Color(0,0,1,1); break;
		case CellColor.Red: render.color = new Color(1,0,0,1); break;
		case CellColor.Green: render.color = new Color(0,1,0,1); break;
		case CellColor.Cyan: render.color = new Color(0,1,1,1); break;
		case CellColor.Magenta: render.color = new Color(1,0,1); break;
		case CellColor.Yellow: render.color = new Color(1,1,0,1); break;
		case CellColor.Chroma: render.color = new Color(1,1,1,1); break;
		case CellColor.NoColor: render.color = new Color(0,0,0,0);break;
		}
	}
Beispiel #44
0
        public void DrawCell(Cell cell, CellColor color, Rectangle targetRect, SpriteBatch spriteBatch)
        {
            int x = 0;
            int y = 0;
            switch (cell.direction) {
                case Cell.Direction.DOWN | Cell.Direction.RIGHT: { x = 0; y = 0; break; }
                case Cell.Direction.UP | Cell.Direction.DOWN | Cell.Direction.RIGHT: { x = 0; y = 2; break; }
                case Cell.Direction.UP | Cell.Direction.RIGHT: { x = 0; y = 4; break; }
                case Cell.Direction.DOWN | Cell.Direction.LEFT | Cell.Direction.RIGHT: { x = 2; y = 0; break; }
                case Cell.Direction.UP | Cell.Direction.LEFT | Cell.Direction.DOWN | Cell.Direction.RIGHT: { x = 2; y = 2; break; }
                case Cell.Direction.UP | Cell.Direction.LEFT | Cell.Direction.RIGHT: { x = 2; y = 4; break; }
                case Cell.Direction.DOWN | Cell.Direction.LEFT: { x = 4; y = 0; break; }
                case Cell.Direction.UP | Cell.Direction.LEFT | Cell.Direction.DOWN: { x = 4; y = 2; break; }
                case Cell.Direction.UP | Cell.Direction.LEFT: { x = 4; y = 4; break; }

                case Cell.Direction.RIGHT: { x = 6; y = 0; break; }
                case Cell.Direction.RIGHT | Cell.Direction.LEFT: { x = 7; y = 0; break; }
                case Cell.Direction.LEFT: { x = 8; y = 0; break; }

                case Cell.Direction.DOWN: { x = 10; y = 0; break; }
                case Cell.Direction.UP | Cell.Direction.DOWN: { x = 10; y = 1; break; }
                case Cell.Direction.UP: { x = 10; y = 2; break; }

                case Cell.Direction.NONE: { x = 6; y = 2; break; }
            }
            if (cell.locked) {
                x = 8;
                y = 2;
            }
            x *= 65;
            y *= 65;

            Color highlight = (cell.matched ? Color.Gray : Color.White);

            Rectangle sourceRect;
            sourceRect.X = x;
            sourceRect.Y = y;
            sourceRect.Width = 64;
            sourceRect.Height = 64;

            spriteBatch.Draw(colorTextures[color].GetTexture(), targetRect, sourceRect, highlight);
        }
Beispiel #45
0
 public FourPieceZToken(Board board, int row, int column, CellColor color1, CellColor color2, CellColor color3, CellColor color4)
 {
     piece = new TokenPiece[4];
     Cell cell1 = new Cell();
     Cell cell2 = new Cell();
     Cell cell3 = new Cell();
     Cell cell4 = new Cell();
     cell1.color = color1;
     cell2.color = color2;
     cell3.color = color3;
     cell4.color = color4;
     cell1.direction = Cell.Direction.RIGHT;
     cell2.direction = Cell.Direction.LEFT | Cell.Direction.DOWN;
     cell3.direction = Cell.Direction.UP | Cell.Direction.RIGHT;
     cell4.direction = Cell.Direction.LEFT;
     piece[0] = new TokenPiece(board, row, column, cell1);
     piece[1] = new TokenPiece(board, row, column + 1, cell2);
     piece[2] = new TokenPiece(board, row + 1, column + 1, cell3);
     piece[3] = new TokenPiece(board, row + 1, column + 2, cell4);
     orientation = 0;
 }
Beispiel #46
0
	public void TintColor(CellColor c)
	{
		cellView.TintColor(c);
	}
Beispiel #47
0
	public bool Match(CellColor clr)
	{
		// if argument color is Chromatic,
		// it just matches if self color is chromatic as well.
		if(clr == CellColor.Chroma)
			return color == clr;
		else
			return( (clr & color) > 0); 
	}
Beispiel #48
0
 public void init(CellColor curCorlor,CellType curType)
 {
     cellColor = curCorlor;
     cellType = curType;
     updateCell ();
 }
Beispiel #49
0
 public BlockCell(CellColor color)
 {
     blockColor = color;
 }
Beispiel #50
0
        private void FloodFill(int row, int col, bool[,] visit, CellColor par, Cell[,] board)
        {
            if (row < 0 || row >= ROW_SIZE + 3) return;
            if (col < 0 || col >= COL_SIZE) return;
            if (visit[row, col]) return;
            if (board[row, col].IsEmpty) return;

            if (board[row, col].Color != par) return;

            // in same color
            visit[row, col] = true;
            if (row + 1 < ROW_SIZE + 3)
                FloodFill(row + 1, col, visit, board[row + 1, col].Color,board); // connect upper
            FloodFill(row - 1, col, visit, par, board);
            FloodFill(row, col + 1, visit, par, board);
            FloodFill(row, col - 1, visit, par, board);
        }
Beispiel #51
0
 public Tetrimino(int x, int y, CellColor[,] colors)
 {
     leftTopX = x;
     leftTopY = y;
     this.colors = colors;
 }
Beispiel #52
0
 public void RotateRight()
 {
     CellColor[,] temp = new CellColor[width, height];
     for (int x = 0 ; x < width ; ++x) {
         for (int y = 0 ; y < height ; ++y) {
             temp[x, y] = colors[y, width - x - 1];
         }
     }
     colors = temp;
 }
Beispiel #53
0
 public static Value FillRows(Value rows, Value pattern, CellColor color)
 {
     if (rows.type != Type.INT) {
         throw new Exception("fill_rows expects a first argument of type int.");
     }
     if (pattern.type != Type.PATTERN) {
         throw new Exception("fill_rows expects a second argument of type pattern.");
     }
     int total = rows.intValue * Constants.COLUMNS;
     int additional = total - pattern.patternValue.Count;
     if (additional < 0) {
         return pattern;
     }
     return ((new Value(color)).Multiply(new Value(additional))).Add(pattern);
 }
Beispiel #54
0
 private CellColor[,] CreateEmptyCellColors()
 {
     CellColor[,] colors = new CellColor[WiDTH, HEIGHT];
     for (int x = 0 ; x < WiDTH ; ++x) {
         for (int y = 0 ; y < HEIGHT ; ++y) {
             colors[x, y] = CellColor.Empty;
         }
     }
     return colors;
 }
Beispiel #55
0
        private void Reflect(CellColor[,] colors, Tetrimino tetrimino)
        {
            for (int tetriminoX = 0 ; tetriminoX < tetrimino.width ; ++tetriminoX) {
                for (int tetriminoY = 0 ; tetriminoY < tetrimino.height ; ++tetriminoY) {
                    int x = tetrimino.leftTopX + tetriminoX;
                    int y = tetrimino.leftTopY + tetriminoY;
                    if (x < 0 || x >= WiDTH || y < 0 || y >= HEIGHT) {
                        continue;
                    }

                    if (tetrimino.colors[tetriminoX, tetriminoY] != CellColor.Empty) {
                        colors[x, y] = tetrimino.colors[tetriminoX, tetriminoY];
                    }
                }
            }
        }
Beispiel #56
0
	public void SetColor(CellColor c)
	{ color = c;	ResetColor(); }
Beispiel #57
0
 public Value(CellColor color)
 {
     patternValue = new List<Cell>();
     Cell cell = new Cell();
     cell.color = color;
     cell.locked = true;
     patternValue.Add(cell);
     type = Type.PATTERN;
 }
        //---------------------------------------------------------------------------------------------
        // 各セルの Saturation および Brightness 値をリストに格納する
        // このメソッドは、userControl_Loaded イベント内で 1 回だけ呼ばれる
        private void SetSVList(int hue)
        {
            int n = 0;
            const double N = 0.0625;
            SVList = new List<CellColor>(289); // = 17 x 17

            for (double v = 1.0; v >= 0.0; v -= N)
            {
                for (double s = 0.0; s <= 1.0; s += N)
                {
                    var sv = new CellColor();
                    sv.H = hue;
                    sv.S1 = s;
                    sv.S2 = s + N;
                    sv.V1 = v;
                    sv.V2 = v - N;
                    sv.Color = ColorUtility.HsvToColor(hue, s, v);

                    ++n;

                    SVList.Add(sv);
                }
            }
        }
Beispiel #59
0
 public void RotateLeft()
 {
     CellColor[,] temp = new CellColor[width, height];
     for (int x = 0 ; x < width ; ++x) {
         for (int y = 0 ; y < height ; ++y) {
             temp[x, y] = colors[height - y - 1, x];
         }
     }
     colors = temp;
 }
Beispiel #60
0
	public void ResetColor(CellColor c)
	{
		TintColor(c);
	}