Exemple #1
0
	// Draw a card (fires when the button is clicked).
	public void DrawCard(){
		// A story card exists, can't draw.
		if (activeStoryCard){
			logger.info ("A story card has already been drawn.");

			// Story card hasn't been drawn yet.
		} else {
			logger.info("Drawing a story card...");
			// Draw a story card.
			_storyCard = _storyDeck.Draw();
			GameObject storyCardObj = null;

			// Discard.
			_discardPileStory.Discard(_storyCard);


			//Out of Cards reshuffle
			if(_storyDeck.GetSize() == 0){
				logger.info("The check has ran out, reshuffling the deck!");
				_storyDeck = _discardPileStory;
				_discardPileStory = new Deck ("");
			}

			// Load the card sprite.
			Sprite storySprite = Resources.Load<Sprite>(_storyCard.asset);

			// A quest card has been drawn.
			if (_storyCard.GetType() == typeof(QuestCard)) {
				logger.info("A quest card was drawn: " + _storyCard.name);
				storyCardObj = Instantiate(QuestCard);
				_questBehaviour.setCurrentTurn(_currentPlayer);
				_questBehaviour.setCard(_storyCard);
				// A tournament card been drawn.
			} else if (_storyCard.GetType() == typeof(TournamentCard)) {
				logger.info("A tournament card was drawn: " + _storyCard.name);
				storyCardObj = Instantiate(TournamentCard);
				_tournamentBehaviour.setCurrentTurn(_currentPlayer);
				_tournamentBehaviour.setCard(_storyCard);
				// A event card has been drawn.
			} else if (_storyCard.GetType() == typeof(EventCard)) {
				logger.info("A event card was drawn: " + _storyCard.name);
				storyCardObj = Instantiate(EventCard);
				_eventBehaviour.setCurrentTurn(_currentPlayer);
				_eventBehaviour.setCard(_storyCard);
			}

			// Update the card.
			storyCardObj.gameObject.GetComponent<Image>().sprite = storySprite;
			storyCardObj.transform.SetParent(drawCardArea.transform);

			// Indicate a story card is in play.
			activeStoryCard = true;

			// Clear the prompt.
			Prompt.PromptManager.statusPrompt("");

			// Auto end the turn to prompt.
			EndTurn();
		}
	}