private void SetupGameBoard(GameBoardComponent gameBoard) { game.SetGameData(null, new List <GameEntity>(), new List <GameEntity>(), new List <GameEntity>()); var cards = this.game.cardCache.value; cards.Shuffle(); int index = 0; for (int i = 0; i < gameBoard.slotDefs.Count; i++) { var tSD = gameBoard.slotDefs[i]; var e = cards[index]; e.AddCardState(CardState.tableau); e.AddCardProspector(tSD.id, tSD); e.AddFaceUp(tSD.faceUp); e.AddPosition(new Vector3( gameBoard.multiplier.x * tSD.x, gameBoard.multiplier.y * tSD.y, -tSD.layerID )); e.ReplaceSortOrder(0); game.gameData.tableau.Add(e); index++; } foreach (var card in game.gameData.tableau) { var tSD = card.cardProspector.slotDef; var hidden = new List <GameEntity>(); foreach (var c in game.gameData.tableau) { if (tSD.hiddenBy.Contains(c.cardProspector.layoutID)) { hidden.Add(c); } } card.AddHiddenBy(hidden); } game.MoveToTarget(cards[index]); index++; for (; index < cards.Count; index++) { game.gameData.drawPile.Add(cards[index]); } game.UpdateDrawPile(); }
/// <summary> /// 移动当前牌到弃牌堆 /// </summary> /// <param name="game">Game.</param> /// <param name="e">E.</param> public static void MoveToDiscard(this GameContext game, GameEntity e) { GameBoardComponent gameBoard = game.gameBoard; e.ReplaceCardProspector(gameBoard.discardPile.id, gameBoard.discardPile); e.ReplaceCardState(CardState.discard); e.ReplaceFaceUp(true); e.ReplacePosition(new Vector3( gameBoard.discardPile.x * gameBoard.multiplier.x, gameBoard.discardPile.y * gameBoard.multiplier.y, -gameBoard.discardPile.layerID + 0.5f )); e.ReplaceSortOrder(-100 + game.gameData.discardPile.Count); game.gameData.discardPile.Add(e); }
public static void SetTableauFaces(this GameContext game) { GameBoardComponent gameBoard = game.gameBoard; foreach (var card in game.gameData.tableau) { var hiddenBy = card.hiddenBy.hiddenBy; var faceUp = true; foreach (var item in hiddenBy) { if (item.cardState.value == CardState.tableau) { faceUp = false; } } card.ReplaceFaceUp(faceUp); } }
public static void UpdateDrawPile(this GameContext game) { GameBoardComponent gameBoard = game.gameBoard; for (int i = 0; i < game.gameData.drawPile.Count; i++) { var e = game.gameData.drawPile[i]; e.ReplaceCardProspector(gameBoard.drawPile.id, gameBoard.drawPile); e.ReplaceFaceUp(false); e.ReplaceCardState(CardState.drawpile); e.ReplacePosition(new Vector3( (gameBoard.drawPile.x + i * gameBoard.drawPile.stagger.x) * gameBoard.multiplier.x, (gameBoard.drawPile.y + i * gameBoard.drawPile.stagger.y) * gameBoard.multiplier.y, -gameBoard.discardPile.layerID + 0.1f * i )); e.ReplaceSortOrder(-10 * i); } }
/// <summary> /// 使 e 成为新的目标牌 /// </summary> /// <param name="game">Game.</param> /// <param name="e">E.</param> public static void MoveToTarget(this GameContext game, GameEntity e) { GameBoardComponent gameBoard = game.gameBoard; if (game.gameData.target != null) { game.MoveToDiscard(game.gameData.target); } game.gameData.target = e; e.ReplaceCardProspector(gameBoard.discardPile.id, gameBoard.discardPile); e.ReplaceCardState(CardState.target); e.ReplaceFaceUp(true); e.ReplacePosition(new Vector3( gameBoard.discardPile.x * gameBoard.multiplier.x, gameBoard.discardPile.y * gameBoard.multiplier.y, -gameBoard.discardPile.layerID )); e.ReplaceSortOrder(0); }