Exemple #1
0
 public override void Hited()
 {
     EventManager.shakeCamera();
     //SoundEffectFunction.Play (gameObject, sounds,0.5f);
     SoundEffectFunction.Play(gameObject, hitesSounds);
     ExpressionControl.ChangeToWarning();
 }
    void Start()
    {
        character = GameObject.FindGameObjectWithTag("Player");
        CharacterInitialize();
        rnd          = new System.Random();
        pitchShifter = Resources.Load <AudioMixerGroup>(Global.mixer);

        // Components added during runtime
        mecanimControl  = character.AddComponent <MecanimControl>();
        facialControl   = character.AddComponent <ExpressionControl>();
        mainOffsetCtrl  = character.AddComponent <MainOffset>();
        spineOffsetCtrl = character.AddComponent <SpineOffset>();

        // Static method can be called doesn't have StartCoroutine()
        character.AddComponent <HandControl>();
        character.AddComponent <FootControl>();
        gameObject.AddComponent <SlideControl>();
        gameObject.AddComponent <AudioControl>();
    }
Exemple #3
0
    //Function to send the message to the OSCOVA bot
    //It will then review all the intents in the loaded .west/.json workspace
    //Once it found the nearest match, it will send the response
    public void SendMessageToBot(string inputField)
    {
        var userMessage = inputField;

        if (!string.IsNullOrEmpty(userMessage))
        {
            Debug.Log($"OscovaBot:[USER] {userMessage}");
            AddMessage($"User: {userMessage}", MessageType.User);

            //Create a request for bot to process.
            var request = MainBot.MainUser.CreateRequest(userMessage);

            //Evaluate the request (Compute NLU - Natural Language Understanding)
            var evaluationResult = MainBot.Evaluate(request);

            //Invoke the best suggested intent found. This is compel a response generation.
            evaluationResult.Invoke();

            //Get the intent name to change the Tobor expression
            IntentResult intentResult = evaluationResult.SuggestedIntent;
            string       intentName   = intentResult.Name.ToString();
            Debug.Log("Intent Name: " + intentName);


            //Phrase will be loading according to the current date
            //Different phrases loads different JSON

            // if intentname contain "sad", show sad, contain "happy" show happy(check dialogs name) eg: happy_dialog_ep1.happy
            //Currently Tobor only have "Greeting" and "Feeling" dialogs -> loads "Happy" expression and "Happy" body movement
            ExpressionAnim    = FindObjectOfType <ExpressionControl>();
            toborBodyAnimator = GameObject.FindGameObjectWithTag("BodyAnimator").GetComponent <Animator>();

            if (phaseInitiated < 3)
            {
                if (intentName == "BotDialog.DefaultFallback")
                {
                    ExpressionAnim.SetExpression(SAD_STATE_INDEX);
                    StartCoroutine(BackToBodyNormal(3, NORMAL_STATE_INDEX, NORMAL_STATE_INDEX));
                }
                else
                {
                    ExpressionAnim.SetExpression(NORMAL_STATE_INDEX);
                }
            }
            else
            {
                if (intentName == "BotDialog.DefaultFallback")
                {
                    ExpressionAnim.SetExpression(SAD_STATE_INDEX);
                    toborBodyAnimator.SetInteger(BODY_ANIM_STATE, SAD_STATE_INDEX);

                    StartCoroutine(BackToBodyNormal(3, SAD_BACKNORMAL_STATE_INDEX, NORMAL_STATE_INDEX));
                }
                else if (intentName.Contains("feeling"))
                {
                    ExpressionAnim.SetExpression(HAPPY_STATE_INDEX);
                    toborBodyAnimator.SetInteger(BODY_ANIM_STATE, HAPPY_STATE_INDEX);

                    StartCoroutine(BackToBodyNormal(3, HAPPY_BACKNORMAL_STATE_INDEX, NORMAL_STATE_INDEX));
                }
                else
                {
                    ExpressionAnim.SetExpression(NORMAL_STATE_INDEX);
                    toborBodyAnimator.SetInteger(BODY_ANIM_STATE, NORMAL_STATE_INDEX);
                }
            }

            chatBox.text = "";
            //  }
        }
    }