Esempio n. 1
0
        public Dictionary <string, DnaSetter> GetDNA(UMAData umaData, IDNAConverter dcb, string[] dbNames)
        {
            Dictionary <string, DnaSetter> dna = new Dictionary <string, DnaSetter>();

            foreach (UMADnaBase db in umaData.GetAllDna())
            {
                string Category = dcb.DisplayValue;

                if (dbNames.Length == 0)
                {
                    Debug.Break();
                }
                for (int i = 0; i < db.Count; i++)
                {
                    if (dna.ContainsKey(dbNames[i]))
                    {
                        dna[db.Names[i]] = new DnaSetter(dbNames[i], db.Values[i], i, db, Category);
                    }
                    else
                    {
                        try
                        {
                            dna.Add(dbNames[i], new DnaSetter(dbNames[i], db.Values[i], i, db, Category));
                        }
                        catch (System.Exception ex)
                        {
                            Debug.LogException(ex);
                        }
                    }
                }
            }
            return(dna);
        }
Esempio n. 2
0
        /// <summary>
        /// Get the DNA. Unlike DynamicCharacterAvatar, this is cached because the character cannot be rebuilt.
        /// </summary>
        /// <param name="recipe"></param>
        /// <returns></returns>
        public Dictionary <string, DnaSetter> GetDNA(UMAData.UMARecipe recipe = null)
        {
            if (dna.Keys.Count == 0)
            {
                UMADnaBase[] dnaBase = umaData.GetAllDna();

                if (recipe == null)
                {
                    dnaBase = umaData.GetAllDna();
                }
                else
                {
                    dnaBase = recipe.GetAllDna();
                }

                foreach (UMADnaBase db in dnaBase)
                {
                    string          Category = db.GetType().ToString();
                    IDNAConverter[] dcb      = originalRace.GetConverters(db);

                    if (dcb.Length > 0 && dcb[0] != null && (!string.IsNullOrEmpty(dcb[0].DisplayValue)))
                    {
                        Category = dcb[0].DisplayValue;
                    }

                    for (int i = 0; i < db.Count; i++)
                    {
                        if (dna.ContainsKey(db.Names[i]))
                        {
                            dna[db.Names[i]] = new DnaSetter(db.Names[i], db.Values[i], i, db, Category);
                        }
                        else
                        {
                            dna.Add(db.Names[i], new DnaSetter(db.Names[i], db.Values[i], i, db, Category));
                        }
                    }
                }
            }
            return(dna);
        }