private void CellStateChanged(object sender, CellStateChangedEventArgs args)
    {
        var p = new PlayfieldPoint(args.Column, args.Row);

        switch (args.NewState)
        {
        case Cell.States.Empty:
            RemoveCell(p);
            break;

        case Cell.States.Disabled:
            break;

        case Cell.States.BlackAndWhite:
            break;

        case Cell.States.Black:
        case Cell.States.BlackJeweledBoth:
        case Cell.States.BlackJeweledHorz:
        case Cell.States.BlackJeweledVert:
        case Cell.States.White:
        case Cell.States.WhiteJeweledBoth:
        case Cell.States.WhiteJeweledHorz:
        case Cell.States.WhiteJeweledVert:
            InstantiateVisual(Playfield.GetCell(p));
            break;

        default:
            break;
        }
    }
示例#2
0
        public void CellStateChanged(object sender, CellStateChangedEventArgs e)
        {
            Cell firstCell = null;
            bool completed = true;

            for (int c = 0; c < NumCellsPerAxis; c++)
            {
                for (int r = 0; r < NumCellsPerAxis; r++)
                {
                    Cell cell = Playfield.GetCell(c + Column, r + Row);
                    if (firstCell == null)
                    {
                        firstCell = cell;
                    }
                    if (!cell.IsOccupied ||
                        !firstCell.IsSameColor(cell))
                    {
                        completed = false;
                        break;
                    }
                }
            }

            if (completed && State != States.Completing)
            {
                foreach (var c in new Cell[] { UpperLeft, UpperRight, LowerLeft, LowerRight })
                {
                    if (!c.IsRemove)
                    {
                        c.RemoveState = Cell.RemoveStates.WillBeRemoved;
                    }
                }
            }
            else if (!completed)
            {
                foreach (var c in new Cell[] { UpperLeft, UpperRight, LowerLeft, LowerRight })
                {
                    bool clearRemoveState = true;
                    foreach (var s in GetOtherSquares(c))
                    {
                        if (s?.State == States.Completing)
                        {
                            clearRemoveState = false;
                            break;
                        }
                    }
                    if (clearRemoveState && !c.IsJewelRemove)
                    {
                        c.RemoveState = Cell.RemoveStates.NotRemoved;
                    }
                }
            }

            if (_prevState != State)
            {
                _prevState = State;
                StateChanged?.Invoke(this, EventArgs.Empty);
            }
        }
示例#3
0
 private void OnCellStateChanged(object sender, CellStateChangedEventArgs e)
 {
     if (e.Cell.CachingState == CachingState.InUse)
     {
         records.Add(new CellStateChanged()
         {
             Row       = e.Cell.Row,
             Column    = e.Cell.Column,
             NewState  = e.Cell.State,
             Timestamp = this.game.UsedTime,
         });
     }
     else
     {
         Trace.TraceWarning("Useless state changed event triggered from the game.");
     }
 }
示例#4
0
        private void Engine_CellStateChanged(object sender, CellStateChangedEventArgs e)
        {
            GridCellUi test = Cells.Where(cell => cell.X == e.CellAfterChange.X && cell.Y == e.CellAfterChange.Y).First();

            SwitchColorState(test);
        }
示例#5
0
 private void Engine_CellStateChanged(object sender, CellStateChangedEventArgs e)
 {
     cellulesVerticalesDetectees.Add(e.CellAfterChange);
 }