// Draws number of cards needed for the player / street public void DrawCards(int numberOfCards) { for (int i = 0; i < numberOfCards; i++) { Card newCard = new Card(_deck); _deck.Add(newCard); Street.Add(newCard); } }
// Draws number of cards needed for the player / street public void DrawCards(int numberOfCards) { for (int i = 0; i < numberOfCards; i++) { Card newCard = new Card(_deck); _deck.Add(newCard); Street.Add(newCard); foreach (Player player in Players) { player.Cards.Add(newCard); } } }
private void GenerateRoadTile(Vector3 _pos, Quaternion _rot, RectTransform rt, Street _street, float _size = 1f, bool _toLeft = true, int _possibleCorner = 0, bool _loneRoad = false) { var _isThatEnd = false; string endReason = ""; if (!CheckStartingPointsToThis(_pos)) { _isThatEnd = true; endReason = "end"; } var newRoadChunk = roadChunks[0]; newRoadChunk.name = "street" + _street.Name + " - " + (_street.RoadChunks.Count + 1); var rChunk = Instantiate(newRoadChunk, _pos, _rot, Map.transform); rChunk.RegionColor(CheckStartingPoints(_pos)); rChunk.ended = endReason; rChunk.streetNo = _street.CountNo; float roadscale = Random.Range(5, 9); var oldPos = rChunk.End.position; rChunk.transform.rotation *= Quaternion.Euler(0, 0, Random.Range(-_possibleCorner, _possibleCorner + 1)); var newPos = rChunk.End.position; rChunk.transform.position += newPos - oldPos; float realRoadScale = CheckForwardRoadChunk(rChunk, roadscale); if (realRoadScale == 0 || realRoadScale >= roadscale) { realRoadScale = roadscale; } else if (realRoadScale < roadscale) { realRoadScale += 0.5f; _isThatEnd = true; } rChunk.transform.position += (realRoadScale) * (rChunk.End.position - rChunk.transform.position); rChunk.transform.localScale = new Vector3 (rChunk.transform.localScale.x * _size, rChunk.transform.localScale.y * (realRoadScale), rChunk.transform.localScale.z); rChunk.Length = (rChunk.End.position - rChunk.Begin.position).magnitude; if (_toLeft) { _street.Insert0(rChunk); } else { _street.Add(rChunk); } _rot = rChunk.End.rotation; _pos = rChunk.End.position; if (_isThatEnd || _pos.x < 0 || _pos.y < 0 || _pos.x > width || _pos.y > height) { streetCounter--; if (streetCounter == 0) { GenerateHouses(); } return; } GenerateRoad(_pos, _rot, rt, _street, _toLeft, _possibleCorner, _size, _loneRoad, 0.2f); if (CheckDistance(_pos, _rot * Quaternion.Euler(0, 0, -90) * Vector3.up, 9) == false) { return; } var _newStreet = new Street(); spawnedStreets.Add(_newStreet); _newStreet.Name = streetNo.ToString(); _newStreet.CountNo = streetNo; streetNo++; bool isLeft = false; bool isRight = false; if (Random.Range(0, 10) < 3) { isLeft = true; streetCounter++; GenerateRoad(_pos, _rot * Quaternion.Euler(0, 0, 90), rt, _newStreet, true, _possibleCorner + 2, 1f, _loneRoad, 0.9f); } if (Random.Range(0, 10) < 2) { isRight = true; streetCounter++; GenerateRoad(_pos, _rot * Quaternion.Euler(0, 0, -90), rt, _newStreet, false, _possibleCorner + 2, 1f, _loneRoad, 0.9f); } if (isLeft || isRight) { rChunk.GeneratedStreets.Add(Tuple.Create(rChunk.End.position, _newStreet)); } }
private void NewCards() { Player1Cards.Clear(); Player2Cards.Clear(); Street.Clear(); CardsInPlay.Clear(); AiDrawGuessLabel.Visible = false; AiPlayer1GuessLabel.Visible = false; AiPlayer2GuessLabel.Visible = false; if (RandomPlayerCards) { for (int x = 0; x < 2; x++) { NewCard = new Card(CardsInPlay); CardsInPlay.Add(NewCard); Player1Cards.Add(NewCard); } for (int x = 0; x < 2; x++) { NewCard = new Card(CardsInPlay); CardsInPlay.Add(NewCard); Player2Cards.Add(NewCard); } } else { Player1Cards.Add(new Card(Suit.Hearts, Rank.Ace)); Player1Cards.Add(new Card(Suit.Spades, Rank.Ace)); CardsInPlay.Add(Player1Cards[0]); CardsInPlay.Add(Player1Cards[1]); Player2Cards.Add(new Card(Suit.Diamonds, Rank.Ace)); Player2Cards.Add(new Card(Suit.Diamonds, Rank.King)); CardsInPlay.Add(Player2Cards[0]); CardsInPlay.Add(Player2Cards[1]); } for (int x = 0; x < 5; x++) { NewCard = new Card(CardsInPlay); CardsInPlay.Add(NewCard); Street.Add(NewCard); } foreach (Card card in CardsInPlay) { card.LoadImage(); } Player1pictureBox1.Image = Player1Cards[0].Image; Player1pictureBox2.Image = Player1Cards[1].Image; Player2pictureBox1.Image = Player2Cards[0].Image; Player2pictureBox2.Image = Player2Cards[1].Image; StreetCard1ImageBox.Image = Street[0].Image; StreetCard2ImageBox.Image = Street[1].Image; StreetCard3ImageBox.Image = Street[2].Image; StreetCard4ImageBox.Image = Street[3].Image; StreetCard5ImageBox.Image = Street[4].Image; AiResult = winCalc.WhoWins(Player1Cards.Concat(Street).ToList(), Player2Cards.Concat(Street).ToList()); }