Esempio n. 1
0
        public void GetCellNeighbors_CoordinatesOfTheCell_ShouldReturnCellNeighbors(int x, int y, int quantityOfNeighbors)
        {
            var cell = new Cell(x, y);
            var actualQuantityOfEntities = CellContainer.GetNeighbors(cell).Count;

            Assert.Equal(quantityOfNeighbors, actualQuantityOfEntities);
        }
Esempio n. 2
0
        public void GetNorthWestCell_CoordinatesOfTheCell_ShouldReturnNullNorthEastCell()
        {
            var cell          = new Cell(0, 69);
            var northEastCell = CellContainer.GetNorthWestCell(cell);

            Assert.Null(northEastCell);
        }
Esempio n. 3
0
 void HandleActivated(object sender, EventArgs e)
 {
     if (cellView.Editable && !cellView.RaiseToggled() && cellView.ActiveField != null)
     {
         CellContainer.SetValue(cellView.ActiveField, State != NSCellStateValue.Off);
     }
 }
Esempio n. 4
0
        public void GetSouthEastCell_CoordinatesOfTheCell_ShouldReturnNullSouthEastCell()
        {
            var cell          = new Cell(24, 69);
            var southEastCell = CellContainer.GetSouthEastCell(cell);

            Assert.Null(southEastCell);
        }
Esempio n. 5
0
        public void GetEastCell_CoordinatesOfTheCell_ShouldReturnNullEastCell()
        {
            var cell     = new Cell(1, 69);
            var eastCell = CellContainer.GetEastCell(cell);

            Assert.Null(eastCell);
        }
Esempio n. 6
0
        public void GetWestCell_CoordinatesOfTheCell_ShouldReturnNullWestCell()
        {
            var cell     = new Cell(1, 0);
            var westCell = CellContainer.GetWestCell(cell);

            Assert.Null(westCell);
        }
Esempio n. 7
0
    public static Cell[] GenerateReserveUp(GameObject parent,
                                           LevelDescription level, SaveData saveData = null)
    {
        int[] reserve = level.GetUpReserve();

        if (reserve == null)
        {
            return(null);
        }
        Cell[] upReserve = new Cell[level.W];
        for (int i = 0; i < level.W; i++)
        {
            int count = reserve[i];
            if (saveData != null)
            {
                count = saveData.MapContainerUp[i];
            }
            CellContainer cell = InstantiateCell(parent, containerPrefab, new Vector2Int(i, level.H), new Vector2((i + 1), level.H)) as CellContainer;
            upReserve[i] = cell;
            for (int k = 0; k < count; k++)
            {
                InstantiateStone(cell, stonePrefab);
            }
        }
        return(upReserve);
    }
Esempio n. 8
0
    public static Cell[] GenerateReserveLeft(GameObject parent,
                                             LevelDescription level, SaveData saveData = null)
    {
        int[] reserve = level.GetLeftReserve();
        if (reserve == null)
        {
            return(null);
        }
        Cell[] leftReserve = new Cell[level.H];

        for (int j = 0; j < level.H; j++)
        {
            int count = reserve[j];
            if (saveData != null)
            {
                count = saveData.MapContainerLeft[j];
            }
            CellContainer cell = InstantiateCell(parent, containerPrefab, new Vector2Int(-1, j), new Vector2((0), j)) as CellContainer;
            leftReserve[j] = cell;
            for (int k = 0; k < count; k++)
            {
                InstantiateStone(cell, stonePrefab);
            }
        }

        return(leftReserve);
    }
Esempio n. 9
0
        public void GetPreyCellNeighbors_CoordinatesOfTheCell_ShouldReturnPreyCellNeighbors(int x, int y)
        {
            var cell           = new Cell(x, y);
            var expectedResult = CellContainer.GetNeighbors(cell).Where(c => c.GetType().Name == "Prey").ToList().Count;
            var actualResult   = CellContainer.GetPreyNeighborCells(cell).Count;

            Assert.Equal(expectedResult, actualResult);
        }
Esempio n. 10
0
        public void GetNorthEastCell_CoordinatesOfTheCell_ShouldReturnNorthEastCell()
        {
            var cell          = new Cell(1, 1);
            var northEastCell = CellContainer.GetNorthEastCell(cell);

            Assert.Equal(cell.X - 1, northEastCell.X);
            Assert.Equal(cell.Y + 1, northEastCell.Y);
        }
Esempio n. 11
0
        public void GetSouthCell_CoordinatesOfTheCell_ShouldReturnSouthCell()
        {
            var cell  = new Cell(1, 1);
            var south = CellContainer.GetSouthCell(cell);

            Assert.Equal(cell.X + 1, south.X);
            Assert.Equal(cell.Y, south.Y);
        }
Esempio n. 12
0
        public void GetWestCell_CoordinatesOfTheCell_ShouldReturnWestCell()
        {
            var cell     = new Cell(1, 1);
            var westCell = CellContainer.GetWestCell(cell);

            Assert.Equal(cell.X, westCell.X);
            Assert.Equal(cell.Y - 1, westCell.Y);
        }
Esempio n. 13
0
        /// <summary>
        /// Moves content from <see cref="Content"/> into cells.
        /// </summary>
        private void layoutContent()
        {
            if (cellContent.IsValid)
            {
                return;
            }

            int requiredRows    = Content?.Length ?? 0;
            int requiredColumns = requiredRows == 0 ? 0 : Content.Max(c => c?.Length ?? 0);

            // Clear cell containers without disposing, as the content might be reused
            foreach (var cell in cells)
            {
                cell.Clear(false);
            }

            // It's easier to just re-construct the cell containers instead of resizing
            // If this becomes a bottleneck we can transition to using lists, but this keeps the structure clean...
            ClearInternal();
            cellLayout.Invalidate();

            // Create the new cell containers and add content
            cells = new CellContainer[requiredRows, requiredColumns];
            for (int r = 0; r < cellRows; r++)
            {
                for (int c = 0; c < cellColumns; c++)
                {
                    // Add cell
                    cells[r, c] = new CellContainer();

                    // Allow empty rows
                    if (Content[r] == null)
                    {
                        continue;
                    }

                    // Allow non-square grids
                    if (c >= Content[r].Length)
                    {
                        continue;
                    }

                    // Allow empty cells
                    if (Content[r][c] == null)
                    {
                        continue;
                    }

                    // Add content
                    cells[r, c].Add(Content[r][c]);
                    cells[r, c].Depth = Content[r][c].Depth;

                    AddInternal(cells[r, c]);
                }
            }

            cellContent.Validate();
        }
Esempio n. 14
0
        public void Indexer_ReturnCorrectCell(int x, int y, int skip)
        {
            _container = new FakeCellContainer(3, 3);
            var point = new Point(x, y);
            var cell = new Cell { Location = new Point(x, y) };
            var expected = _container.Skip(skip).Take(1).Single();

            Assert.That(_container[cell], Is.SameAs(expected));
        }
Esempio n. 15
0
        public void GetCellAt_CoordinatesOfTheCell_ShouldReturnCell(int x, int y)
        {
            var cell = CellContainer.GetCellAt(x, y);

            Assert.NotNull(cell);
            Assert.Equal(x, cell.X);
            Assert.Equal(y, cell.Y);
            //Assert.True(x == cell.X, $"X coordinate {x} in cell incorrect {cell.X}");
            //Assert.True(y == cell.Y, $"Y coordinate {y} in cell incorrect {cell.Y}");
        }
Esempio n. 16
0
 public static void SetPrefabs(Cell cellPref, Stone stonePref, CellContainer containerPref, CellPit cellPitPref, Cell cellSolvePartPref, CellPit cellPitSolvePartPref)
 {
     cellSolvePartPrefab    = cellSolvePartPref;
     cellPitSolvePartPrefab = cellPitSolvePartPref;
     cellPrefab             = cellPref;
     stonePrefab            = stonePref;
     containerPrefab        = containerPref;
     cellPit          = cellPitPref;
     Stone.PrefabSize = stonePref.GetComponent <RectTransform>().rect.size;
 }
Esempio n. 17
0
        public void Constructor_InitializeCellsMethodIsCalled_WhenCellContainerCreated()
        {
            _container = new FakeCellContainer(32, 57,
                cell => {
                    cell.Type = XType.StairsDown;
                });

            Assert.That(_container, Has.All
                .With.Property(nameof(Cell.Type))
                .EqualTo(XType.StairsDown));
        }
		void HandleActivated (object sender, EventArgs e)
		{
			var cellView = Frontend;
			CellContainer.SetCurrentEventRow ();
			if (cellView.Editable && !cellView.RaiseToggled () && (cellView.StateField != null || cellView.ActiveField != null)) {
				if (cellView.StateField != null)
					CellContainer.SetValue (cellView.StateField, State.ToXwtState ());
				else if (cellView.ActiveField != null)
					CellContainer.SetValue (cellView.ActiveField, State != NSCellStateValue.Off);
			}
		}
Esempio n. 19
0
        void HandleActivated(object sender, EventArgs e)
        {
            Backend.Load(this);
            var cellView = Frontend;

            CellContainer.SetCurrentEventRow();
            if (!cellView.RaiseToggled())
            {
                if (cellView.ActiveField != null)
                {
                    CellContainer.SetValue(cellView.ActiveField, true);
                }
            }
        }
Esempio n. 20
0
        public void GetQuantityOfEntities_QuantityOfEntities_ShouldInitializeQuantityOfEntitiesInOcean(string typeOfEntity, int expectedQuantity)
        {
            var actualQuantity = 0;
            var oceanField     = CellContainer.InitializeField();

            for (int i = 0; i < MaxRows; i++)
            {
                for (int j = 0; j < MaxColumns; j++)
                {
                    if (oceanField[i, j].GetType().Name == typeOfEntity)
                    {
                        actualQuantity++;
                    }
                }
            }
            Assert.Equal(expectedQuantity, actualQuantity);
        }
Esempio n. 21
0
        void HandleActivated(object sender, EventArgs e)
        {
            Backend.Load(this);
            var cellView  = Frontend;
            var nextState = State;                    // store new state internally set by Cocoa

            base.State = cellView.State.ToMacState(); // reset state to previous state from store
            CellContainer.SetCurrentEventRow();
            if (!cellView.RaiseToggled())
            {
                if (cellView.StateField != null)
                {
                    CellContainer.SetValue(cellView.StateField, nextState.ToXwtState());
                }
                else if (cellView.ActiveField != null)
                {
                    CellContainer.SetValue(cellView.ActiveField, nextState != NSCellStateValue.Off);
                }
            }
        }
Esempio n. 22
0
 void HandleActivated(object sender, EventArgs e)
 {
     if (State == NSCellStateValue.On && stateChanging)
     {
         var cellView = Frontend;
         CellContainer.SetCurrentEventRow();
         Frontend.Load(CellContainer);
         if (cellView.Editable && !cellView.RaiseToggled())
         {
             if (cellView.ActiveField != null)
             {
                 CellContainer.SetValue(cellView.ActiveField, State != NSCellStateValue.Off);
             }
         }
         else
         {
             base.State = NSCellStateValue.Off;
         }
     }
     stateChanging = false;
 }
Esempio n. 23
0
 public SheetUnit()
 {
     this.Cells    = new CellContainer();
     this.Pictures = new PictureContainer();
 }
Esempio n. 24
0
        public void InitializeOcean_ShouldInitializeOceanField()
        {
            var oceanField = CellContainer.InitializeField();

            Assert.NotNull(oceanField);
        }
Esempio n. 25
0
        public void Bounds_AreCorrect(int w, int h)
        {
            _container = new FakeCellContainer(w, h);

            Assert.That(_container.Bounds, Is.EqualTo(new Rectangle(0, 0, w, h)));
        }
Esempio n. 26
0
 public void SetUp()
 {
     _container = new FakeCellContainer(11, 15);
 }
Esempio n. 27
0
        public void GetCellAt_CoordinatesOfTheCell_ShouldReturnNullCell(int x, int y)
        {
            var cell = CellContainer.GetCellAt(x, y);

            Assert.Null(cell);
        }