// EmptyCell和ItemCell相关操作 public void UpdateBackPackCell(ItemInformation itemInfo, int count) { if (count == 0)//删除道具格子 { } else if (count == 1)//添加道具格子 { if (emptyCellList.Count <= itemCellList.Count) { for (int i = 0; i < cellCountPerRow; i++) { emptyCellList.Add(Instantiate(emptyCellPrefab, gridLayoutGroup.transform)); } UpdateGridLayoutGroupRectSize(); } EmptyCell emptyCell = emptyCellList.Find(targetCell => targetCell.isEmpty); ItemCell itemCell = Instantiate(itemCellPrefab); itemCell.Initialization(this, emptyCell, itemInfo); BindingBackPackCell(emptyCell, itemCell); itemCellList.Add(itemCell); } else if (count > 1)//更新道具数量显示 { ItemCell itemCell = itemCellList.Find(targetCell => targetCell.itemInfo.ID == itemInfo.ID); itemCell.UpdateItemCount(count); } }
public void SetEmpty() { for (var i = 0; i < grid.Length; i++) { grid[i] = new EmptyCell(); } }
public void BeNotEqualToOtherCell() { var first = new EmptyCell(position); var second = new EmptyCell(position + CellPosition.DeltaDown); first.Equals(second).Should().BeFalse(); }
public ICell[,] GenerateBoard(int size, IList <ShipType> ships) { // generate an empty board ... var board = new ICell[size, size]; for (int i = 0; i < size; i++) { for (int j = 0; j < size; j++) { board[i, j] = new EmptyCell(); } } // ...and place ships on it foreach (var ship in ships) { bool placedShip; do { var direction = (Direction)(randomizer.Next() % 2); var a = randomizer.Next(0, size - ship.ShipSize()); var b = randomizer.Next(0, size); var initialPosition = direction == Direction.Horizontal ? new Point(a, b) : new Point(b, a); placedShip = PlaceShip(board, ship, direction, initialPosition); } while (!placedShip); } return(board); }
public EmptyCell GetValueEmptyCell( ) { int v = GetValueInt((int)EmptyCell.BlindsJpn); EmptyCell Ret = EmptyCell.BlindsJpn; switch (v) { case (int)EmptyCell.BlindsJpn: Ret = EmptyCell.BlindsJpn; break; case (int)EmptyCell.BlindsEng: Ret = EmptyCell.BlindsEng; break; case (int)EmptyCell.LastFrame: Ret = EmptyCell.LastFrame; break; case (int)EmptyCell.Opacity: Ret = EmptyCell.Opacity; break; } return(Ret); }
protected override void PostSetup() { if (!this._goal) { this._goal = FindObjectOfType <EmptyCell>(); } if (!this._actor) { this._actor = FindObjectOfType <Actor>(); } if (this._goal) { NeodroidUtilities.RegisterCollisionTriggerCallbacksOnChildren( this, this._goal.transform, null, this.OnTriggerEnterChild, debug: this.Debugging); } if (this._actor) { NeodroidUtilities.RegisterCollisionTriggerCallbacksOnChildren( this, this._actor.transform, null, this.OnTriggerEnterChild, debug: this.Debugging); } }
swf.Control CreateEmptyCell(int x, int y) { var c = new EmptyCell(); c.Margin = GetMargin(x, y); return(c); }
/// <summary> /// Inits cells on the map /// </summary> /// <param name="size">The map size</param> private void InitCells(int size) { if (!CheckSize(size)) { throw new ArgumentOutOfRangeException(); } Cells = new Cell[size, size]; var cards = new Stack <Card>(GenerateAvailableCards(size)); for (var row = 0; row < Cells.GetLength(0); row++) { for (var column = 0; column < Cells.GetLength(1); column++) { if (column % 2 == 0) { Cells[row, column] = cards.Pop(); } else { if (row % 2 == 0) { Cells[row, column] = new Block(); } else { Cells[row, column] = new EmptyCell(); } } } } }
public void Should_Change_Index() { var cell = new EmptyCell(1); cell.SetIndex(3); Assert.True(cell.Index == 3); }
public void TestMinerEmpty() { Piece att = new Miner(Ownership.FirstPlayer); ICell def = new EmptyCell(); Assert.True(att == ConflictHandler.Handle(att, def)); }
public void TestFailOnAttackerFlag_ThrowsPieceConflictHandlerException() { Piece att = new Flag(Ownership.SecondPlayer); ICell def = new EmptyCell(); TestDelegate code = () => ConflictHandler.Handle(att, def); Assert.Throws(typeof(PieceConflictHandlerException), code); }
public void Initialization(BackPack backpack, EmptyCell emptyCell, ItemInformation itemInfo) { this.itemInfo = itemInfo; this.backpack = backpack; this.emptyCell = emptyCell; image.sprite = itemInfo.Sprite; gameObject.name = itemInfo.Name; UpdateItemCount(1); }
public void BeEqualToSameCell() { var first = new EmptyCell(position); var second = new EmptyCell(position); var third = new EmptyCell(position + CellPosition.DeltaDown); first.Equals(second).Should().BeTrue(); first.Equals(third).Should().BeFalse(); }
public void TestEmptyCell() { var emptyCell = new EmptyCell(new Point { X = 1, Y = 1 }); Assert.AreEqual(emptyCell.Name, "EmptyCell"); Assert.IsFalse(emptyCell.Destructible); Assert.IsTrue(emptyCell.Permeability); }
public void OnEndDrag(PointerEventData eventData) { enableDraw = false; enableCheckDistance = false; image.raycastTarget = true; EmptyCell newEmptycCell = UIUnit.GetFirstPickUI <EmptyCell>(eventData.position); backpack.SwapBackPackCell(this, newEmptycCell); }
public void HaveDifferentHashWithDifferentCell() { var first = new EmptyCell(position); var second = new EmptyCell(position + CellPosition.DeltaDown); var firstHash = first.GetHashCode(); var secondHash = second.GetHashCode(); firstHash.Should().NotBe(secondHash); }
public void HaveSameHashWithSameCell() { var first = new EmptyCell(position); var second = new EmptyCell(position); var firstHash = first.GetHashCode(); var secondHash = second.GetHashCode(); firstHash.Should().Be(secondHash); }
private static void DecideFutureOfEmptyCell(EmptyCell emptyCell, int neighbouringAmebaCount) { if (neighbouringAmebaCount == 3) { emptyCell.SpawnAmeba(); } else { emptyCell.Maintain(); } }
internal static IGameboard GenerateFieldWithSizeTwo() { var gameboard = new Gameboard(2); gameboard[0, 0] = new Mine(MineRadius.MineRadiusOne); gameboard[0, 1] = new EmptyCell(); gameboard[0, 1].Explode(); gameboard[1, 0] = new EmptyCell(); gameboard[1, 1] = new EmptyCell(); return(gameboard); }
private void GenerateEmptyField(IGameboard gameboard) { int size = gameboard.Size; for (int row = 0; row < size; row++) { for (int col = 0; col < size; col++) { gameboard[row, col] = new EmptyCell(); } } }
private ICell[,] GenerateEmptyBoard(int size) { var board = new ICell[size, size]; for (int i = 0; i < size; i++) { for (int j = 0; j < size; j++) { board[i, j] = new EmptyCell(); } } return(board); }
public void ConsumedGameElementIsLifeless() { //Given a game element EmptyCell emptyCell = new EmptyCell(); int remainingLife = 0; //When it is consumed by main character of the game emptyCell.MarkAsConsumed(); //Then is should no longer have life (it should not provide //additional value if is being visited second time) Assert.Equal(remainingLife, emptyCell.Life); }
internal static IGameboard GenerateFieldWithSizeTenWithEmptyCells() { var gameboard = new Gameboard(10); for (int i = 0; i < gameboard.Size; i++) { for (int k = 0; k < gameboard.Size; k++) { gameboard[i, k] = new EmptyCell(); } } return(gameboard); }
// Grid renderer. public void RenderGrid() { for (int y = 1; y <= GridArray.GetLength(0); y++) { for (int x = 1; x <= GridArray.GetLength(1); x++) { EmptyCell emptyCell = new EmptyCell(); Console.Write(emptyCell.GetCellFormatter() + " "); } // Write y-axis labels. Console.Write(Convert.ToChar(y + 64) + Environment.NewLine); } }
private void ResetCells() { lCells.Clear(); lSnakeCells.Clear(); int r = Screen.height / Cell.isize - 2; int c = Screen.width / Cell.isize - 2; for (int i = 0; i < r; i++) { lCells.Add(new List <Cell>()); for (int j = 0; j < c; j++) { if (i == 0 || j == 0 || i == r - 1 || j == c - 1) { WallCell wc = new WallCell(); wc.ix = j; wc.iy = i; lCells[i].Add(wc); } else { EmptyCell wc = new EmptyCell(); wc.ix = j; wc.iy = i; lCells[i].Add(wc); } } } for (int i = 0; i < 5; i++) { int ix = 5 + i; int iy = 5; SnakeCell sc = new SnakeCell(); sc.ix = ix; sc.iy = iy; lSnakeCells.Insert(0, sc); lCells[iy][ix] = sc; } RandomOneFood(); bGameOver = false; iDirectX = 1; iDirectY = 0; moveSep = 1; }
public void Should_Draw_Itself_Correctly() { var testStr = "{99}"; var cell = new EmptyCell(1); cell.SetIndex(99); Assert.True(cell.DrawYourselfInTable(testStr) == testStr.ToSpaces()); cell.SetIndex(8); testStr = "{8}"; Assert.True(cell.DrawYourselfInTable(testStr) == testStr.ToSpaces()); }
public override void OnClick(GameObject cell) { Count--; if (Count == 0) { EmptyCell e = null; switch (type) { case (MaterialType.Forrest): e = new EmptyCell(EmptyCell.EmptyCellType.Grass); break; case (MaterialType.Mountain): e = new EmptyCell(EmptyCell.EmptyCellType.Ground); break; } cell.GetComponent<CellContent>().SetEntity(e); } Debug.Log("Tap"); }
override public void OnClick(GameObject cell) { Count--; if (Count == 0) { EmptyCell e = null; switch (type) { case (MaterialType.Forrest): e = new EmptyCell(EmptyCell.EmptyCellType.Grass); break; case (MaterialType.Mountain): e = new EmptyCell(EmptyCell.EmptyCellType.Ground); break; } cell.GetComponent <CellContent>().SetEntity(e); } Debug.Log("Tap"); }
private void BindingBackPackCell(EmptyCell emptyCell, ItemCell itemCell) { if (itemCell != null) { emptyCell.isEmpty = false; emptyCell.itemCell = itemCell; itemCell.emptyCell = emptyCell; itemCell.transform.SetParent(emptyCell.transform); itemCell.transform.localPosition = Vector3.zero; } else { emptyCell.isEmpty = true; emptyCell.itemCell = null; } }
public void DoMove_WhenAllShipsDown_ReturnsGameFinished() { for (int i = 0; i < currentBoard.GetLength(0); i++) { currentBoard[0, i] = new EmptyCell(); } gameEngine.DoMove(new Point(0, 1), 0).Item1 .ShouldBe(MoveResult.Hit); gameEngine.DoMove(new Point(1, 1), 0).Item1 .ShouldBe(MoveResult.Hit); gameEngine.DoMove(new Point(2, 1), 0).Item1 .ShouldBe(MoveResult.Hit); gameEngine.DoMove(new Point(3, 1), 0).Item1 .ShouldBe(MoveResult.PlayerWon); }
public void CellsTestIfEmptyCellIsCloned() { EmptyCell emptyCell = new EmptyCell(); emptyCell.X = 2; emptyCell.Y = 3; emptyCell.Color = Color.White; emptyCell.CellView = CellView.Bomb1; ICell clonedEmptyCell = emptyCell.Clone(); Assert.AreEqual(emptyCell.X, clonedEmptyCell.X, "X coordinate has not cloned."); Assert.AreEqual(emptyCell.Y, clonedEmptyCell.Y, "Y coordinate has not cloned."); Assert.AreEqual(emptyCell.Color, clonedEmptyCell.Color, "Cell Color has not cloned."); Assert.AreEqual(emptyCell.CellView, clonedEmptyCell.CellView, "CellView Color has not cloned."); }
public void CheckIfGenerateFieldMethodSetsACellToAnEmptyOneInsideField() { var testFieldSize = 9; var field = new Field(testFieldSize); field.GenerateField(); var testCell = field.FieldPositions[2, 3]; var testEmptyCell = new EmptyCell(); Assert.AreEqual(testCell.ToString(), testEmptyCell.ToString()); }