Ejemplo n.º 1
0
        public async void OnStateChangedHandler(GridStateEventArgs <Claim> args)
        {
            Console.WriteLine(args.PropertyName); // get the setting that was just changed (paging, sorting,...)


            await GridRef.SetState(args.GridState);
        }
Ejemplo n.º 2
0
        public void GivenSixFigureOsGridReferenceThenCorrectlyConstructed()
        {
            var sut = new GridRef("NM123456");

            Assert.That(sut.SixFigure, Is.EqualTo("NM123456"));
            Assert.That(sut.TenFigure, Is.EqualTo("NM1230045600"));
        }
Ejemplo n.º 3
0
        public void GivenTenFigureIrishGridReferenceThenCorrectlyConstructed()
        {
            var sut = new GridRef("B1234567890");

            Assert.That(sut.SixFigure, Is.EqualTo("B123678"));
            Assert.That(sut.TenFigure, Is.EqualTo("B1234567890"));
        }
Ejemplo n.º 4
0
 private void OnMouseUp()
 {
     isMovable             = false;
     renderer.sortingOrder = 1;
     canvas.sortingOrder   = 1;
     GridRef.ReleaseItem(this);
 }
Ejemplo n.º 5
0
 private void OnMouseDown()
 {
     GridRef.SelectItem(this);
     isMovable             = true;
     renderer.sortingOrder = 99;
     canvas.sortingOrder   = 99;
 }
Ejemplo n.º 6
0
 private void OnMouseDrag()
 {
     if (isMovable && !isMerging)
     {
         GridRef.DragItem(this);
         Vector3 newPos = Camera.main.ScreenToWorldPoint(Input.mousePosition);
         newPos = new Vector2(Mathf.Clamp(newPos.x, (-grid.Width + grid.ItemWidth) / 2.0f, (grid.Width - grid.ItemWidth) / 2.0f),
                              Mathf.Clamp(newPos.y, (-grid.Height + grid.ItemWidth) / 2.0f, (grid.Height - grid.ItemWidth) / 2.0f));
         transform.position = newPos;
     }
 }
Ejemplo n.º 7
0
            public int CompareTo(object obj)
            {
                if (obj == null)
                {
                    return(1);
                }
                GridRef otherGridRef = obj as GridRef;
                var     xMatches     = otherGridRef.x == this.x;
                var     zMatchex     = otherGridRef.z == this.z;

                return(xMatches && zMatchex ? 1 : 0);
            }
Ejemplo n.º 8
0
        public GridRef GetOffsetGridRef(ExitDirections direction)
        {
            //Generate grid reference
            GridRef[] positionOffsets = new GridRef[] {
                new GridRef(0, 1),  //Y = N
                new GridRef(1, 0),  //X = E
                new GridRef(0, -1), //-Y = S
                new GridRef(-1, 0)  //-X = W
            };

            return(new Place.GridRef(
                       PlaceGridRef.x + positionOffsets[(int)direction].x,
                       PlaceGridRef.y + positionOffsets[(int)direction].y
                       ));
        }
Ejemplo n.º 9
0
    private IEnumerator MoveCoroutine(int newX, int newY, float time, bool merge)
    {
        gridIndex.X = newX;
        gridIndex.Y = newY;
        gridIndex.ChangeName();

        Vector3 startPos = transform.localPosition;
        Vector3 endPos   = GridRef.GetWorldPosition(newX, newY);

        for (float t = 0; t <= 1 * time; t += Time.deltaTime)
        {
            transform.localPosition = Vector3.Lerp(startPos, endPos, t / time);
            yield return(0);
        }
        transform.localPosition = endPos;
        if (merge)
        {
            Destroy(transform.gameObject);
        }
    }
Ejemplo n.º 10
0
        public void Play()
        {
            char playAgainResponse;

            do
            {
                // Setup grid
                grid.SetUp();

                // Place ships
                grid.AddShip(new Battleship());
                grid.AddShip(new Destroyer());
                grid.AddShip(new Destroyer());

                while (grid.ShipsRemaining > 0)
                {
                    grid.PrintGridForPlayer();
                    Console.WriteLine("Enter grid reference to fire at: ");

                    string input = Console.ReadLine();

                    if (input == CheatCodes.REVEAL_GRID)
                    {
                        grid.PrintActualGrid();
                        continue;
                    }

                    if (input == CheatCodes.GIVE_UP)
                    {
                        break;
                    }

                    Point?chosenPoint = GridRef.GridRefToPoint(input);
                    if (chosenPoint == null)
                    {
                        Console.WriteLine("Please enter a valid point. It should be a letter directly followed by a number i.e. A1.");
                        continue;
                    }

                    Point point = (Point)chosenPoint;

                    if (!grid.IsPointValid(point))
                    {
                        Console.WriteLine("That point is outside the bounds of the grid");
                        continue;
                    }

                    string fireString = grid.Fire(point);
                    Console.WriteLine(fireString);
                }

                grid.PrintActualGrid();

                Console.WriteLine("Game Over");

                do
                {
                    Console.WriteLine();
                    Console.WriteLine("Play again? [y/n]: ");
                    playAgainResponse = char.ToUpper(Console.ReadKey().KeyChar);
                }while (playAgainResponse != 'Y' && playAgainResponse != 'N');
            } while (playAgainResponse == 'Y');
        }
Ejemplo n.º 11
0
            public int CompareTo(object obj)
            {
                GridRef otherGridRef = obj as GridRef;

                return(otherGridRef.x - this.x + otherGridRef.y - this.y);
            }
Ejemplo n.º 12
0
 public bool GivenStringReturnsIsValidCorrectly(string input)
 {
     return(GridRef.IsValid(input));
 }
Ejemplo n.º 13
0
 void OnMouseDown()
 {
     GridRef.MouseDownHandler(this);
 }
Ejemplo n.º 14
0
 void OnMouseEnter()
 {
     GridRef.MouseEnterHandler(this);
 }
Ejemplo n.º 15
0
 public ActionGenerateRolls(GridChainRef gridChain, DiceRef dice, GridRef grid)
 {
     _gridChain = gridChain;
     _dice      = dice;
     _grid      = grid;
 }
        public override string ToString()
        {
            var above = GridRef.IsValid(KeyCol) ? "col" : KeyCol;

            return($"{base.ToString()} above {above} ({KeyColHeight})");
        }