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); }
public void GetNorthWestCell_CoordinatesOfTheCell_ShouldReturnNullNorthEastCell() { var cell = new Cell(0, 69); var northEastCell = CellContainer.GetNorthWestCell(cell); Assert.Null(northEastCell); }
void HandleActivated(object sender, EventArgs e) { if (cellView.Editable && !cellView.RaiseToggled() && cellView.ActiveField != null) { CellContainer.SetValue(cellView.ActiveField, State != NSCellStateValue.Off); } }
public void GetSouthEastCell_CoordinatesOfTheCell_ShouldReturnNullSouthEastCell() { var cell = new Cell(24, 69); var southEastCell = CellContainer.GetSouthEastCell(cell); Assert.Null(southEastCell); }
public void GetEastCell_CoordinatesOfTheCell_ShouldReturnNullEastCell() { var cell = new Cell(1, 69); var eastCell = CellContainer.GetEastCell(cell); Assert.Null(eastCell); }
public void GetWestCell_CoordinatesOfTheCell_ShouldReturnNullWestCell() { var cell = new Cell(1, 0); var westCell = CellContainer.GetWestCell(cell); Assert.Null(westCell); }
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); }
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); }
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); }
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); }
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); }
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); }
/// <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(); }
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)); }
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}"); }
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; }
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); } }
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); } } }
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); }
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); } } }
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; }
public SheetUnit() { this.Cells = new CellContainer(); this.Pictures = new PictureContainer(); }
public void InitializeOcean_ShouldInitializeOceanField() { var oceanField = CellContainer.InitializeField(); Assert.NotNull(oceanField); }
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))); }
public void SetUp() { _container = new FakeCellContainer(11, 15); }
public void GetCellAt_CoordinatesOfTheCell_ShouldReturnNullCell(int x, int y) { var cell = CellContainer.GetCellAt(x, y); Assert.Null(cell); }