示例#1
0
    void LoadJSON()
    {
        string path       = Application.dataPath + "/JSONs/speech.json";
        string jsonString = File.ReadAllText(path);

        JSONObject speechJSON = JSON.Parse(jsonString) as JSONObject;

        m_speech = new Dictionary <string, List <string> >();

        foreach (var personalityStuation in speechJSON)
        {
            if (personalityStuation.Key != personality.ToString())
            {
                continue;
            }

            foreach (var situationText in personalityStuation.Value)
            {
                m_speech.Add(situationText.Key, new List <string>());
                foreach (var text in situationText.Value)
                {
                    m_speech[situationText.Key].Add(text.Value);
                }
            }
        }
    }
示例#2
0
    //Selects a personality randomly and initializes the enemy's stats based on it.
    public void InitializeEnemy()
    {
        audioSource          = GetComponent <AudioSource>();
        collisionGameObjects = new List <GameObject>();

        //Select a personality randomly.
        //Personality = (EnemyPersonality)random.Next(0, (int)Enum.GetNames(typeof(EnemyPersonality)).Length);
        Personality = (EnemyPersonality)RandomNumberGenerator.NextRandom(0, (int)Enum.GetNames(typeof(EnemyPersonality)).Length);


        //Initialize stats based on the personality.
        switch (Personality)
        {
        case EnemyPersonality.aggressive:
            SetStats(3, 3, 2, 6.0f, CharacterState.idle, 4.0f, GetComponent <Animator>(), true, false, 100, GameObject.FindGameObjectWithTag("ImageTarget"));

            //Assign voices based on the personality.
            try
            {
                attack1 = (AudioClip)Resources.Load("Sounds/Voices/aggressive_attack1");
                attack2 = (AudioClip)Resources.Load("Sounds/Voices/aggressive_attack2");
                taunt1  = (AudioClip)Resources.Load("Sounds/Voices/aggressive_taunt1");
                taunt2  = (AudioClip)Resources.Load("Sounds/Voices/aggressive_taunt2");
                death1  = (AudioClip)Resources.Load("Sounds/Voices/aggressive_death1");
                death2  = (AudioClip)Resources.Load("Sounds/Voices/aggressive_death2");
            }
            catch (Exception e) { }

            break;

        case EnemyPersonality.defensive:

            try
            {
                attack1 = (AudioClip)Resources.Load("Sounds/Voices/defensive_attack1");
                attack2 = (AudioClip)Resources.Load("Sounds/Voices/defensive_attack2");
                taunt1  = (AudioClip)Resources.Load("Sounds/Voices/defensive_taunt1");
                taunt2  = (AudioClip)Resources.Load("Sounds/Voices/defensive_taunt2");
                death1  = (AudioClip)Resources.Load("Sounds/Voices/defensive_death1");
                death2  = (AudioClip)Resources.Load("Sounds/Voices/defensive_death2");
            }
            catch (Exception e) { }

            SetStats(4, 4, 1, 6.0f, CharacterState.idle, 3.0f, GetComponent <Animator>(), true, false, 100, GameObject.FindGameObjectWithTag("ImageTarget"));
            break;

        case EnemyPersonality.jerk:

            try
            {
                attack1 = (AudioClip)Resources.Load("Sounds/Voices/jerk_attack1");
                attack2 = (AudioClip)Resources.Load("Sounds/Voices/jerk_attack2");
                taunt1  = (AudioClip)Resources.Load("Sounds/Voices/jerk_taunt1");
                taunt2  = (AudioClip)Resources.Load("Sounds/Voices/jerk_taunt2");
                death1  = (AudioClip)Resources.Load("Sounds/Voices/jerk_death1");
                death2  = (AudioClip)Resources.Load("Sounds/Voices/jerk_death2");
            }
            catch (Exception e) { }

            SetStats(2, 2, 2, 6.0f, CharacterState.idle, 5.0f, GetComponent <Animator>(), true, false, 100, GameObject.FindGameObjectWithTag("ImageTarget"));
            break;

        default:

            try
            {
                attack1 = (AudioClip)Resources.Load("Sounds/Voices/aggressive_attack1");
                attack2 = (AudioClip)Resources.Load("Sounds/Voices/aggressive_attack2");
                taunt1  = (AudioClip)Resources.Load("Sounds/Voices/aggressive_taunt1");
                taunt2  = (AudioClip)Resources.Load("Sounds/Voices/aggressive_taunt2");
                death1  = (AudioClip)Resources.Load("Sounds/Voices/aggressive_death1");
                death2  = (AudioClip)Resources.Load("Sounds/Voices/aggressive_death2");
            }
            catch (Exception e) { }

            SetStats(2, 2, 2, 6.0f, CharacterState.idle, 3.5f, GetComponent <Animator>(), true, false, 100, GameObject.FindGameObjectWithTag("ImageTarget"));
            break;
        }

        try
        {
            //Set the superclass' audio settings.
            characterAudioSource = audioSource;
            destroyGameObject    = (AudioClip)Resources.Load("Sounds/destroy_gameobject");
            swordAttack1         = (AudioClip)Resources.Load("Sounds/enemy_sword_attack");
            swordAttack2         = (AudioClip)Resources.Load("Sounds/player_sword_attack");
            swordSlash           = (AudioClip)Resources.Load("Sounds/sword_slash");
        }
        catch (Exception e) {}


        Debug.Log("Enemy's personality set to " + Personality.ToString() + ".");
        SelectTargetRandomly();
        commandDecided   = false;
        executingCommand = false;
    }
示例#3
0
 static void FindBlindDate()
 {
     yourDate = (Personality)UnityEngine.Random.Range(0, 5);
     Debug.Log("Your date is " + yourDate.ToString());
     //Load dates images and name/type
 }