Ejemplo n.º 1
0
 private void SetCurrentFeeling(PlayerFeeling newFeeling)
 {
     if (currentFeeling != newFeeling)
     {
         currentFeeling = newFeeling;
         currentMovements.Reset();
         //doInkBurst = true;
     }
 }
Ejemplo n.º 2
0
        public PlayerFeeling CalculateCurrentFeeling(PlayerScript player, PlayerFeeling curFeeling)
        {
            int quadsTouched = 0;
            for(int i = 0; i < QuadrantDensity; ++i)
            {
                for(int j = 0; j < QuadrantDensity; ++j)
                {
                    QuadrantsTouched[i,j].timer -= 1;
                    if(QuadrantsTouched[i,j].timer < 0)
                        QuadrantsTouched[i,j].timer = 0;

                    if(QuadrantsTouched[i,j].timer > 0)
                        ++quadsTouched;
                }
            }

            float dt = Time.deltaTime;
            float quadrantsPerSecond = quadsTouched / TimeSinceLastTouchDown;
            float anglesPerSecond = TotalAngleChanges / TimeSinceLastTouchDown;
            float distancePerSecond = DistanceTraveled / TimeSinceLastTouchDown;

            TotalAngleChanges -= 1000.0f * dt;
            //DistanceTraveled -= 1.0f*dt;
            if(TotalAngleChanges < 0)
                TotalAngleChanges = 0;
            if(DistanceTraveled < 0)
                DistanceTraveled= 0;

            FuzzyRule isSadQuadrants = new FuzzyRule(0, 2, 5, 15, quadsTouched);
            float amountOfSadQuads = isSadQuadrants.Fuzzify();
            FuzzyRule isHappyQuadrants = new FuzzyRule(5, 20, 35, 50, quadsTouched);
            float amountOfHappyQuads = isHappyQuadrants.Fuzzify();
            FuzzyRule isAngryQuadrants = new FuzzyRule(25, 40, 60, 255, quadsTouched);
            float amountOfAngryQuads = isAngryQuadrants.Fuzzify();

            float aps = anglesPerSecond * 0.1f;
            FuzzyRule isSadAngles = new FuzzyRule(0, 15, 45, 110, aps);
            float amountOfSadAngles = isSadAngles.Fuzzify();
            FuzzyRule isHappyAngles = new FuzzyRule(15, 50, 250, 360, aps);
            float amountOfHappyAngles = isHappyAngles.Fuzzify();
            FuzzyRule isAngryAngles = new FuzzyRule(200, 320, 400, 1500, aps);
            float amountOfAngryAngles = isAngryAngles.Fuzzify();

            FuzzyRule isSadDistance = new FuzzyRule(0, 0.25f, 0.85f, 1.25f, distancePerSecond);
            float amountOfSadDistance = isSadDistance.Fuzzify();
            FuzzyRule isHappyDistance = new FuzzyRule(0.5f, 1.15f, 2.0f, 4.0f, distancePerSecond);
            float amountOfHappyDistance = isHappyDistance.Fuzzify();
            FuzzyRule isAngryDistance = new FuzzyRule(1.75f, 3.0f, 5.0f, 10.0f, distancePerSecond);
            float amountOfAngryDistance = isAngryDistance.Fuzzify();

            player.totalSadness = (amountOfSadQuads +  amountOfSadDistance)/2.0f;
            player.totalHappiness = (amountOfHappyQuads +  amountOfHappyDistance)/2.0f;
            player.totalAngriness = (amountOfAngryQuads +  amountOfAngryDistance)/2.0f;

            string debugMsg = "\ntotalSadness: " + player.totalSadness.ToString("f2");
            debugMsg += "\ntotalHappiness: " + player.totalHappiness.ToString("f2");
            debugMsg += "\ntotalAngriness: " + player.totalAngriness.ToString("f2");

            //string debugMsg = "LineIntersects: " + LineIntersects.ToString();

            //string debugMsg = "quadsTouched: " + quadsTouched.ToString("f2");
            //debugMsg += "\naps: " + aps.ToString("f2");
            //debugMsg += "\ndistancePerSecond: " + distancePerSecond.ToString("f2");
            debugMsg += "\ncurrent feeling: " + curFeeling.ToString();
            //DebugStreamer.message = debugMsg;

            if(TimeSinceLastFeelingChange < 3.50f)
                return curFeeling;

            if(player.totalSadness > player.totalHappiness && player.totalSadness > player.totalAngriness)
                return PlayerFeeling.Sad;
            else if(player.totalHappiness > player.totalSadness && player.totalHappiness > player.totalAngriness)
                return PlayerFeeling.Happy;
            else if(player.totalAngriness > player.totalSadness && player.totalAngriness > player.totalHappiness)
                return PlayerFeeling.Angry;

            return curFeeling;
        }
Ejemplo n.º 3
0
 private void SetCurrentFeeling(PlayerFeeling newFeeling)
 {
     if(currentFeeling != newFeeling)
     {
         currentFeeling = newFeeling;
         currentMovements.Reset();
         //doInkBurst = true;
     }
 }
Ejemplo n.º 4
0
        public PlayerFeeling CalculateCurrentFeeling(PlayerScript player, PlayerFeeling curFeeling)
        {
            int quadsTouched = 0;

            for (int i = 0; i < QuadrantDensity; ++i)
            {
                for (int j = 0; j < QuadrantDensity; ++j)
                {
                    QuadrantsTouched[i, j].timer -= 1;
                    if (QuadrantsTouched[i, j].timer < 0)
                    {
                        QuadrantsTouched[i, j].timer = 0;
                    }

                    if (QuadrantsTouched[i, j].timer > 0)
                    {
                        ++quadsTouched;
                    }
                }
            }

            float dt = Time.deltaTime;
            float quadrantsPerSecond = quadsTouched / TimeSinceLastTouchDown;
            float anglesPerSecond    = TotalAngleChanges / TimeSinceLastTouchDown;
            float distancePerSecond  = DistanceTraveled / TimeSinceLastTouchDown;

            TotalAngleChanges -= 1000.0f * dt;
            //DistanceTraveled -= 1.0f*dt;
            if (TotalAngleChanges < 0)
            {
                TotalAngleChanges = 0;
            }
            if (DistanceTraveled < 0)
            {
                DistanceTraveled = 0;
            }

            FuzzyRule isSadQuadrants     = new FuzzyRule(0, 2, 5, 15, quadsTouched);
            float     amountOfSadQuads   = isSadQuadrants.Fuzzify();
            FuzzyRule isHappyQuadrants   = new FuzzyRule(5, 20, 35, 50, quadsTouched);
            float     amountOfHappyQuads = isHappyQuadrants.Fuzzify();
            FuzzyRule isAngryQuadrants   = new FuzzyRule(25, 40, 60, 255, quadsTouched);
            float     amountOfAngryQuads = isAngryQuadrants.Fuzzify();

            float     aps                 = anglesPerSecond * 0.1f;
            FuzzyRule isSadAngles         = new FuzzyRule(0, 15, 45, 110, aps);
            float     amountOfSadAngles   = isSadAngles.Fuzzify();
            FuzzyRule isHappyAngles       = new FuzzyRule(15, 50, 250, 360, aps);
            float     amountOfHappyAngles = isHappyAngles.Fuzzify();
            FuzzyRule isAngryAngles       = new FuzzyRule(200, 320, 400, 1500, aps);
            float     amountOfAngryAngles = isAngryAngles.Fuzzify();

            FuzzyRule isSadDistance         = new FuzzyRule(0, 0.25f, 0.85f, 1.25f, distancePerSecond);
            float     amountOfSadDistance   = isSadDistance.Fuzzify();
            FuzzyRule isHappyDistance       = new FuzzyRule(0.5f, 1.15f, 2.0f, 4.0f, distancePerSecond);
            float     amountOfHappyDistance = isHappyDistance.Fuzzify();
            FuzzyRule isAngryDistance       = new FuzzyRule(1.75f, 3.0f, 5.0f, 10.0f, distancePerSecond);
            float     amountOfAngryDistance = isAngryDistance.Fuzzify();

            player.totalSadness   = (amountOfSadQuads + amountOfSadDistance) / 2.0f;
            player.totalHappiness = (amountOfHappyQuads + amountOfHappyDistance) / 2.0f;
            player.totalAngriness = (amountOfAngryQuads + amountOfAngryDistance) / 2.0f;

            string debugMsg = "\ntotalSadness: " + player.totalSadness.ToString("f2");

            debugMsg += "\ntotalHappiness: " + player.totalHappiness.ToString("f2");
            debugMsg += "\ntotalAngriness: " + player.totalAngriness.ToString("f2");

            //string debugMsg = "LineIntersects: " + LineIntersects.ToString();

            //string debugMsg = "quadsTouched: " + quadsTouched.ToString("f2");
            //debugMsg += "\naps: " + aps.ToString("f2");
            //debugMsg += "\ndistancePerSecond: " + distancePerSecond.ToString("f2");
            debugMsg += "\ncurrent feeling: " + curFeeling.ToString();
            //DebugStreamer.message = debugMsg;

            if (TimeSinceLastFeelingChange < 3.50f)
            {
                return(curFeeling);
            }

            if (player.totalSadness > player.totalHappiness && player.totalSadness > player.totalAngriness)
            {
                return(PlayerFeeling.Sad);
            }
            else if (player.totalHappiness > player.totalSadness && player.totalHappiness > player.totalAngriness)
            {
                return(PlayerFeeling.Happy);
            }
            else if (player.totalAngriness > player.totalSadness && player.totalAngriness > player.totalHappiness)
            {
                return(PlayerFeeling.Angry);
            }

            return(curFeeling);
        }