public void SetDirection(CardManager.Direction dir, bool forceUpdate = true) { direction = dir; if (forceUpdate) { UpdateCard(); } }
public void FlipDirection(bool forceUpdate = true) { direction = (direction == CardManager.Direction.From) ? CardManager.Direction.To : CardManager.Direction.From; if (forceUpdate) { UpdateCard(); } }
/// <summary> /// Looks for cards in LanguageFolder that match the "from" words from the LineString /// </summary> /// <returns>Returns a list of length n being the number of words in LineString with elements being cards that can be put in these locations</returns> List <List <CardIndexer> > BuildWords(CardManager.Direction direction = CardManager.Direction.From) { string[] words = LineString.Split(); //Each wordGroup is made up of cards with wordcount words.Length - i + 1 //Each element keeps track where it starts with CardIndexer HashSet <CardIndexer> cardSet = new HashSet <CardIndexer>(); //Can use a List<List<CardIndexer> to get GetSwipablePhrase and GetBestPhrase which can greatly improve search time //This works provided the conditions for GetSwipablePhrase doesn't ever change (breaking change) //Search for largest words first and add them to list then get smaller words StringBuilder sb = new StringBuilder(); for (int wordSize = words.Length; wordSize > 0; wordSize--) { //The group of all words of the same length within this line //List<CardIndexer> currentGroup = new List<CardIndexer>(); //wordGroups.Add(currentGroup); for (int i = 0; i <= words.Length - wordSize; i++) { //Append all words together for (int j = 0; j < wordSize; j++) { //Concatenate all words into single string to form a key //e.g. "a" "b" "c" --> "a b c" string word = words[i + j]; if (j > 0) { word = " " + word; } sb.Append(word); } string key = sb.ToString(); sb.Clear(); //Get all cards that match that key and create CardIndexers for them var set = CardManager.GetCards(key, direction); //only take cards that are words, not lines/stories/cards var cardIndexerSet = set.Where(x => x.CardType == "CardData").Select(x => new CardIndexer(x, i, wordSize)); cardSet.UnionWith(cardIndexerSet); } } //Populate output [index][n CardData that fits] List <List <CardIndexer> > slots = new List <List <CardIndexer> >(words.Length); for (int i = 0; i < words.Length; i++) { slots.Add(new List <CardIndexer>()); } foreach (CardIndexer cardI in cardSet) { slots[cardI.Index].Add(cardI); } return(slots); }
public void SetCard(LineManager.CardIndexer cardIndexer, CardManager.Direction direction, GameObject uiBlock) { this.cardIndexer = cardIndexer; this.direction = direction; this.uiBlock = uiBlock; uiTextMesh = uiBlock.GetComponentInChildren <TextMeshProUGUI>(); //Format text to fit a sentence CardData card = cardIndexer.Card; name = card.From + "-->" + card.To; }
public void SetCard(LineManager.CardIndexer cardIndexer, CardManager.Direction direction) { this.cardIndexer = cardIndexer; this.direction = direction; CardData card = cardIndexer.Card; name = card.From + "-->" + card.To; //TEMPORARY setting location to somewhere random; CreateHomeLocation(); Vector3 randomSpot = new Vector3(UnityEngine.Random.Range(SpawnRangeX.x, SpawnRangeX.y), UnityEngine.Random.Range(SpawnRangeY.x, SpawnRangeY.y)); HomeLocation.transform.position += randomSpot; }
public void FlipAll() { foreach (Transform t in CardParents) { foreach (LargeCard card in t.GetComponentsInChildren <LargeCard>()) { //Only spin cards that are facing the wrong way if (card.GetDirection() == direction) { card.SpinCard(); } } } //Flip direction direction = (direction == CardManager.Direction.From) ? CardManager.Direction.To : CardManager.Direction.From; }
public void Setup(CardData card, string folder, SerializationManager.SavePathType PathType) { this.PathType = PathType; LanguageFolder = folder; //To Broken up //Direction = CardManager.Direction.To; //Line = card.BrokenUpTo; //To with phrases //Direction = CardManager.Direction.To; //Line = card.To; //From Direction = CardManager.Direction.From; Line = card.From; }