Ejemplo n.º 1
0
    public void CreatePin(EmotionType type)
    {
        _pin = GameObject.Instantiate(PinPrefab);
        _pin.transform.SetParent(this.transform, false);

        string       ty = type.ToString();
        PinViewModel vm = _pin.GetComponent <PinViewModel>();

        vm.EmotionIcon.sprite = Resources.Load <Sprite>("Sprites/" + type.ToString());

        StartCoroutine(DestroyPin());
    }
Ejemplo n.º 2
0
        /*
         * This method counts questions with a given emotion type
         */
        private static ushort CountByType(List <Answer> answers, EmotionType type)
        {
            List <Answer> filtered = FilterByEmotionType(answers, type);

            Debug.Assert(filtered.Count() > 0, $"Expected quantity of type '{type.ToString("G")}' to be greater then 0.");
            return(Convert.ToUInt16(filtered.Count()));
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Save the current values of the tree as the previous values
        /// </summary>
        public void backupState()
        {
            Console.WriteLine(String.Format("Backing up {0}/{1}", positiveKey.ToString(), negativeKey.ToString()));

            emotionTable[positiveKey][1] = emotionTable[positiveKey][0];
            emotionTable[negativeKey][1] = emotionTable[negativeKey][0];
        }
Ejemplo n.º 4
0
        /// <summary>
        /// get path under which image for emotion is served (or null when no image exists)
        /// </summary>
        /// <param name="emotion">name of emotion</param>
        /// <returns>path to image on server</returns>
        public string GetImagePath(EmotionType emotion)
        {
            string path;

            if (!imagecache.TryGetValue(emotion.ToString().ToLower(), out path))
            {
                string resourcepath = GetType().Namespace + ".Images." + emotion.ToString().ToLower() + ".png";
                if (ResourceAccessor.ContainsResource(GetType().Assembly, resourcepath))
                {
                    path = $"http://localhost/streamrc/image/emotion?name={HttpExtensions.URLEncode(emotion.ToString().ToLower())}";
                }

                imagecache[emotion.ToString().ToLower()] = path;
            }

            return(path);
        }
Ejemplo n.º 5
0
        //		#region IChromosomeProvider implementation
        //
        //		public Chromosome GetChromosome ()
        //		{
        //			var chromosome = new Chromosome ();
        //			int id = 0;
        //			chromosome.Genes.Add (GetGene (id++, "Openness", Openness));
        //			chromosome.Genes.Add (GetGene (id++, "Conscientiousness", Conscientiousness));
        //			chromosome.Genes.Add (GetGene (id++, "Introversion", Introversion));
        //			chromosome.Genes.Add (GetGene (id++, "Agreeableness", Agreeableness));
        //			chromosome.Genes.Add (GetGene (id++, "Neuroticism", Neuroticism));
        //			return chromosome;
        //		}

        //		public void SetChromosome (Chromosome chromosome)
        //		{
        //			Openness = chromosome.Genes.Find (w => w.Name == "Openness").Value;
        //			Conscientiousness = chromosome.Genes.Find (w => w.Name == "Conscientiousness").Value;
        //			Introversion = chromosome.Genes.Find (w => w.Name == "Introversion").Value;
        //			Agreeableness = chromosome.Genes.Find (w => w.Name == "Agreeableness").Value;
        //			Neuroticism = chromosome.Genes.Find (w => w.Name == "Neuroticism").Value;
        //		}
        //
        //		private Gene GetGene (int id, string name, double value)
        //		{
        //			return new Gene { Id = id, Name = name, Value = (float) value, Descriptor = gp };
        //		}
        //
        //		#endregion


        #region "Personality-based Emotion Manipulation Methods"

        /// <summary>
        /// The net intensity of an emotion after applying the effect of all the personality attributes
        /// </summary>
        /// <param name="et">The emotion to be evaluated</param>
        /// <param name="value">The intensity of the emotion</param>
        /// <returns>The net intensity of an emotion after applying all the personality attributes</returns>
        private double NetEmotion(EmotionType et, double emotionalValue)
        {
            ////Console code to validate the effect of personality on emotional effect
            Debug.Log(String.Format("Event was evaluated to have a raw net emotional value of {0}({1}).", et.ToString(), emotionalValue.ToString()));
            Debug.Log(String.Format("Bonuses from personality: Neuroticism ({0}), Introversion ({1}), Openness ({2}), Agreeableness ({3}), Conscientiousness ({4}).",
                                    NeuroticimFactor(et, emotionalValue), IntroversionFactor(et, emotionalValue), OpennessFactor(et, emotionalValue),
                                    AgreeablenessFactor(et, emotionalValue), ConscientiousnessFactor(et, emotionalValue)));
            Debug.Log(String.Format("Net emotion to be applied was {0} ({1}).", et.ToString(), Math.Max(0, emotionalValue + NeuroticimFactor(et, emotionalValue) + IntroversionFactor(et, emotionalValue) +
                                                                                                        OpennessFactor(et, emotionalValue) + AgreeablenessFactor(et, emotionalValue) +
                                                                                                        ConscientiousnessFactor(et, emotionalValue)).ToString()));

            //Apply all the personality factors to work out net emotional value, making sure we never go below 0
            //since a raw increase in emotion should never result in a net decrease
            return(Math.Max(0, emotionalValue + NeuroticimFactor(et, emotionalValue) + IntroversionFactor(et, emotionalValue) +
                            OpennessFactor(et, emotionalValue) + AgreeablenessFactor(et, emotionalValue) +
                            ConscientiousnessFactor(et, emotionalValue)));
        }
Ejemplo n.º 6
0
        public void VerifyPhoto2Results(EmotionType emotion, double expectedScore)
        {
            //Arrange

            //Act
            FaceOffPage.SubmitImageForPhoto2(emotion);
            App.Screenshot($"Player 2 Image Submitted: {emotion.ToString()}");

            FaceOffPage.WaitForNoPhoto2ActivityIndicator();

            //Assert
            Assert.AreEqual(EmotionConstants.EmotionDictionary[emotion], FaceOffPage.Emotion);
            Assert.IsTrue(FaceOffPage.ScoreButton2Text.Contains(expectedScore.ToString()));

            //Act
            FaceOffPage.TapScoreButton2();
            FaceOffPage.WaitForResultsPopup();

            //Assert
            Assert.IsTrue(FaceOffPage.DoesResultsPopupContainExpectedResults(emotion, expectedScore));
        }
Ejemplo n.º 7
0
        private static List <string> SampleEmotionType(short quantity, EmotionType type)
        {
            var filtered = m_PicturePaths.Where(path => Path.GetDirectoryName(path).Contains(type.ToString("G")));
            var weak     = filtered.Where(path => Utils.GetFirstDigit(Path.GetFileName(path)) == EmotionSeverity.Weak.ToString("D")[0]);
            var average  = filtered.Where(path => Utils.GetFirstDigit(Path.GetFileName(path)) == EmotionSeverity.Average.ToString("D")[0]);
            var strong   = filtered.Where(path => Utils.GetFirstDigit(Path.GetFileName(path)) == EmotionSeverity.Strong.ToString("D")[0]);

            /* Here we use different method of randomization to increase randomness */
            List <string> weakSample    = weak.OrderBy(x => Guid.NewGuid()).Take(quantity).ToList();
            List <string> averageSample = average.OrderBy(x => Guid.NewGuid()).Take(quantity).ToList();
            List <string> strongSample  = strong.OrderBy(x => Guid.NewGuid()).Take(quantity).ToList();

            List <string> sample = new List <string>();

            sample.AddRange(weakSample);
            sample.AddRange(averageSample);
            sample.AddRange(strongSample);
            sample = Utils.PermuteList(sample);

            return(sample);
        }
Ejemplo n.º 8
0
        /*
         * Samples tuple of videos based on the types of emotions the subject recognized best and worst.
         * The first element in the sample stands for best video, last - for worst one.
         */
        public static List <JSONWrappers.VideoInfo> GetVideoSample(EmotionType best, EmotionType worst)
        {
            Debug.Assert((best != EmotionType.Undefined) && (worst != EmotionType.Undefined), "Got invalid values for emotion types.");

            /* Filtering videos categories by required emotion types */
            var bestVideos  = m_VideosPaths.Where(path => Path.GetDirectoryName(path).Contains(best.ToString("G")));
            var worstVideos = m_VideosPaths.Where(path => Path.GetDirectoryName(path).Contains(worst.ToString("G")));

            /*
             * Randomly choosing best and worst video from all filtered videos.
             * Creating Random instance twice to increase randomness.
             */
            int bestVideoIndex  = new Random().Next(bestVideos.Count());
            int worstVideoIndex = new Random().Next(worstVideos.Count());

            VideoInfo bestVideo  = new VideoInfo(bestVideos.ElementAt(bestVideoIndex));
            VideoInfo worstVideo = new VideoInfo(worstVideos.ElementAt(worstVideoIndex));

            return(new List <JSONWrappers.VideoInfo> {
                bestVideo.ToJSON(), worstVideo.ToJSON()
            });
        }
Ejemplo n.º 9
0
        public static Task SubmitImageForPhoto2(string playerName, EmotionType emotion)
        {
            var player2 = new PlayerModel(PlayerNumberType.Player2, playerName)
            {
                ImageMediaFile = new MediaFile($"{Xamarin.Essentials.FileSystem.AppDataDirectory}/player2photo", () => _applicationTypeInfo.GetTypeInfo().Assembly.GetManifestResourceStream($"{_applicationTypeInfo.Namespace}.Images.{emotion.ToString()}.png"))
            };

            return(FaceOffViewModel.SubmitPhoto(emotion, player2));
        }