예제 #1
0
 public Personas(DollmasterPlugin dm) : base(dm)
 {
     PERSONA_PATH = DollmasterPlugin.ASSETS_PATH + "/Personas";
     SuperController.singleton.GetDirectoriesAtPath(PERSONA_PATH).ToList().ForEach((string path) =>
     {
         path                    = SuperController.singleton.NormalizePath(path);
         string name             = PathExt.GetFileName(path);
         nameToPersonality[name] = new Personality(path, name);
     });
 }
예제 #2
0
        public NamedAudioClip GetRandomClimaxClip()
        {
            JSONArray climaxes = personaConfig["climaxes"].AsArray;

            if (climaxes.Count == 0)
            {
                return(GetRandomAudioClip());
            }
            int       randomIndex = UnityEngine.Random.Range(0, climaxes.Count);
            JSONClass picked      = climaxes[randomIndex].AsObject;
            string    clipName    = PathExt.GetFileName(picked["audio"].Value);

            return(audioClips.Find((nac) =>
            {
                return nac.displayName == clipName;
            }));
        }
예제 #3
0
        public NamedAudioClip GetTriggeredAudioClip(Arousal arousal)
        {
            if (audioClips.Count == 0)
            {
                return(null);
            }

            if (personaConfig == null)
            {
                return(GetRandomAudioClip());
            }
            else
            {
                float            arousalNormalized = arousal.value / Arousal.SLIDER_MAX;
                JSONArray        expressions       = personaConfig["expressions"].AsArray;
                List <JSONClass> validExpressions  = new List <JSONClass>();
                for (int i = 0; i < expressions.Count; i++)
                {
                    JSONClass expression = expressions[i].AsObject;
                    float     minArousal = expression["minIntensity"].AsFloat;
                    float     maxArousal = expression["maxIntensity"].AsFloat;

                    if (arousalNormalized >= minArousal && arousalNormalized <= maxArousal)
                    {
                        //Debug.Log(arousalNormalized);
                        //Debug.Log(minArousal + " " + maxArousal);
                        validExpressions.Add(expression);
                    }
                }

                if (validExpressions.Count == 0)
                {
                    validExpressions.Add(expressions[0].AsObject);
                }

                int       randomIndex = UnityEngine.Random.Range(0, validExpressions.Count);
                JSONClass picked      = validExpressions[randomIndex].AsObject;
                string    clipName    = PathExt.GetFileName(picked["audio"].Value);
                return(audioClips.Find((nac) =>
                {
                    return nac.displayName == clipName;
                }));
            }
        }
예제 #4
0
        NamedAudioClip GetRandomClipFromCategory(string category)
        {
            if (personaConfig == null)
            {
                return(null);
            }

            if (personaConfig[category] == null)
            {
                return(null);
            }

            JSONArray clipGroup = personaConfig[category].AsArray;

            if (clipGroup == null)
            {
                return(null);
            }

            if (clipGroup.Count == 0)
            {
                return(null);
            }

            Debug.Log(clipGroup.Count);

            int    randomIndex = UnityEngine.Random.Range(0, clipGroup.Count);
            string picked      = clipGroup[randomIndex].Value;

            string clipName = PathExt.GetFileName(picked);

            Debug.Log(clipName);

            return(audioClips.Find((nac) =>
            {
                return nac.displayName == clipName;
            }));
        }
예제 #5
0
        public Montage(Atom atom, string filePath)
        {
            this.atom   = atom;
            montageJSON = JSON.Parse(SuperController.singleton.ReadFileIntoString(filePath)) as JSONClass;
            poses.Add(ExtractPersonPose(montageJSON));

            string fileName    = PathExt.GetFileName(filePath);
            string folder      = filePath.Replace(fileName, "");
            string montageName = PathExt.GetFileNameWithoutExtension(filePath);

            name = montageName;

            List <string> poseFiles = SuperController.singleton.GetFilesAtPath(folder, "*.json").ToList().Where(path =>
            {
                if (path.Contains(montageName) == false)
                {
                    return(false);
                }
                int periodCount = path.Count(f => f == '.');
                if (periodCount <= 1)
                {
                    return(false);
                }
                return(true);
            }).ToList();

            poseFiles.ForEach(poseFilePath =>
            {
                //Debug.Log("pose file found" + poseFilePath);
                var poseMontageJSON = JSON.Parse(SuperController.singleton.ReadFileIntoString(poseFilePath)) as JSONClass;

                poses.Add(ExtractPersonPose(poseMontageJSON));
            });

            //Debug.Log("montage " + filePath + " has " + poses.Count() + " poses");
        }