private void SetNeighborMovable()
        {
            List <GameObject> neighbors = slotGridItemMover.GetNeighbors();

            foreach (GameObject neighbor in neighbors)
            {
                PieceDestinationController currentNeighborPieceDestinationController = neighbor.GetComponent <PieceDestinationController>();
                currentNeighborPieceDestinationController.SetMovable();
            }
        }
예제 #2
0
        public void FindGridItemNeighbor()
        {
            grid = CreateSlotGrid(3, 3);
            GameObject    currentSlotObject = GetSlotObjectByRowAndColumn(1, 1);
            GridItemMover slotGridItemMover = currentSlotObject.GetComponent <GridItemMover>();

            //List<GameObject> neighBors = grid.GetItemNeighbors(slotGridItemMover);
            List <GameObject> neighBors = slotGridItemMover.GetNeighbors();

            Assert.AreEqual(4, neighBors.Count);
        }
        public void NeigborOfSlotDifferentThanAGivenSlotTurnFixed()
        {
            Game.Grid                  grid                     = CreateSlotGrid();
            GameObject                 slotObject               = GetEmptySlotObjectFromGrid(grid);
            GridItemMover              slotMover                = slotObject.GetComponent <GridItemMover>();
            List <GameObject>          slotNeighbors            = slotMover.GetNeighbors();
            GameObject                 givenSlot                = slotNeighbors[0];
            SlotSelectionServer        givenSlotSelectionServer = givenSlot.GetComponent <SlotSelectionServer>();
            PieceDestinationController slot                     = slotObject.GetComponent <PieceDestinationController>();

            slot.TurnFixedAllNeighborButOne(givenSlotSelectionServer);
            TestNeighborsAreFixedButGivenOne(slotNeighbors, givenSlotSelectionServer);
        }
        public void WhenEmptySlotReceivePieceItsNeighborShouldTurnFixed()
        {
            Game.Grid         grid              = CreateSlotGrid();
            GameObject        emptySlotObject   = GetEmptySlotObjectFromGrid(grid);
            GameObject        movableSlotObject = GetNeighborOfSlot(emptySlotObject);
            GridItemMover     slotMover         = emptySlotObject.GetComponent <GridItemMover>();
            List <GameObject> slotNeighbors     = slotMover.GetNeighbors();
            Slot emptySlot   = emptySlotObject.GetComponent <Slot>();
            Slot movableSlot = movableSlotObject.GetComponent <Slot>();
            SlotSelectionServer        givenSlotSelectionServer              = movableSlotObject.GetComponent <SlotSelectionServer>();
            PieceDestinationController emptySlotPieceDestinationController   = emptySlotObject.GetComponent <PieceDestinationController>();
            PieceDestinationController movableSlotPieceDestinationController = movableSlotObject.GetComponent <PieceDestinationController>();

            movableSlot.Touch();
            emptySlot.Touch();

            TestNeighborsAreFixedButGivenOne(slotNeighbors, givenSlotSelectionServer);
        }
        private GameObject GetNeighborOfSlot(GameObject slotObject)
        {
            GridItemMover gridItemMover = slotObject.GetComponent <GridItemMover>();

            return(gridItemMover.GetNeighbors()[0]);
        }