/// <summary>
 /// Initializes this subclass (asset) with given parameters.
 /// </summary>
 /// <param name="gender">Gender of this asset.</param>
 /// <param name="assetPath">Path of sprites.</param>
 public CEyebrows(AssetGender gender, string assetPath)
     : base(gender, AssetType.Eyebrows
            , AssetModifyFlag.MoveVertical | AssetModifyFlag.Resize | AssetModifyFlag.StretchHorizontal | AssetModifyFlag.StretchVertical
            | AssetModifyFlag.ChangeDistance | AssetModifyFlag.Rotate
            , assetPath, true)
 {
 }
    public CBaseAsset(AssetGender gender, AssetType assetType, AssetModifyFlag modifyFlags, string assetPath, bool loadSpriteOverride = false)
    {
        m_assetGender = gender;
        m_assetType   = assetType;
        m_modifyFlags = modifyFlags;

        LoadSprite(assetPath, loadSpriteOverride);

        Debug.Log("CBaseAsset: " + m_assetType + " " + m_assetGender + " " + m_modifyFlags);
    }
    /// <summary>
    /// Creates an asset object with given parameters.
    /// </summary>
    /// <param name="type">Type of the asset.</param>
    /// <param name="gender">Gender of the asset.</param>
    /// <param name="assetPath">Path of asset sprites.</param>
    /// <returns></returns>
    public CBaseAsset CreateAsset(AssetType type, AssetGender gender, string assetPath)
    {
        switch (type)
        {
        case AssetType.HeadShape:
            return(new CHeadShape(gender, assetPath));

        case AssetType.Hair:
            return(new CHair(gender, assetPath));

        case AssetType.Ears:
            return(new CEars(gender, assetPath));

        case AssetType.Eyes:
            return(new CEyes(gender, assetPath));

        case AssetType.Eyebrows:
            return(new CEyebrows(gender, assetPath));

        case AssetType.Glasses:
            return(new CGlasses(gender, assetPath));

        case AssetType.FaceTexture:
            return(new CFaceTexture(gender, assetPath));

        case AssetType.Nose:
            return(new CNose(gender, assetPath));

        case AssetType.Moustache:
            return(new CMoustache(gender, assetPath));

        case AssetType.Beard:
            return(new CBeard(gender, assetPath));

        case AssetType.Mouth:
            return(new CMouth(gender, assetPath));

        case AssetType.Body:
            return(new CBody(gender, assetPath));

        case AssetType.SpecialBody:
            return(new CSpecialBody(gender, assetPath));

        case AssetType.Ghutra:
            return(new CGhutra(gender, assetPath));

        case AssetType.BackgroundTexture:
            return(new CBGTexture(gender, assetPath));
        }

        return(null);
    }
    /// <summary>
    /// Returns all assets of the specified type and gender.
    /// </summary>
    /// <param name="type"></param>
    /// <param name="gender"></param>
    /// <returns></returns>
    public static List <CBaseAsset> GetLoadedAssetsByTypeAndGender(AssetType type, AssetGender gender)
    {
        List <CBaseAsset> returnList = new List <CBaseAsset>();

        foreach (CBaseAsset asset in m_assets[type])
        {
            if (asset.GetGender() == gender)
            {
                returnList.Add(asset);
            }
        }

        return(returnList);
    }
    /// <summary>
    ///  Loads assets from the disk with given path, type and gender.
    /// </summary>
    /// <param name="directoryPath"></param>
    /// <param name="assetType"></param>
    /// <param name="assetGender"></param>
    private void InitAssets(string directoryPath, AssetType assetType, AssetGender assetGender)
    {
        Debug.Log("AvatarCreatorContext:InitAssets: " + directoryPath + " " + assetType + " " + assetGender);

        CBaseAssetFactory assetFactory = new CBaseAssetFactory();
        List <CBaseAsset> assets       = new List <CBaseAsset>();

        // Load all sprites inside given directory.
        Object[] sprites = Resources.LoadAll(directoryPath, typeof(Sprite));
        string   lastLoadedSpriteName = "";

        // Add an empty asset to the list. Once it selected by the user, this empty asset will delete the current selected asset.
        if (assetType == AssetType.Hair || assetType == AssetType.Eyebrows || assetType == AssetType.Glasses ||
            assetType == AssetType.FaceTexture || /*assetType == AssetType.Moustache ||*/ assetType == AssetType.Beard ||
            assetType == AssetType.BackgroundTexture || assetType == AssetType.Ghutra)
        {
            assets.Add(assetFactory.CreateAsset(assetType, assetGender, ""));
        }

        // For every sprite, create the asset object and add it to the temporary list.
        foreach (Sprite sprite in sprites)
        {
            string currentSpriteName = sprite.name.Split('_')[0];
            if (lastLoadedSpriteName == currentSpriteName)
            {
                continue;
            }

            assets.Add(assetFactory.CreateAsset(assetType, assetGender, directoryPath + currentSpriteName));
            lastLoadedSpriteName = currentSpriteName;
        }

        // Extend global asset list (currently loaded assets) with the temporary asset list.
        if (m_assets.ContainsKey(assetType))
        {
            m_assets[assetType].AddRange(assets);
        }
        else
        {
            m_assets.Add(assetType, assets);
        }
    }
 /// <summary>
 /// Initializes this subclass (asset) with given parameters.
 /// </summary>
 /// <param name="gender">Gender of this asset.</param>
 /// <param name="assetPath">Path of sprites.</param>
 public CBGTexture(AssetGender gender, string assetPath)
     : base(gender, AssetType.BackgroundTexture, 0, assetPath)
 {
 }
 /// <summary>
 /// Initializes this subclass (asset) with given parameters.
 /// </summary>
 /// <param name="gender">Gender of this asset.</param>
 /// <param name="assetPath">Path of sprites.</param>
 public CGhutra(AssetGender gender, string assetPath)
     : base(gender, AssetType.Ghutra
            , AssetModifyFlag.MoveVertical | AssetModifyFlag.Resize | AssetModifyFlag.StretchHorizontal | AssetModifyFlag.StretchVertical
            , assetPath, true)
 {
 }
 /// <summary>
 /// Initializes this subclass (asset) with given parameters.
 /// </summary>
 /// <param name="gender">Gender of this asset.</param>
 /// <param name="assetPath">Path of sprites.</param>
 public CSpecialBody(AssetGender gender, string assetPath)
     : base(gender, AssetType.SpecialBody
            , AssetModifyFlag.Resize | AssetModifyFlag.StretchHorizontal | AssetModifyFlag.StretchVertical
            , assetPath, true)
 {
 }
 /// <summary>
 /// Initializes this subclass (asset) with given parameters.
 /// </summary>
 /// <param name="gender">Gender of this asset.</param>
 /// <param name="assetPath">Path of sprites.</param>
 public CBeard(AssetGender gender, string assetPath)
     : base(gender, AssetType.Beard
            , AssetModifyFlag.MoveVertical | AssetModifyFlag.Resize | AssetModifyFlag.StretchHorizontal | AssetModifyFlag.StretchVertical
            , assetPath)
 {
 }
 /// <summary>
 /// Initializes this subclass (asset) with given parameters.
 /// </summary>
 /// <param name="gender">Gender of this asset.</param>
 /// <param name="assetPath">Path of sprites.</param>
 public CFaceTexture(AssetGender gender, string assetPath)
     : base(gender, AssetType.FaceTexture, AssetModifyFlag.Resize | AssetModifyFlag.StretchHorizontal | AssetModifyFlag.StretchVertical, assetPath)
 {
 }
 /// <summary>
 /// Initializes this subclass (asset) with given parameters.
 /// </summary>
 /// <param name="gender">Gender of this asset.</param>
 /// <param name="assetPath">Path of sprites.</param>
 public CGlasses(AssetGender gender, string assetPath)
     : base(gender, AssetType.Glasses, AssetModifyFlag.MoveVertical, assetPath)
 {
 }
 /// <summary>
 /// Initializes this subclass (asset) with given parameters.
 /// </summary>
 /// <param name="gender">Gender of this asset.</param>
 /// <param name="assetPath">Path of sprites.</param>
 public CHeadShape(AssetGender gender, string assetPath)
     : base(gender, AssetType.HeadShape
            , AssetModifyFlag.Resize | AssetModifyFlag.StretchHorizontal | AssetModifyFlag.StretchVertical
            , assetPath)
 {
 }