private void ShowRandomSentence() { LocalizedText text = null; if ((DataManager.instance.customSentencesAllowed && mode.allowCustomSentencesCard) && //The configurations allow custom sentences (counterToCustomSentenceInsteadOfRandom <= 0) && //It is time to show a custom sentence (DataManager.instance.sortedCustomSentences.Count > 0) && //There are custom sentences created (DataManager.instance.numOfCustomSentencesAlreadyShown < DataManager.instance.sortedCustomSentences.Count)) //Do not repeat custom sentences { text = LocalizedText.GetRandomTextWithIdStartingWith(Utils.beginingOfCustomSentenceId, true, false, DataManager.instance.customSentences); counterToCustomSentenceInsteadOfRandom = Utils.NumberOfRandomSentenceToCustomSentence; DataManager.instance.numOfCustomSentencesAlreadyShown++; } else if (DataManager.instance.randomSentencesAllowed && mode.allowRandomSentencesCard) { text = LocalizedText.GetRandomTextWithIdStartingWith(Utils.beginingOfRandomSentenceId, true, true, LocalizationManager.instance.localizedTexts); counterToCustomSentenceInsteadOfRandom--; } if (text != null) { GUIManager.instance.ShowRandomCard(text); } }
//If you want to do a next turn you must execute "NextTurn()" or "GameManager.instance.NextTurn()". private new bool _NextTurn() //Use to perform action in each "nex turn" call { if (!base._NextTurn()) { return(false); //Mandatory } LocalizedText localizedText = LocalizedText.GetRandomTextWithIdStartingWith(mode.SentenceIdBeggining, true, true, LocalizationManager.instance.localizedTexts); string text = localizedText.getTextAddingTimestamp(); if (text.StartsWith(Utils.indicatorOfSentenceAddedByUser)) { var splittedText = text.Split(new string[] { Utils.indicatorOfSentenceAddedByUser }, StringSplitOptions.None); text = ""; for (int i = 0; i < splittedText.Length; i++) { if (i > 1) { text += Utils.indicatorOfSentenceAddedByUser; } text += splittedText[i]; } AddedByUserNote.gameObject.SetActive(true); } else { AddedByUserNote.gameObject.SetActive(false); } textZone.text = text; textZoneLocalizer.id = localizedText.id; return(true); }
public void SelectType(VoaTypeOfSentence type) { //Display proper elements gameZone.SetActive(true); nextButton.SetActive(true); gameZoneSelection.SetActive(false); buttonsSelection.SetActive(false); string sentenceIdBeggining = mode.SentenceIdBeggining; switch (type) { case VoaTypeOfSentence.verdad: sentenceIdBeggining += verdadSentenceIdIndicator; break; case VoaTypeOfSentence.atrevimiento: sentenceIdBeggining += atrevimientoSentenceIdIndicator; break; } LocalizedText localizedText = LocalizedText.GetRandomTextWithIdStartingWith(sentenceIdBeggining, true, true, LocalizationManager.instance.localizedTexts); string text = localizedText.getTextAddingTimestamp(); //Activate or deactivat the "added by user" note if (text.StartsWith(Utils.indicatorOfSentenceAddedByUser)) { var splittedTextUserContribution = text.Split(new string[] { Utils.indicatorOfSentenceAddedByUser }, StringSplitOptions.None); text = ""; for (int i = 0; i < splittedTextUserContribution.Length; i++) { if (i > 1) { text += Utils.indicatorOfSentenceAddedByUser; } text += splittedTextUserContribution[i]; } addedByUserNote.gameObject.SetActive(true); } else { addedByUserNote.gameObject.SetActive(false); } //Put player's names in text List <int> PlayerNumbers = new List <int>(); int rndNum = 0; var splittedTextPlayers = text.Split(new string[] { Utils.indicatorOfPlayerNameInSentence }, StringSplitOptions.None); text = ""; for (int i = 0; i < splittedTextPlayers.Length - 1; i++) { do { rndNum = UnityEngine.Random.Range(0, GameManager.instance.GetPlayers().Count); } while (PlayerNumbers.Contains(rndNum)); PlayerNumbers.Add(rndNum); if (i < splittedTextPlayers.Length - 1) { text += splittedTextPlayers[i]; } text += GameManager.instance.GetPlayerNumber(rndNum); } text += splittedTextPlayers[splittedTextPlayers.Length - 1]; textZone.text = text; textZoneLocalizer.id = localizedText.id; }