public IEnumerator TestPawnButtonSpawnsPawn() { GameObject go = new GameObject(); PawnButton button = go.AddComponent <PawnButton>(); button.button = go.AddComponent <Button>(); BoardManager board = BoardManager.Instance; yield return(null); Assert.Null(board.Pieces[3, 5]); board.emptySelectionX = 3; board.emptySelectionZ = 5; board.isWhiteTurn = false; Coin.BlackCoins = 1; button.SpawnAPiece(); Assert.IsInstanceOf(typeof(Pawn), board.Pieces[3, 5]); }
void OnInitPawns(EventDataModel data) { InitPawnsEventDataModel targetData = (InitPawnsEventDataModel)data; if (targetData == null) { return; } if (RestingPawnPrefab == null) { RestingPawnPrefab = Resources.Load <GameObject> (RESTING_PAWN_UI_PREFAB_PATH); } targetData.Pawns.ForEach((Pawn pawn) => { GameObject newUIPrefab = Instantiate <GameObject> (RestingPawnPrefab); newUIPrefab.transform.SetParent(transform); newUIPrefab.transform.localScale = Vector3.one; PawnButton pawnButton = newUIPrefab.GetComponent <PawnButton> (); pawnButton.Init(pawn); }); }