コード例 #1
0
        private Coordinates TwoInLeftDownDiagonal(CellCondition[,] gameField, CellCondition condition)
        {
            var conditionCells = new List <Coordinates>();
            var emptyCells     = new List <Coordinates>();

            for (var factor = 0; factor <= 2; factor++)
            {
                var cell = new Coordinates {
                    X = factor, Y = 2 - factor
                };

                if (gameField[factor, 2 - factor] == condition)
                {
                    conditionCells.Add(cell);
                    continue;
                }

                if (gameField[factor, 2 - factor] == CellCondition.Empty)
                {
                    emptyCells.Add(cell);
                }
            }

            if (conditionCells.Count != 2)
            {
                return(null);
            }

            return(emptyCells.Any() ? emptyCells.FirstOrDefault() : null);
        }
コード例 #2
0
 void initPivotGridButton_Click(object sender, RoutedEventArgs e)
 {
     // pivotGridControl.URL = WSDataUrl;
     pivotGridControl.Connection                = ConnectionStringId;
     pivotGridControl.Query                     = tbMdxQuery.Text;
     pivotGridControl.UpdateScript              = tbUpdateScript.Text;
     pivotGridControl.MembersViewMode           = (Ranet.AgOlap.Controls.ViewModeTypes)cbMembersViewMode.SelectedIndex;
     pivotGridControl.MemberVisualizationType   = (Ranet.Olap.Core.Data.MemberVisualizationTypes)cbMemberVisualizationType.SelectedIndex;
     pivotGridControl.DataReorganizationType    = (Ranet.Olap.Core.Providers.DataReorganizationTypes)cbDataReorganizationType.SelectedIndex;
     pivotGridControl.DefaultMemberAction       = (Ranet.AgOlap.Controls.MemberClickBehaviorTypes)cbDefaultMemberAction.SelectedIndex;
     pivotGridControl.ColumnTitleClickBehavior  = (Ranet.AgOlap.Controls.ColumnTitleClickBehavior)cbColumnTitleClickBehavior.SelectedIndex;
     pivotGridControl.DrillDownMode             = (Ranet.AgOlap.Controls.DrillDownMode)cbDrillDownMode.SelectedIndex;
     pivotGridControl.IsUpdateable              = ckbIsUpdateable.IsChecked.Value;
     pivotGridControl.AutoWidthColumns          = ckbAutoWidthColumns.IsChecked.Value;
     pivotGridControl.ColumnsIsInteractive      = ckbColumnsIsInteractive.IsChecked.Value;
     pivotGridControl.RowsIsInteractive         = ckbRowsIsInteractive.IsChecked.Value;
     pivotGridControl.UseColumnsAreaHint        = ckbUseColumnsAreaHint.IsChecked.Value;
     pivotGridControl.UseRowsAreaHint           = ckbUseRowsAreaHint.IsChecked.Value;
     pivotGridControl.UseCellsAreaHint          = ckbUseCellsAreaHint.IsChecked.Value;
     pivotGridControl.UseCellConditionsDesigner = ckbUseCellConditionsDesigner.IsChecked.Value;
     if (!pivotGridControl.UseCellConditionsDesigner)
     {
         var conds   = new CellConditionsDescriptor("[Measures].[Internet Sales Amount]");
         var cellApp = new CellAppearanceObject(Colors.Cyan, Colors.Black, Colors.Black);
         cellApp.Options.UseBackColor = true;
         // cellApp.Options.UseBorderColor=true;
         var cond = new CellCondition(CellConditionType.GreaterOrEqual, 1000000.0, 1000000.0, cellApp);
         conds.Conditions.Add(cond);
         pivotGridControl.CustomCellsConditions = new List <CellConditionsDescriptor>();
         pivotGridControl.CustomCellsConditions.Add(conds);
     }
     pivotGridControl.Initialize();
 }
コード例 #3
0
        public void ManipulateCellsByCondition(CustomAction action, CellCondition condition)
        {
            ProgressMax     = _tileMap.Map.MapData.Count;
            ProgressCounter = 0;
            var cellsToManipulate =
                (from cell in _tileMap.Map.MapData where condition(cell.Key) select cell.Key).ToList();

            cellsToManipulate.ForEach(cell => action(cell));
        }
コード例 #4
0
ファイル: Cell.cs プロジェクト: Anagalanyuk/LifeGame
 public void ChangeState()
 {
     if (cell == CellCondition.Live)
     {
         cell = CellCondition.Death;
     }
     else
     {
         cell = CellCondition.Live;
     }
 }
コード例 #5
0
        public CellCondition[,] MakeFieldCopy(CellCondition[,] field)
        {
            var gameField = new CellCondition[GameFieldConstants.LineLength, GameFieldConstants.LineLength];

            for (var x = 0; x <= GameFieldConstants.MaxCoordinate; x++)
            {
                for (var y = 0; y <= GameFieldConstants.MaxCoordinate; y++)
                {
                    gameField[x, y] = field[x, y];
                }
            }

            return(gameField);
        }
コード例 #6
0
        public CellCondition[,] CreateNewGameField()
        {
            var gameField = new CellCondition[GameFieldConstants.LineLength, GameFieldConstants.LineLength];

            for (var x = 0; x <= GameFieldConstants.MaxCoordinate; x++)
            {
                for (var y = 0; y <= GameFieldConstants.MaxCoordinate; y++)
                {
                    gameField[x, y] = CellCondition.Empty;
                }
            }

            return(gameField);
        }
コード例 #7
0
        static void Made_Shot(object sender, EventArgs e)
        {
            Field field = (Field)sender;

            if (field == Form1.RightField)
            {
                leftStatistika.CountLeftShot--;
            }
            else
            {
                rightStatistika.CountLeftShot--;
            }

            CellCondition result = ((shotEventArgs)e).shotResult;

            if (result == CellCondition.Drowned)
            {
                if (field == Form1.RightField)
                {
                    rightStatistika.CountShips--;
                }
                else
                {
                    leftStatistika.CountShips--;
                }
            }

            if (soundPlay)
            {
                PlaysEffect(ShotSound);

                if (result == CellCondition.Miss)
                {
                    PlaysEffect(MissSound);
                }
                else
                if (result == CellCondition.Crippled)
                {
                    PlaysEffect(CrippledSound);
                }
                else
                if (result == CellCondition.Drowned)
                {
                    PlaysEffect(DrownedShipsSound);
                }
            }
        }
コード例 #8
0
        void SureShot()
        {
            int di = 0;
            int dj = 0;

            if (direction == Direction.Left)
            {
                dj = -1;
            }
            if (direction == Direction.Reight)
            {
                dj = 1;
            }
            if (direction == Direction.Top)
            {
                di = -1;
            }
            if (direction == Direction.Bottom)
            {
                di = 1;
            }

            CellCondition shotState;

            if ((GeneralFunction.PreventionIndexRange(currentShot.I + di, currentShot.J + dj)) &&
                (!CheckShot[currentShot.I + di, currentShot.J + dj]))
            {
                shotState = ShotDirection(direction);
            }
            else
            {
                ChangeDirection();
                shotState = ShotDirection(direction);
            }

            if (shotState == CellCondition.Miss)
            {
                ChangeDirection();
            }
            else
            {
                Move();
            }
        }
コード例 #9
0
        void Cell_Click(object sender, MouseEventArgs e)
        {
            if (!canMove)
            {
                return;
            }

            SeaBattlePicture cell = (SeaBattlePicture)sender;

            cell.Enabled = false;

            CellCondition shotResult = Form1.RightField.Shot(cell);

            if (shotResult == CellCondition.Miss)
            {
                canMove = false;
                CallTransferMove();
            }
        }
コード例 #10
0
        CellCondition ShotDirection(Direction direciton)
        {
            int di = 0;
            int dj = 0;

            if (direciton == Direction.Left)
            {
                dj = -1; di = 0;
            }

            if (direciton == Direction.Top)
            {
                dj = 0; di = -1;
            }

            if (direciton == Direction.Reight)
            {
                dj = 1; di = 0;
            }

            if (direciton == Direction.Bottom)
            {
                dj = 0; di = 1;
            }

            shotState = oponentField.Shot(
                oponentField.CellField[currentShot.I + di, currentShot.J + dj]);
            CheckShot[currentShot.I + di, currentShot.J + dj] = true;


            if (shotState != CellCondition.Miss)
            {
                currentShot.I += di;
                currentShot.J += dj;
            }

            if (shotState == CellCondition.Drowned)
            {
                moveState = MoveState.UnknownShipLocation;
            }

            return(shotState);
        }
コード例 #11
0
        public void InstallTheCage()
        {
            ControlOverWork toWork = new ControlOverWork();

            cursor.Show();

            Right         right         = new Right(field, cursor);
            Left          left          = new Left(cursor);
            Up            up            = new Up(cursor, field);
            Down          down          = new Down(field, cursor);
            CellCondition cellCondition = new CellCondition(field, cursor);
            Start         start         = new Start(toWork);

            commands.Add(right);
            commands.Add(left);
            commands.Add(up);
            commands.Add(down);
            commands.Add(cellCondition);
            commands.Add(start);

            ConsoleKeyInfo key;

            toWork.CurrentState = true;

            while (toWork.CurrentState)
            {
                key = Console.ReadKey();
                Console.SetCursorPosition(cursor.X, cursor.Y);
                //очистка хвоста
                Console.Write(' ');

                foreach (ICommand command in commands)
                {
                    command.Executive(key);
                }

                field.PrintOutTheFrame();
                field.WithdrawTheArea();
                cursor.Show();
            }
        }
コード例 #12
0
        void GuessingDirection()
        {
            if (oneGuessing)
            {
                CountingAllowableDirection();
            }

            int shot = random.Next(0, intactDirection);

            count = 0;

            int numberDirection = -1;

            for (var i = 0; i < 4; i++)
            {
                if (!ChekDirection[i])
                {
                    if (count == shot)
                    {
                        ChekDirection[i] = true;
                        intactDirection--;
                        numberDirection = i;
                    }
                    count++;
                }
            }

            CellCondition shotResult = ShotDirection((Direction)numberDirection);

            if (shotResult == CellCondition.Crippled)
            {
                direction = (Direction)numberDirection;
                moveState = MoveState.KnownDirection;
            }

            if (shotState != CellCondition.Miss)
            {
                Move();
            }
        }
コード例 #13
0
        void LongShot()
        {
            int shot = random.Next(0, IntactCell);

            Location newShot = OverrideShot(CheckShot, shot);

            shotState = oponentField.Shot(
                oponentField.CellField[newShot.I, newShot.J]);

            if (shotState == CellCondition.Crippled)
            {
                moveState   = MoveState.UnknownDirection;
                oneGuessing = true;
                firstShot   = newShot;
            }
            currentShot = newShot;

            if (shotState != CellCondition.Miss)
            {
                Move();
            }
        }
コード例 #14
0
        private Coordinates TwoInRow(CellCondition[,] gameField, CellCondition condition)
        {
            for (var y = 0; y <= 2; y++)
            {
                var conditionCells = new List <Coordinates>();
                var emptyCells     = new List <Coordinates>();

                for (var x = 0; x <= 2; x++)
                {
                    var cell = new Coordinates {
                        X = x, Y = y
                    };

                    if (gameField[x, y] == condition)
                    {
                        conditionCells.Add(cell);
                        continue;
                    }

                    if (gameField[x, y] == CellCondition.Empty)
                    {
                        emptyCells.Add(cell);
                    }
                }

                if (conditionCells.Count != 2)
                {
                    continue;
                }

                if (emptyCells.Any())
                {
                    return(emptyCells.FirstOrDefault());
                }
            }

            return(null);
        }
コード例 #15
0
 public ComputerPlay(Field field) : base(field)
 {
     shotState = CellCondition.Miss;
     GeneralFunction.FalseToMatrix(CheckShot);
     IntactCell = Field.Size * Field.Size;
 }
コード例 #16
0
 public shotEventArgs(CellCondition result)
 {
     shotResult = result;
 }
コード例 #17
0
ファイル: Cell.cs プロジェクト: stasOR4ik/Angel_Problem
 public Cell(Polygon angelSquare)
 {
     Square        = angelSquare;
     CellCondition = CellCondition.ANGEL;
 }
コード例 #18
0
 public void RemoveCellsByCondition(CellCondition condition)
 {
     ManipulateCellsByCondition(_tileMap.RemoveEverythingAtCell, condition);
 }
コード例 #19
0
ファイル: Cell.cs プロジェクト: Anagalanyuk/LifeGame
 public Cell()
 {
     cell = CellCondition.Death;
 }
コード例 #20
0
ファイル: Cell.cs プロジェクト: stasOR4ik/Angel_Problem
 public Cell()
 {
     Square        = new Polygon();
     CellCondition = CellCondition.EMPTY;
 }