public void addEffectByConfig(string _effect_name, effectConfig effect_config)
    {
        if (!m_is_init)
        {
            init();
        }

        if (effect_config == null)
        {
            Debug.unityLogger.Log("effectsManager", "Effect was not found: " + _effect_name);
            return;
        }

        if (!isEffectRun(_effect_name))
        {
            effect_config.m_is_loop = false;
            cRunEffect root_effect = generateEffectFrom(effect_config);
            effect_config.IsMainEffect = true;

            if (root_effect != null)
            {
                //effect_config.m_final_action += _action;
                addEffect(effect_config.m_root_name, root_effect);
            }
        }
    }
 public void addEffect(string _key, cRunEffect _run)
 {
     if (!m_effects.ContainsKey(_key))
     {
         m_effects.Add(_key, _run);
     }
 }
    public void startEffectForName(string _effect_name, effectConfig.EffectFinalAction _action, bool _loop_mode = false)
    {
        if (!m_is_init)
        {
            init();
        }

        var effect_config = m_effects_storage.getEffect(_effect_name);

        if (effect_config == null)
        {
            Debug.unityLogger.Log("effectsManager", "Effect was not found: " + _effect_name);
            return;
        }

        if (!isEffectRun(_effect_name))
        {
            effect_config.m_is_loop = _loop_mode;
            cRunEffect root_effect = generateEffectFrom(effect_config);
            effect_config.IsMainEffect = true;

            if (root_effect != null)
            {
                effect_config.delegateReset();
                effect_config.m_final_action += _action;
                addEffect(effect_config.m_root_name, root_effect);
            }
        }
    }
 private void replaceEffect(string _key, cRunEffect _run)
 {
     if (_key != "" && _run != null)
     {
         if (m_effects.ContainsKey(_key) && !m_effects_for_replace.ContainsKey(_key))
         {
             m_effects_for_replace.Add(_key, _run);
         }
     }
 }
    public void restartLoopEffect(effectConfig _effect_config)
    {
        if (_effect_config == null)
        {
            Debug.unityLogger.Log("effectsManager", "Loop effect is null");
            return;
        }

        if (_effect_config.IsMainEffect)
        {
            _effect_config.m_delay_value = _effect_config.m_delta_time_loop;
            cRunEffect run = generateEffectFrom(_effect_config);

            if (run != null)
            {
                //_effect_config.m_final_action += _action;
                replaceEffect(_effect_config.m_root_name, run);
            }
        }
        else
        {
            Debug.unityLogger.Log("effectsManager", "Loop effect is not main");
        }
    }
    public cRunEffect generateEffectFrom(effectConfig _root_config)
    {
        _root_config.IsReadyForRemove = false;
        _root_config.Delay            = _root_config.m_delay_value;
        if (_root_config.m_type != eEffectType.COMPOUND_TYPE)
        {
            if (_root_config.m_control_object == null)
            {
                Debug.unityLogger.Log("effectsManager", "Not Compound Effect must have control object: " + _root_config.m_root_name + "/" + _root_config.m_type.ToString());
                return(null);
            }
            _root_config.IsVisibleState = _root_config.m_control_object.activeSelf;
        }

        if (_root_config.m_type == eEffectType.TERMINAL_MOVE_LINE_LOCAL_POS ||
            _root_config.m_type == eEffectType.TERMINAL_MOVE_ARC_LOCAL_POS)
        {
            if (_root_config.m_obj_finish_pos != null)
            {
                _root_config.m_finish_pos = new Vector2(_root_config.m_obj_finish_pos.transform.localPosition.x,
                                                        _root_config.m_obj_finish_pos.transform.localPosition.y);
            }

            if (!_root_config.m_is_use_external_start_position)
            {
                _root_config.m_start_pos = _root_config.m_control_object.transform.localPosition;
            }
        }
        else if (_root_config.m_type == eEffectType.TERMINAL_MOVE_LINE_GLOBAL_POS ||
                 _root_config.m_type == eEffectType.TERMINAL_MOVE_ARC_GLOBAL_POS)
        {
            if (_root_config.m_obj_finish_pos != null)
            {
                _root_config.m_finish_pos = new Vector2(_root_config.m_obj_finish_pos.transform.position.x,
                                                        _root_config.m_obj_finish_pos.transform.position.y);
            }

            if (!_root_config.m_is_use_external_start_position)
            {
                _root_config.m_start_pos = _root_config.m_control_object.transform.position;
            }
        }
        else if (_root_config.m_type == eEffectType.TERMINAL_CHANGE_SPRITE)
        {
            if (_root_config.m_control_object)
            {
                Image img = _root_config.m_control_object.GetComponent <Image>();
                if (img != null)
                {
                    _root_config.OldSprite = img.sprite;
                }
            }
        }
        else if (_root_config.m_type == eEffectType.TERMINAL_FILL_RECT)
        {
            if (_root_config.m_control_object)
            {
            }
        }
        else if (_root_config.m_type == eEffectType.TERMINAL_ANIMATION)
        {
        }

        cRunEffect root_effect = null;

        if (!_root_config.m_is_switch_off)
        {
            root_effect = cRunEffect.create(_root_config, this);

            foreach (Transform child in _root_config.gameObject.transform)
            {
                effectConfig child_config = child.GetComponent <effectConfig>();
                if (child_config != null && !child_config.m_is_switch_off)
                {
                    cRunEffect child_effect = generateEffectFrom(child_config);
                    if (child_effect != null)
                    {
                        //Debug.unityLogger.Log("Ariman", "generateEffectFrom: add: " + child_config.m_root_name);
                        root_effect.add(child_effect);
                    }
                }
            }
        }

        return(root_effect);
    }