wasdswag

WordsDictionary

Jun 15th, 2021
804
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. using System.Collections.Generic;
  2. using UnityEngine;
  3.  
  4. [CreateAssetMenu(fileName = "Dictionary", menuName = "Dictionary")]
  5. public class WordDictionary : ScriptableObject
  6. {
  7.  
  8.     public LayerStructure[] Layers;
  9.  
  10.     public List<Dictionary<string, string[]>> Layer = new List<Dictionary<string, string[]>>();
  11.  
  12.  
  13.     public void Init()
  14.     {
  15.         Layer.Clear();
  16.         foreach (var layer in Layers)
  17.         {
  18.             layer.FillDictionary();
  19.             Layer.Add(layer.Words);
  20.         }
  21.  
  22.     }
  23.  
  24.  
  25.     [System.Serializable]
  26.     public struct LayerStructure
  27.     {
  28.         public WordStructure[] Vocabular;
  29.         public Dictionary<string, string[]> Words;
  30.  
  31.         public Dictionary<string, string[]> FillDictionary()
  32.         {
  33.             Words = new Dictionary<string, string[]>();
  34.             foreach (var word in Vocabular) Words.Add(word.Key, word.Words);
  35.             return Words;
  36.         }
  37.     }
  38.  
  39.     [System.Serializable]
  40.     public struct WordStructure
  41.     {
  42.         public string Key;
  43.         public string[] Words;
  44.     }
  45.  
  46.  
  47. }
RAW Paste Data