Esempio n. 1
0
    private IEnumerator playEmotion(EmotionStates emotion)
    {
        int i = (int)emotion;

        if (emotions[i].Cloud != -1)
        {
            cloud.SetActive(true);
        }
        else
        {
            cloud.SetActive(false);
        }

        AssigEmotion(i);
        setAnim(emotion, true);

        yield return(new WaitForSeconds(emoteduration));

        setAnim(emotion, false);

        i = (int)EmotionStates.Normal;
        AssigEmotion(i);

        cloud.SetActive(false);
    }
Esempio n. 2
0
 public void newEmotion(EmotionStates emotion)
 {
     if (routine != null)
     {
         StopCoroutine(routine);
     }
     routine = playEmotion(emotion);
     StartCoroutine(routine);
 }
    private void OnClick()
    {
        float random = Random.Range(0, 10);

        if (random > 4)
        {
            _emotion = EmotionStates.Angry;
        }
        else
        {
            _emotion = EmotionStates.Happy;
        }
    }
Esempio n. 4
0
    void AssigEmotion(int i)
    {
        current_emotion = (EmotionStates)i;
        Rect rect = clouds[0].raw.uvRect;

        materials[0].mat.mainTextureOffset = -materials[0].offsets[emotions[i].Eyes - 1];
        materials[1].mat.mainTextureOffset = -materials[1].offsets[emotions[i].Mouth - 1];
        if (emotions[i].Cloud != -1)
        {
            rect.position = clouds[0].offsets[emotions[i].Cloud - 1];
        }
        clouds[0].raw.uvRect = rect;
    }
 public void SetFace(EmotionStates state)
 {
     _emotion = state;
     UpdateFace();
 }
Esempio n. 6
0
    void setAnim(EmotionStates emotion, bool enable)
    {
        anim.ForceStateNormalizedTime(0);
        if (emotion == EmotionStates.Angry)
        {
            source.clip = clips[2];
            anim.SetBool("Angry", enable);
            anim.SetBool("Sad", false);
            anim.SetBool("Happy", false);
            anim.SetBool("Eat", false);
            anim.SetBool("Walk", false);
        }
        else if (emotion == EmotionStates.Bored)
        {
            source.clip = clips[3];
            anim.SetBool("Angry", false);
            anim.SetBool("Bored", enable);
            anim.SetBool("Happy", false);
            anim.SetBool("Eat", false);
            anim.SetBool("Walk", false);
        }
        else if (emotion == EmotionStates.Happy || emotion == EmotionStates.Love)
        {
            source.clip = clips[0];
            anim.SetBool("Angry", false);
            anim.SetBool("Happy", enable);
            anim.SetBool("Eat", false);
            anim.SetBool("Walk", false);
        }
        else if (emotion == EmotionStates.Full)
        {
            source.clip = clips[1];
            anim.SetBool("Angry", false);
            anim.SetBool("Happy", false);
            anim.SetBool("Walk", false);
            anim.SetBool("Eat", enable);
            if (enable)
            {
                lastEmotion = Time.time;
            }
        }
        else if (emotion == EmotionStates.Hungry || emotion == EmotionStates.Sad)
        {
            source.clip = clips[3];
            anim.SetBool("Angry", false);
            anim.SetBool("Happy", false);
            anim.SetBool("Eat", false);
            anim.SetBool("Walk", false);
        }
        else
        {
            anim.SetBool("Angry", false);
            anim.SetBool("Happy", false);
            anim.SetBool("Eat", false);
            anim.SetBool("Walk", false);
        }

        if (enable == true)
        {
            if (source.isPlaying)
            {
                source.Stop();
            }
            source.Play();
        }
    }
Esempio n. 7
0
    void Awake()
    {
        if(Instance != null){
            Debug.Log("Already get an GeneralValues");
        }
        if(Instance == null){
            Instance = this;
        }

        Emotions= new EmotionStates();
        colorValue = RenderSettings.ambientLight.r;
        sound = gameObject.GetComponent<AudioSource>() as AudioSource;
    }