public mcCellRelations(mcCellRelations obj) { nR = obj.nR; nL = obj.nL; nT = obj.nT; nD = obj.nD; nTR = obj.nTR; nTL = obj.nTL; nDR = obj.nDR; nDL = obj.nDL; MB = obj.MB; }
public void Rearrenge(mcCell asker, bool empty) { BallsNextStepActivate(); Point P = new Point(_cellPress.X, _cellPress.Y); BallColor colrAsker = _grid[(int)asker._coord.Y, (int)asker._coord.X]._cellCurrentColor; BallColor colrPress = _grid[(int)_cellPress.Y, (int)_cellPress.X]._cellCurrentColor; _grid[(int)asker._coord.Y, (int)asker._coord.X]._cellBall._BallChangeColor(colrPress); _grid[(int)P.Y, (int)P.X]._cellBall._BallChangeColor(colrAsker); _grid[(int)P.Y, (int)P.X]._cellBall._BallSetUnPressWH(); if (empty) { _grid[(int)asker._coord.Y, (int)asker._coord.X]._cellBall._BallSetNormalWH(); _grid[(int)P.Y, (int)P.X]._cellBall._BallSetNullWH(); } PrintLines(); Thread.Sleep(100); //_SetNANCellPress(); }
public CellGame(mcCell cell) { InitializeComponent(); //BallSetNullWH(); _cellBall = cell; }
void FillGameDesk() { int temp = 1; for (int y = 0; y < _boardHW.Y; y++) { for (int x = 0; x < _boardHW.X; x++) { _grid[y, x] = new mcCell(x, y); CellGame T = new CellGame(_grid[y, x]); T._cellBall._celRel.MB = this; T._BallChangeColor((BallColor)_glRand.Next(0, _countColorBalls)); T._cellBall._celRel.SN = temp; temp++; _MW.Desk.Children.Add(T); _grid[y, x]._cellBall = (CellGame)_MW.Desk.Children[_MW.Desk.Children.Count - 1]; } } for (int y = 0; y < _boardHW.Y; y++) { for (int x = 0; x < _boardHW.X; x++) { if (x > 0 && y > 0 && x < _boardHW.X - 1 && y < _boardHW.Y - 1) { _grid[y, x]._celRel.nT = _grid[y - 1, x]; _grid[y, x]._celRel.nTL = _grid[y - 1, x - 1]; _grid[y, x]._celRel.nTR = _grid[y - 1, x + 1]; _grid[y, x]._celRel.nD = _grid[y + 1, x]; _grid[y, x]._celRel.nDL = _grid[y + 1, x - 1]; _grid[y, x]._celRel.nDR = _grid[y + 1, x + 1]; _grid[y, x]._celRel.nL = _grid[y, x - 1]; _grid[y, x]._celRel.nR = _grid[y, x + 1]; _grid[y, x]._cellPosBord = mcPositionBorder.C; } if (x == 0 && y > 0 && y < _boardHW.Y - 1) { _grid[y, x]._celRel.nT = _grid[y - 1, x]; _grid[y, x]._celRel.nTR = _grid[y - 1, x + 1]; _grid[y, x]._celRel.nR = _grid[y, x + 1]; _grid[y, x]._celRel.nDR = _grid[y + 1, x + 1]; _grid[y, x]._celRel.nD = _grid[y + 1, x]; _grid[y, x]._cellPosBord = mcPositionBorder.LB; } if (x == _boardHW.X - 1 && y > 0 && y < _boardHW.Y - 1) { _grid[y, x]._celRel.nT = _grid[y - 1, x]; _grid[y, x]._celRel.nTL = _grid[y - 1, x - 1]; _grid[y, x]._celRel.nL = _grid[y, x - 1]; _grid[y, x]._celRel.nDL = _grid[y + 1, x - 1]; _grid[y, x]._celRel.nD = _grid[y + 1, x]; _grid[y, x]._cellPosBord = mcPositionBorder.RB; } if (y == 0 && x > 0 && x < _boardHW.X - 1) { _grid[y, x]._celRel.nL = _grid[y, x - 1]; _grid[y, x]._celRel.nR = _grid[y, x + 1]; _grid[y, x]._celRel.nD = _grid[y + 1, x]; _grid[y, x]._celRel.nDL = _grid[y + 1, x - 1]; _grid[y, x]._celRel.nDR = _grid[y + 1, x + 1]; _grid[y, x]._cellPosBord = mcPositionBorder.TB; } if (y == _boardHW.Y - 1 && x > 0 && x < _boardHW.X - 1) { _grid[y, x]._celRel.nL = _grid[y, x - 1]; _grid[y, x]._celRel.nR = _grid[y, x + 1]; _grid[y, x]._celRel.nT = _grid[y - 1, x]; _grid[y, x]._celRel.nTL = _grid[y - 1, x - 1]; _grid[y, x]._celRel.nTR = _grid[y - 1, x + 1]; _grid[y, x]._cellPosBord = mcPositionBorder.DB; } if (x == 0 && y == 0) { _grid[y, x]._celRel.nR = _grid[y, x + 1]; _grid[y, x]._celRel.nDR = _grid[y + 1, x + 1]; _grid[y, x]._celRel.nD = _grid[y + 1, x]; _grid[y, x]._cellPosBord = mcPositionBorder.LT; } if (x == _boardHW.X - 1 && y == 0) { _grid[y, x]._celRel.nL = _grid[y, x - 1]; _grid[y, x]._celRel.nD = _grid[y + 1, x]; _grid[y, x]._celRel.nDL = _grid[y + 1, x - 1]; _grid[y, x]._cellPosBord = mcPositionBorder.RT; } if (x == 0 && y == _boardHW.Y - 1) { _grid[y, x]._celRel.nT = _grid[y - 1, x]; _grid[y, x]._celRel.nR = _grid[y, x + 1]; _grid[y, x]._celRel.nTR = _grid[y - 1, x + 1]; _grid[y, x]._cellPosBord = mcPositionBorder.LD; } if (x == _boardHW.X - 1 && y == _boardHW.Y - 1) { _grid[y, x]._celRel.nT = _grid[y - 1, x]; _grid[y, x]._celRel.nL = _grid[y, x - 1]; _grid[y, x]._celRel.nTL = _grid[y - 1, x - 1]; _grid[y, x]._cellPosBord = mcPositionBorder.RD; } } } ForMyFor(mcWhatToDo.SetDeskCoord); ForMyFor(mcWhatToDo.SetNeigboursSNs); }