コード例 #1
0
ファイル: Resources.cs プロジェクト: JelleDekkers/HoloPet
        public static Resource GetNearestResourceWithColor(EmotionColor color, Vector3 position)
        {
            Emotion         correspondingEmotion            = (Emotion)((int)color);
            List <Resource> resourcesWithCorrespondingColor = AllResources.Where(x => x.emotion == correspondingEmotion).ToList();

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

            float    closestDist     = Mathf.Infinity;
            Resource closestResource = null;

            foreach (Resource r in resourcesWithCorrespondingColor)
            {
                if (r == null)
                {
                    continue;
                }
                float dist = Vector3.Distance(r.transform.position, position);
                if (dist < closestDist)
                {
                    closestDist     = dist;
                    closestResource = r;
                }
            }

            return(closestResource);
        }
コード例 #2
0
 public CameraControl()
 {
     this.InitializeComponent();
     mediaCapture       = new MediaCapture();
     emotionRecognition = new EmotionRecognition();
     faceIdentity       = new FaceIdentity();
     emotionScoresList  = new List <EmotionScore>();
     emotionColor       = new EmotionColor();
     InitializeCapture();
 }
コード例 #3
0
 public void DropEmotionsAfterDeath(EmotionColor emotionColor)
 {
     Debug.Log("Drop Emotions After Death");
     for (int i = 0; i < transform.childCount; i++)
     {
         var emotionToDrop = RemoveEmotion();
         Destroy(transform.GetChild(i).gameObject);      // destroy internal emotion
         DropEmotion(this.gameObject.transform.position, Vector3.zero, emotionToDrop.EmotionColor);
         Debug.Log(Emotions.Count);
     }
     globalAngle = -180;
 }
コード例 #4
0
    public void GenerateMatchingHuman(EmotionColor killedColor)
    {
        switch (killedColor)
        {
        case EmotionColor.pink:    var humanPink = Generator("Human");   humanPink.GetComponent <ConsumableBehaviour>().humanColor = EmotionColor.pink;      break;

        case EmotionColor.blue:    var humanBlue = Generator("Human");   humanBlue.GetComponent <ConsumableBehaviour>().humanColor = EmotionColor.blue;      break;

        case EmotionColor.yellow:    var humanYellow = Generator("Human"); humanYellow.GetComponent <ConsumableBehaviour>().humanColor = EmotionColor.yellow;  break;

        case EmotionColor.purple:    var humanPurple = Generator("Human"); humanPurple.GetComponent <ConsumableBehaviour>().humanColor = EmotionColor.purple;  break;

        case EmotionColor.green:    var humanGreen = Generator("Human");  humanGreen.GetComponent <ConsumableBehaviour>().humanColor = EmotionColor.green;    break;
        }
        Debug.Log("Revival of human is successful (ReInstantiation)");
    }
コード例 #5
0
        private void NearestColorCommandRecieved(string command)
        {
            Debug.Log("nearest color command keyword: " + command);
            EmotionColor color           = GetColorEmotionFromCommand(command);
            Resource     closestResource = Resources.GetNearestResourceWithColor(color, head.transform.position);

            head.MovementSpeed = head.movementStartingSpeed;

            if (closestResource != null && Vector3.Distance(head.transform.position, closestResource.transform.position) < maxFindingDistance)
            {
                pathfinder.SetNewTargetPosition(closestResource.transform.position);
            }
            else
            {
                Debug.Log("No resource with " + color.ToString() + " found within range");
            }
        }
コード例 #6
0
    public Sprite GetDeadSprite(EmotionColor color)
    {
        switch (color)
        {
        default:
        case EmotionColor.blue: return(Resources.Load <Sprite>("blue_dead"));

        case EmotionColor.green: return(Resources.Load <Sprite>("green_dead"));

        case EmotionColor.pink: return(Resources.Load <Sprite>("pink_dead"));

        case EmotionColor.purple: return(Resources.Load <Sprite>("purple_dead"));

        case EmotionColor.yellow: return(Resources.Load <Sprite>("yellow_dead"));

        case EmotionColor.white: return(Resources.Load <Sprite>("white_dead"));
        }
    }
コード例 #7
0
    public Sprite GetHumanSprite(EmotionColor color)
    {
        switch (color)
        {
        default:
        case EmotionColor.blue: return(Resources.Load <Sprite>("blue"));

        case EmotionColor.green: return(Resources.Load <Sprite>("green"));

        case EmotionColor.pink: return(Resources.Load <Sprite>("pink"));

        case EmotionColor.purple: return(Resources.Load <Sprite>("purple"));

        case EmotionColor.yellow: return(Resources.Load <Sprite>("yellow"));

        case EmotionColor.white: return(Resources.Load <Sprite>("white"));
        }
    }
コード例 #8
0
 public void DefineColorByEmotion()
 {
     Debug.Log("shdkjfhsdkjf");
     if (emotionController.Emotions.Count <= 1)
     {
         Debug.Log("Number of emotions in emotionContorller: " + emotionController.Emotions.Count);
         humanColor = emotionController.Emotions[0].EmotionColor;    // save internal value
         Debug.Log("2: " + humanColor);
         humanSpriteRenderer.sprite = GetHumanSprite(humanColor);
         Debug.Log("3: " + GetHumanSprite(humanColor));
         deadSprite = GetDeadSprite(humanColor);
         // change animation controller of human
     }
     else
     {
         Debug.Log("Number of emotions in emotionContorller: " + emotionController.Emotions.Count);
         humanColor = EmotionColor.white;            // save internal value
         humanSpriteRenderer.sprite = GetHumanSprite(humanColor);
         deadSprite = GetDeadSprite(humanColor);
         // change animation controller of human
     }
 }
コード例 #9
0
 public Emotion(EmotionColor ec, bool isA)
 {
     emotionColor = ec;
     isActive     = isA;
 }