Example #1
0
        private CheckPosition GetArroundPosition(CheckPosition myPosition, Check check)
        {
            var line   = myPosition.Position[0];
            var column = myPosition.Position[1];

            switch (check)
            {
            case Check.MyTop:
                return(new CheckPosition {
                    Position = new[] { line - 1, column }
                });

            case Check.MyRight:
                return(new CheckPosition {
                    Position = new[] { line, column + 1 }
                });

            case Check.MyUnderneath:
                return(new CheckPosition {
                    Position = new[] { line + 1, column }
                });

            case Check.MyLeft:
                return(new CheckPosition {
                    Position = new[] { line, column - 1 }
                });

            default:
                return(myPosition);
            }
        }
Example #2
0
        public double DiscountValueTest(double value)
        {
            var checkPosition = new CheckPosition(DiscountFactory.GetDiscount(Discounts.Coupon, value),
                                                  new Product(100));

            return(checkPosition.DiscountValue);
        }
Example #3
0
        private CheckPosition GetNextPosition(CheckPosition currentPosition, Actions action)
        {
            var line   = currentPosition.Position[0];
            var column = currentPosition.Position[1];

            switch (action)
            {
            case Actions.Up:
                return(new CheckPosition {
                    Position = new[] { line - 1, column }
                });

            case Actions.Right:
                return(new CheckPosition {
                    Position = new[] { line, column + 1 }
                });

            case Actions.Down:
                return(new CheckPosition {
                    Position = new[] { line + 1, column }
                });

            case Actions.Left:
                return(new CheckPosition {
                    Position = new[] { line, column - 1 }
                });

            default:
                return(currentPosition);
            }
        }
Example #4
0
 public override void init()
 {
     base.init();
     mSpeed         = 0.0f;
     mDoneCallback  = null;
     mCheckPosition = null;
 }
Example #5
0
 private void OnCollisionEnter(Collision collision)
 {
     if (collision.gameObject.GetComponent <Player>() != null)
     {
         CheckPosition?.Invoke(this);
     }
 }
Example #6
0
        public double CheckPositionDiscountTest(double price, Discounts type, double value)
        {
            var checkPosition = new CheckPosition(DiscountFactory.GetDiscount(type, value),
                                                  new Product(price));

            return(checkPosition.CheckPositionDiscount);
        }
Example #7
0
 public void ResetElements()
 {
     OnResetCanGo();
     currentDirection = null;
     MovementOnX      = false;
     MovementOnY      = false;
 }
Example #8
0
        public static void UpdateBallPosition()
        {
            if (!Ball.CanMove())
            {
                return;
            }
            UpdateLastPosition(Ball);
            if (Ball.YStartValue != Board.YMargin + 1 && Ball.YStartValue != Board.Height - 1)
            {
                State.HasHitWall = false;
            }

            if (CheckPosition.HasHitWall(Ball.YStartValue))
            {
                if (!State.HasHitWall)
                {
                    State.HasHitWall = true;
                    Ball.SetAngleAfterWallHit(Ball.XStartValue, Ball.YStartValue);
                    MoveBall();
                    return;
                }
            }

            var hasScored = false;

            if (CheckPosition.HasPlayer1Scored(Ball.XStartValue))
            {
                ScoreBoard.Player1Score++;
                hasScored = true;
            }

            if (CheckPosition.HasPlayer2Scored(Ball.XStartValue))
            {
                ScoreBoard.Player2Score++;
                hasScored = true;
            }

            if (hasScored)
            {
                State.ScreenNeedsRedraw = true;
                ResetBallPosition();
                MoveBall();
                return;
            }

            if (CheckPosition.HasHitPlayer(Player1, Ball))
            {
                PlayerHit(Player1);
                return;
            }

            if (CheckPosition.HasHitPlayer(Player2, Ball))
            {
                PlayerHit(Player2);
                return;
            }

            Ball.Move();
        }
Example #9
0
        public double CheckPositionPriceTest(double value)
        {
            var discount      = DiscountFactory.GetDiscount(Discounts.Coupon, 11);
            var product       = new Product(value);
            var checkPosition = new CheckPosition(discount, product);

            return(checkPosition.CheckPositionPrice);
        }
Example #10
0
        public void ProductTest(double value)
        {
            var discount      = DiscountFactory.GetDiscount(Discounts.Coupon, 11);
            var product       = new Product(value);
            var checkPosition = new CheckPosition(discount, product);

            Assert.AreSame(product, checkPosition.Product);
        }
        protected override void AddNested(DrawableHitObject h)
        {
            var catchObject = (DrawableCatchHitObject)h;

            catchObject.CheckPosition = o => CheckPosition?.Invoke(o) ?? false;

            dropletContainer.Add(h);
            base.AddNested(h);
        }
Example #12
0
        public int GetResultByStrategy(Strategy strategy, CheckPosition position, Checker checker)
        {
            var pacman = new Pacman
            {
                Strategy = strategy,
                Points   = new int[1],
            };

            _runTheGame.StartMove(ref pacman, position, checker, 0);
            return(pacman.Points[0]);
        }
Example #13
0
 public bool StepNorth()
 {
     InMove           = true;
     currentDirection = MotionCheck(0);
     if (InMove)
     {
         MathAction  = true;
         MovementOnY = true;
         CheckOpportunityTakeStep();
     }
     return(InMove);
 }
Example #14
0
 public bool StepWest()
 {
     InMove           = true;
     currentDirection = MotionCheck(3);
     if (InMove)
     {
         MathAction  = false;
         MovementOnX = true;
         CheckOpportunityTakeStep();
     }
     return(InMove);
 }
Example #15
0
 private static void UpdatePosition(ConsolePlayer player)
 {
     UpdateLastPosition(player);
     player.Move(key);
     if (CheckPosition.HasPlayerReachedWall(player))
     {
         ResetPosition(player);
     }
     else
     {
         State.PlayerNeedsRedraw = true;
     }
 }
        public void CheckPositionOnBoard_InvalidPosition_Throw()
        {
            var checkPosition = new CheckPosition();

            char[,] board = new char[, ]
            {
                { '1', '1', '1' },
                { '1', 'M', '1' },
                { '1', '1', '1' },
            };
            Action test = () => checkPosition.CheckPositionOnBoard(8, 8, board);

            test.Should().Throw <Exception>();
        }
Example #17
0
        public void StartMove(ref Pacman pacman, CheckPosition startPosition, Checker checker, int index)
        {
            var currentPosition = startPosition;

            for (var i = 0; i < (int)GameRules.NumberOfOneGameMove; i++)
            {
                var allSituation = checker.Checks[currentPosition];
                var action       = (Actions)pacman.Strategy.Lines.FirstOrDefault(x => x.Key == string.Join("", allSituation)).Value;
                var rnd          = new Random();
                while (action == Actions.Random || action == Actions.Freeze)
                {
                    action = (Actions)_randomPro.GetNext(rnd, 7);
                }

                switch (action)
                {
                case Actions.Freeze:
                    continue;

                case Actions.Up:
                case Actions.Right:
                case Actions.Down:
                case Actions.Left:
                    var nextCheck = (Situations)allSituation[(int)action];
                    if (nextCheck == Situations.Wall)
                    {
                        pacman.Points[index] = pacman.Points[index] + (int)Points.HitWall;
                    }
                    else
                    {
                        currentPosition      = GetNextPosition(currentPosition, action);
                        pacman.Points[index] = pacman.Points[index] + (int)Points.Move;
                    }
                    break;

                case Actions.Eat:
                    if ((Situations)allSituation[(int)Check.Me] == Situations.Bean)
                    {
                        pacman.Points[index] = pacman.Points[index] + (int)Points.EatBean;
                        CheckerChange(ref checker, currentPosition);
                    }
                    else
                    {
                        pacman.Points[index] = pacman.Points[index] + (int)Points.EatEmpty;
                    }
                    break;
                }
            }
        }
        public void CheckPositionOnBoard_ItsMine_ShouldBeM()
        {
            var checkPosition = new CheckPosition();

            char[,] board = new char[, ]
            {
                { '1', '1', '1' },
                { '1', 'M', '1' },
                { '1', '1', '1' },
            };

            var result = checkPosition.CheckPositionOnBoard(1, 1, board);

            Assert.AreEqual(result, 'M');
        }
Example #19
0
    public void startGame()
    {
        CheckPosition check_p = new CheckPosition();
        Dictionary <string, string> winner = new Dictionary <string, string>();
        string pos;

        int[] idx;
        int   turn = 0;

        while (true)
        {
            Console.Write($"{this.users[turn]["name"]} enter position: ");
            pos = Console.ReadLine();
            Console.WriteLine();
            idx = check_p.findIndex(board, pos);
            if (idx[0] != -1)
            {
                if (turn == 0)
                {
                    board[idx[0], idx[1]] = "X";
                    turn = 1;
                }
                else
                {
                    board[idx[0], idx[1]] = "O";
                    turn = 0;
                }
            }
            else
            {
                Console.WriteLine("Position is no longer available ");
            }
            this.displayBoard();
            winner = check_p.findWinner(this.board, this.users);
            if (winner["type"] == "winner")
            {
                Console.WriteLine($"{winner["message"]} is the winner !!!");
                Console.WriteLine();
                break;
            }
            else if (winner["type"] == "no")
            {
                Console.WriteLine(winner["message"]);
                Console.WriteLine();
                break;
            }
        }
    }
Example #20
0
        public void ShouldNotHitPlayer2()
        {
            var hasHit = false;

            for (sbyte j = 0; j < 2; j++)
            {
                for (sbyte i = 0; i < player2.Height + 2; i++)
                {
                    SetBallPositionForPlayer(j, i, player2);
                    if (CheckPosition.HasHitPlayer(player2, ball))
                    {
                        hasHit = true;
                    }
                }
            }
            Assert.IsFalse(hasHit);
        }
Example #21
0
        private void CheckerChange(ref Checker checker, CheckPosition eatenBeanCheckPosition)
        {
            checker.Checks[eatenBeanCheckPosition][(int)Check.Me] = 0;

            var type = GetCheckType(eatenBeanCheckPosition);

            switch (type)
            {
            case CheckTypes.LeftTopCorner:
                ChangeAccoundSituation(new [] { Check.MyRight, Check.MyUnderneath }, ref checker, eatenBeanCheckPosition);
                break;

            case CheckTypes.RightTopCorner:
                ChangeAccoundSituation(new [] { Check.MyUnderneath, Check.MyLeft }, ref checker, eatenBeanCheckPosition);
                break;

            case CheckTypes.LeftUnderneathCorner:
                ChangeAccoundSituation(new [] { Check.MyTop, Check.MyRight }, ref checker, eatenBeanCheckPosition);
                break;

            case CheckTypes.RightUnderneathCorner:
                ChangeAccoundSituation(new[] { Check.MyTop, Check.MyLeft }, ref checker, eatenBeanCheckPosition);
                break;

            case CheckTypes.TopLine:
                ChangeAccoundSituation(new [] { Check.MyRight, Check.MyUnderneath, Check.MyLeft }, ref checker, eatenBeanCheckPosition);
                break;

            case CheckTypes.RightColumn:
                ChangeAccoundSituation(new [] { Check.MyTop, Check.MyUnderneath, Check.MyLeft }, ref checker, eatenBeanCheckPosition);
                break;

            case CheckTypes.UnderneathLine:
                ChangeAccoundSituation(new [] { Check.MyTop, Check.MyLeft, Check.MyLeft }, ref checker, eatenBeanCheckPosition);
                break;

            case CheckTypes.LeftColumn:
                ChangeAccoundSituation(new [] { Check.MyTop, Check.MyRight, Check.MyUnderneath }, ref checker, eatenBeanCheckPosition);
                break;

            case CheckTypes.Center:
                ChangeAccoundSituation(new [] { Check.MyTop, Check.MyRight, Check.MyUnderneath, Check.MyLeft }, ref checker, eatenBeanCheckPosition);
                break;
            }
        }
Example #22
0
 void Start()
 {
     delay    = 0.5f;
     handData = gameData.GetComponent <HandData>();
     Shuffle();
     spawnCardBySpawnData();
     setHandData();
     reSwapn   = checkPos.GetComponent <CheckPosition>();
     SortCheck = sort.GetComponent <SortCheck>();
     if (reSwapn.finalPos == handData.handData)
     {
         clearBoard();
         Shuffle();
         spawnCardBySpawnData();
         setHandData();
     }
     //reSwapn.checkCurrentPosition();
 }
Example #23
0
        public CheckTypes GetCheckType(CheckPosition position)
        {
            var line   = position.Position[0];
            var column = position.Position[1];

            if (line == 1 && column == 1)
            {
                return(CheckTypes.LeftTopCorner);
            }
            if (line == 1 && column == 10)
            {
                return(CheckTypes.RightTopCorner);
            }
            if (line == 10 && column == 1)
            {
                return(CheckTypes.LeftUnderneathCorner);
            }
            if (line == 10 && column == 10)
            {
                return(CheckTypes.RightUnderneathCorner);
            }
            if (line == 1)
            {
                return(CheckTypes.TopLine);
            }
            if (line == 10)
            {
                return(CheckTypes.UnderneathLine);
            }
            if (column == 1)
            {
                return(CheckTypes.LeftColumn);
            }
            if (column == 10)
            {
                return(CheckTypes.RightColumn);
            }
            else
            {
                return(CheckTypes.Center);
            }
        }
Example #24
0
    private void Start()
    {
        switch (directionVector)
        {
        case DirectionVector.Up:
        case DirectionVector.Down:
            _checking = AxisYCheck;
            _rotation.ChangeDirection(new Vector3(0, 0, startToPositive ? 1 : -1));
            break;

        case DirectionVector.left:
        case DirectionVector.right:
            _checking = AxisXCheck;
            _rotation.ChangeDirection(new Vector3(0, 0, startToPositive ? 1 : -1));
            break;

        default:

            throw new ArgumentOutOfRangeException();
        }
    }
Example #25
0
        public string DiscountTypeTest(Discounts type)
        {
            switch (type)
            {
            case Discounts.Coupon:
            {
                var discount      = DiscountFactory.GetDiscount(type, 11);
                var checkPosition = new CheckPosition(discount, new Product(10));
                return(checkPosition.DiscountType);
            }

            case Discounts.Percent:
            {
                var discount      = DiscountFactory.GetDiscount(type, 11);
                var checkPosition = new CheckPosition(discount, new Product(10));
                return(checkPosition.DiscountType);
            }
            }

            return("Ошибка");
        }
Example #26
0
        public void DiscountBaseTest(Discounts type)
        {
            switch (type)
            {
            case Discounts.Coupon:
            {
                var discount      = DiscountFactory.GetDiscount(type, 11);
                var checkPosition = new CheckPosition(discount, new Product(10));
                Assert.AreSame(discount, checkPosition.DiscountBase);
                break;
            }

            case Discounts.Percent:
            {
                var discount      = DiscountFactory.GetDiscount(type, 11);
                var checkPosition = new CheckPosition(discount, new Product(10));
                Assert.AreSame(discount, checkPosition.DiscountBase);
                break;
            }
            }
        }
Example #27
0
        private static int CheckOtherSituation(int relativePosition, int[] position, Checker checker)
        {
            var key = new CheckPosition();

            switch (relativePosition)
            {
            case 0:
                key.Position = new[] { position[0] - 1, position[1] };
                break;

            case 1:
                key.Position = new[] { position[0], position[1] + 1 };
                break;

            case 2:
                key.Position = new[] { position[0] + 1, position[1] };
                break;

            case 3:
                key.Position = new[] { position[0], position[1] - 1 };
                break;
            }
            return(checker.Checks[key][4]);
        }
Example #28
0
        public Checker GenerateEmptyChecker()
        {
            var checker = new Checker();
            var dic     = new Dictionary <CheckPosition, int[]>();

            for (var i = 1; i < 11; i++)
            {
                for (var j = 1; j < 11; j++)
                {
                    var position = new[] { i, j };
                    var value    = new int[5];
                    if (i == 1)
                    {
                        value[0] = 2;
                    }
                    if (i == 10)
                    {
                        value[2] = 2;
                    }
                    if (j == 1)
                    {
                        value[3] = 2;
                    }
                    if (j == 10)
                    {
                        value[1] = 2;
                    }
                    var key = new CheckPosition {
                        Position = position
                    };
                    dic.Add(key, value);
                }
            }
            checker.Checks = dic;
            return(checker);
        }
Example #29
0
        protected override DrawableHitObject CreateNestedHitObject(HitObject hitObject)
        {
            switch (hitObject)
            {
            case CatchHitObject catchObject:
                return(createDrawableRepresentation?.Invoke(catchObject)?.With(o =>
                                                                               ((DrawableCatchHitObject)o).CheckPosition = p => CheckPosition?.Invoke(p) ?? false));
            }

            throw new ArgumentException($"{nameof(hitObject)} must be of type {nameof(CatchHitObject)}.");
        }
Example #30
0
    //------------------------------------------------------------------------------------------------------------------
    public static void TRACK_TARGET(txUIObject obj, float speed, txUIObject target, TrackDoneCallback doneCallback, CheckPosition checkPosition)
    {
        CommandWindowTrackTarget cmd = mCommandSystem.newCmd <CommandWindowTrackTarget>(false);

        cmd.mObject        = target;
        cmd.mSpeed         = speed;
        cmd.mDoneCallback  = doneCallback;
        cmd.mCheckPosition = checkPosition;
        mCommandSystem.pushCommand(cmd, obj);
    }