// LOGIC

    public void Initialize(string i_DatabasePath)
    {
        tnCharactersDatabase database = Resources.Load <tnCharactersDatabase>(i_DatabasePath);

        if (database != null)
        {
            m_DefaultCharacterPrefabPath = database.defaultCharacterPrefabPath;

            for (int index = 0; index < database.charactersCount; ++index)
            {
                tnCharacterDataEntry entry = database.GetCharacterDataEntry(index);
                if (entry != null)
                {
                    string key = entry.id;
                    tnCharacterDataDescriptor descriptor = entry.descriptor;
                    if (key != "" && descriptor != null)
                    {
                        int             hash = StringUtils.GetHashCode(key);
                        tnCharacterData data = new tnCharacterData(descriptor);

                        m_Data.Add(hash, data);
                        m_Keys.Add(hash);
                    }
                }
            }
        }
        else
        {
            LogManager.LogWarning(this, "Database not loaded.");
        }
    }
    // CTOR

    public tnCharacterData(tnCharacterDataDescriptor i_Descriptor)
    {
        if (i_Descriptor != null)
        {
            m_FirstName = i_Descriptor.firstName;
            m_LastName  = i_Descriptor.lastName;

            m_DisplayName = i_Descriptor.displayName;

            m_Role   = i_Descriptor.role;
            m_Number = i_Descriptor.number;

            m_HasSpecificPrefab  = i_Descriptor.useDifferentPrefab;
            m_PrefabPath         = i_Descriptor.prefabPath;
            m_AnimatorController = i_Descriptor.animatorController;

            m_UIIconFacingRight = i_Descriptor.uiIconFacingRight;
            m_UIIconFacingLeft  = i_Descriptor.uiIconFacingLeft;
        }
    }
Example #3
0
    public static void CreateAnimationPlayer()
    {
        // Load character database.

        tnCharactersDatabase characterDatabase = Resources.Load <tnCharactersDatabase>("Database/Game/CharactersDatabase");

        if (characterDatabase == null)
        {
            Debug.LogError("Character database not found.");
            return;
        }

        for (int index = 0; index < characterDatabase.charactersCount; ++index)
        {
            tnCharacterDataEntry entry = characterDatabase.GetCharacterDataEntry(index);
            if (entry != null)
            {
                EditorUtility.DisplayProgressBar("Processing", "Processing Animator for " + entry.id + "...", Mathf.Clamp01((float)index / characterDatabase.charactersCount));

                tnCharacterDataDescriptor descriptor = entry.descriptor;
                if (descriptor != null)
                {
                    SerializedObject serializedDescriptor = new SerializedObject(descriptor);

                    SerializedProperty serializedProperty = serializedDescriptor.FindProperty("m_AnimatorController");
                    serializedProperty.objectReferenceValue = CreateAnimatorController(entry.id, entry.descriptor);

                    serializedDescriptor.ApplyModifiedProperties();
                }
            }
        }

        AssetDatabase.SaveAssets();

        EditorUtility.ClearProgressBar();
    }
Example #4
0
    private static AnimatorController CreateAnimatorController(string i_CharacterName, tnCharacterDataDescriptor i_Descriptor)
    {
        if (i_Descriptor == null)
        {
            return(null);
        }

        return(CreateAnimatorController(i_CharacterName, i_Descriptor.leftFrames, i_Descriptor.rightFrames));
    }