public PlayerHandController(OldHandState hand, GameObject rockPrefab, GameObject paperPrefab, GameObject scissorsPrefab, GameObject cardBack, GameObject star) { Hand = hand; StarPrefab = star; BackgroundPrefab = cardBack; RockPrefab = rockPrefab; PaperPrefab = paperPrefab; ScissorsPrefab = scissorsPrefab; }
public OldMatchController(GamePrefabs prefabs, GlobalInventoryModel globalInventory, OldHandState playerHand, OldHandState opponentHand, MatchStyleOld style, MatchStyleOptions options) { this.CurrentStyle = style; this.MatchOptions = options; this.globalInventory = globalInventory; this.prefabs = prefabs; this.Player = new PlayerHandController( playerHand, prefabs.PlayerRockCardPrefab, prefabs.PlayerPaperCardPrefab, prefabs.PlayerScissorsCardPrefab, prefabs.CardBackground, prefabs.StarPrefab); this.Opponent = new OpponentHandController( opponentHand, prefabs.OpponentRockCardPrefab, prefabs.OpponentPaperCardPrefab, prefabs.OpponentScissorsCardPrefab, prefabs.CardBackground, prefabs.StarPrefab); this.Player.GenerateCards(prefabs.PlayerCardRootObject, new UnityEngine.Vector3(-7.25f, -2.5f, 0f), HandControllerBase.HandLayout.RightToLeft); this.Opponent.GenerateCards(prefabs.OpponentCardRootObject, new UnityEngine.Vector3(4.6f, -2.2f, 0f), HandControllerBase.HandLayout.LeftToRight); this.Player.GenerateStars(prefabs.PlayerStarRootObject, new Vector3(-3.15f, -5.45f, 0f)); this.Opponent.GenerateStars(prefabs.OpponentStarRootObject, new Vector3(3.25f, -5.45f, 0f)); this.Player.CardChosenEvent += OnPlayerCardChosen; this.Opponent.CardChosenEvent += OnOpponentCardChosen; }
public void SimulateOpponentMatch(OldMatchController.MatchStyleOld style, OldMatchController.MatchStyleOptions options, OldHandState first, OldHandState second) { switch (style) { case OldMatchController.MatchStyleOld.AllCards: break; case OldMatchController.MatchStyleOld.Rounds: for (int i = 0; i < options.RoundCount; i++) { if (first.Cards.HasCards == false || second.Cards.HasCards == false) { break; } var firstCard = first.Cards.PickRandom(random); var secondCard = second.Cards.PickRandom(random); if (firstCard == secondCard) { continue; } if (firstCard == CardType.Rock) { if (secondCard == CardType.Paper) { first.Stars--; second.Stars++; } else { first.Stars++; second.Stars--; } } if (firstCard == CardType.Paper) { if (secondCard == CardType.Scissors) { first.Stars--; second.Stars++; } else { first.Stars++; second.Stars--; } } if (firstCard == CardType.Scissors) { if (secondCard == CardType.Rock) { first.Stars--; second.Stars++; } else { first.Stars++; second.Stars--; } } if (first.Stars == 0 || second.Stars == 0) { break; } } break; } }