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); }
public CameraControl() { this.InitializeComponent(); mediaCapture = new MediaCapture(); emotionRecognition = new EmotionRecognition(); faceIdentity = new FaceIdentity(); emotionScoresList = new List <EmotionScore>(); emotionColor = new EmotionColor(); InitializeCapture(); }
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; }
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)"); }
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"); } }
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")); } }
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")); } }
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 } }
public Emotion(EmotionColor ec, bool isA) { emotionColor = ec; isActive = isA; }