private ScriptExecuteSettingBase CloneCore(bool withChange)
    {
        Assembly assembly             = AllScriptExecuteSettings.CurrentAssembly; // 获取当前程序集
        ScriptExecuteSettingBase copy = (ScriptExecuteSettingBase)assembly.CreateInstance("ScriptExecuteSettings." + Name);

        copy.Name                    = Name;
        copy.DescRaws                = CloneVariantUtils.SortedDictionary(DescRaws);
        copy.TriggerTime             = TriggerTime;
        copy.TriggerRange            = TriggerRange;
        copy.TriggerTimes            = TriggerTimes;
        copy.TriggerDelayTimes       = TriggerDelayTimes;
        copy.RemoveTriggerTime       = RemoveTriggerTime;
        copy.RemoveTriggerRange      = RemoveTriggerRange;
        copy.RemoveTriggerTimes      = RemoveTriggerTimes;
        copy.RemoveTriggerDelayTimes = RemoveTriggerDelayTimes;
        if (withChange)
        {
            copy.M_SideEffectParam = M_SideEffectParam.CloneWithFactor();
        }
        else
        {
            copy.M_SideEffectParam = M_SideEffectParam.Clone();
        }
        return(copy);
    }
Beispiel #2
0
 private static void addScriptExecuteSetting(ScriptExecuteSettingBase scriptExecuteSettingBase)
 {
     if (!ScriptExecuteSettingsNameDict.ContainsKey(scriptExecuteSettingBase.Name))
     {
         ScriptExecuteSettingsNameDict.Add(scriptExecuteSettingBase.Name, scriptExecuteSettingBase);
     }
 }
Beispiel #3
0
    public static ScriptExecuteSettingBase GetNewScriptExecuteSetting(string ScriptsExecuteSettingName)
    {
        Type type = mScriptsExecuteSettingMap[ScriptsExecuteSettingName];
        ScriptExecuteSettingBase newSESB = (ScriptExecuteSettingBase)type.Assembly.CreateInstance(type.ToString());

        return(newSESB);
    }
Beispiel #4
0
    public static void AddAllScriptExecuteSettings()
    {
        Reset();
        SortedDictionary <string, string> descKeyDict = new SortedDictionary <string, string>();

        foreach (int v in Enum.GetValues(typeof(LanguageShorts)))
        {
            string strName = Enum.GetName(typeof(LanguageShorts), v);
            descKeyDict[strName] = "desc_" + strName;
        }

        string text;

        using (StreamReader sr = new StreamReader(ScriptExecuteSettingsXMLFile))
        {
            text = sr.ReadToEnd();
        }

        XmlDocument doc = new XmlDocument();

        doc.LoadXml(text);
        XmlElement node_AllScriptExecuteSettings = doc.DocumentElement;

        for (int i = 0; i < node_AllScriptExecuteSettings.ChildNodes.Count; i++)
        {
            XmlNode node_ScriptExecuteSetting = node_AllScriptExecuteSettings.ChildNodes.Item(i);

            string name = node_ScriptExecuteSetting.Attributes["name"].Value;
            ScriptExecuteSettingBase se = (ScriptExecuteSettingBase)CurrentAssembly.CreateInstance("ScriptExecuteSettings." + name);

            if (se == null)
            {
                Utils.DebugLog("ScriptExecuteSettings: " + name + " does not exist");
                continue;
            }

            se.Name     = node_ScriptExecuteSetting.Attributes["name"].Value;
            se.DescRaws = new SortedDictionary <string, string>();
            foreach (KeyValuePair <string, string> kv in descKeyDict)
            {
                se.DescRaws[kv.Key] = node_ScriptExecuteSetting.Attributes[kv.Value].Value;
            }

            addScriptExecuteSetting(se);
        }
    }
Beispiel #5
0
    public void Initialize(SideEffectExecute see, UnityAction onRefreshText, bool isReadOnly, bool isExecuteSettingTypeChanged)
    {
        Initializing = true;
        foreach (PropertyFormRow cpfr in CardPropertyFormRows)
        {
            cpfr.PoolRecycle();
        }

        CardPropertyFormRows.Clear();

        bool isScriptExecuteSetting = see.M_ExecuteSetting is ScriptExecuteSettingBase;

        PFR_ScriptExecuteSettingType.gameObject.SetActive(isScriptExecuteSetting);
        ScriptExecuteSettingBase sesb = null;

        if (isScriptExecuteSetting)
        {
            sesb = (ScriptExecuteSettingBase)see.M_ExecuteSetting;
            ScriptExecuteSettingTypeDropdown.options.Clear();
            foreach (string option in AllScriptExecuteSettings.ScriptExecuteSettingsNameDict.Keys.ToList())
            {
                ScriptExecuteSettingTypeDropdown.options.Add(new Dropdown.OptionData(option));
            }

            ScriptExecuteSettingTypeDropdown.onValueChanged.RemoveAllListeners();
            SetScriptExecuteSettingType(sesb.Name);
            ScriptExecuteSettingTypeDropdown.onValueChanged.AddListener(delegate(int index)
            {
                string scriptExecuteSettingName  = ScriptExecuteSettingTypeDropdown.options[index].text;
                ScriptExecuteSettingBase newSESB = AllScriptExecuteSettings.GetScriptExecuteSetting(scriptExecuteSettingName);
                if (see != null)
                {
                    see.M_ExecuteSetting = newSESB;
                }

                Initialize(see, onRefreshText, isReadOnly, false);
                onRefreshText();
                StartCoroutine(ClientUtils.UpdateLayout((RectTransform)ExecuteRowContainer));
                StartCoroutine(ClientUtils.UpdateLayout((RectTransform)UIManager.Instance.GetBaseUIForm <CardEditorPanel>().CardPropertiesContainer));
            });

            CardEditorPanel_Params.GenerateParamRows(null, sesb.M_SideEffectParam, onRefreshText, delegate { Initialize(see, onRefreshText, isReadOnly, false); }, ExecuteRowContainer, CardPropertyFormRows, null, delegate
            {
                StartCoroutine(ClientUtils.UpdateLayout((RectTransform)ExecuteRowContainer));
                StartCoroutine(ClientUtils.UpdateLayout((RectTransform)UIManager.Instance.GetBaseUIForm <CardEditorPanel>().CardPropertiesContainer));
            });
        }

        PropertyFormRow            cpfr_TriggerRange     = null;
        UnityAction <string, bool> _setValueTriggerRange = null;
        PropertyFormRow            cpfr_TriggerTime      = PropertyFormRow.BaseInitialize(PropertyFormRow.CardPropertyFormRowType.Dropdown, ExecuteRowContainer, "CardEditorPanel_TriggerTime",
                                                                                          delegate(string value_str)
        {
            SideEffectExecute.TriggerTime value = (SideEffectExecute.TriggerTime)Enum.Parse(typeof(SideEffectExecute.TriggerTime), value_str);
            see.M_ExecuteSetting.TriggerTime    = value;
            List <string> trList = SideEffectExecute.GetTriggerRangeListByTriggerTime(see.M_ExecuteSetting.TriggerTime);
            ((PropertyFormRow_Dropdown)cpfr_TriggerRange).RefreshDropdownOptionList(trList);
            if (!Initializing && (see.ExecuteSettingType == SideEffectExecute.ExecuteSettingTypes.Scripts || see.ExecuteSettingType == SideEffectExecute.ExecuteSettingTypes.Others))
            {
                _setValueTriggerRange(trList[0], true);
            }
            onRefreshText?.Invoke();
        },
                                                                                          out UnityAction <string, bool> _setValueTriggerTime, sesb != null ? ScriptExecuteSettingBase.HashSetTriggerTimeToListString(sesb.ValidTriggerTimes) : triggerTimeTypeList);

        CardPropertyFormRows.Add(cpfr_TriggerTime);
        cpfr_TriggerTime.SetReadOnly(isReadOnly);

        cpfr_TriggerRange = PropertyFormRow.BaseInitialize(PropertyFormRow.CardPropertyFormRowType.Dropdown, ExecuteRowContainer, "CardEditorPanel_TriggerRange",
                                                           delegate(string value_str)
        {
            SideEffectExecute.TriggerRange value = (SideEffectExecute.TriggerRange)Enum.Parse(typeof(SideEffectExecute.TriggerRange), value_str);
            see.M_ExecuteSetting.TriggerRange    = value;
            onRefreshText?.Invoke();
        },
                                                           out _setValueTriggerRange, SideEffectExecute.GetTriggerRangeListByTriggerTime(see.M_ExecuteSetting.TriggerTime));
        CardPropertyFormRows.Add(cpfr_TriggerRange);
        cpfr_TriggerRange.SetReadOnly(isReadOnly);
        ((PropertyFormRow_Dropdown)cpfr_TriggerRange).RefreshDropdownOptionList(SideEffectExecute.GetTriggerRangeListByTriggerTime(see.M_ExecuteSetting.TriggerTime));

        PropertyFormRow cpfr_TriggerTimes = PropertyFormRow.BaseInitialize(PropertyFormRow.CardPropertyFormRowType.InputField, ExecuteRowContainer, "CardEditorPanel_TriggerTimes",
                                                                           delegate(string value_str)
        {
            if (int.TryParse(value_str, out int value))
            {
                see.M_ExecuteSetting.TriggerTimes = value;
                onRefreshText?.Invoke();
            }
        },
                                                                           out UnityAction <string, bool> _setValueTriggerTimes);

        CardPropertyFormRows.Add(cpfr_TriggerTimes);
        cpfr_TriggerTimes.SetReadOnly(sesb != null ? sesb.LockedTriggerTimes != ScriptExecuteSettingBase.UNLOCKED_EXECUTESETTING_TIMES : isReadOnly);

        PropertyFormRow cpfr_TriggerDelayTimes = PropertyFormRow.BaseInitialize(PropertyFormRow.CardPropertyFormRowType.InputField, ExecuteRowContainer, "CardEditorPanel_TriggerDelayTimes",
                                                                                delegate(string value_str)
        {
            if (int.TryParse(value_str, out int value))
            {
                see.M_ExecuteSetting.TriggerDelayTimes = value;
                onRefreshText?.Invoke();
            }
        },
                                                                                out UnityAction <string, bool> _setValueTriggerDelayTimes);

        CardPropertyFormRows.Add(cpfr_TriggerDelayTimes);
        cpfr_TriggerDelayTimes.SetReadOnly(sesb != null ? sesb.LockedTriggerDelayTimes != ScriptExecuteSettingBase.UNLOCKED_EXECUTESETTING_TIMES : isReadOnly);

        PropertyFormRow            cpfr_RemoveTriggerRange     = null;
        UnityAction <string, bool> _setValueRemoveTriggerRange = null;
        PropertyFormRow            cpfr_RemoveTriggerTime      = PropertyFormRow.BaseInitialize(PropertyFormRow.CardPropertyFormRowType.Dropdown, ExecuteRowContainer, "CardEditorPanel_RemoveTriggerTime",
                                                                                                delegate(string value_str)
        {
            SideEffectExecute.TriggerTime value    = (SideEffectExecute.TriggerTime)Enum.Parse(typeof(SideEffectExecute.TriggerTime), value_str);
            see.M_ExecuteSetting.RemoveTriggerTime = value;
            List <string> trList = SideEffectExecute.GetTriggerRangeListByTriggerTime(see.M_ExecuteSetting.RemoveTriggerTime);
            ((PropertyFormRow_Dropdown)cpfr_RemoveTriggerRange).RefreshDropdownOptionList(trList);
            if (!Initializing && (see.ExecuteSettingType == SideEffectExecute.ExecuteSettingTypes.Scripts || see.ExecuteSettingType == SideEffectExecute.ExecuteSettingTypes.Others))
            {
                _setValueRemoveTriggerRange(trList[0], true);
            }
            onRefreshText?.Invoke();
        },
                                                                                                out UnityAction <string, bool> _setValueRemoveTriggerTime, sesb != null ? ScriptExecuteSettingBase.HashSetTriggerTimeToListString(sesb.ValidRemoveTriggerTimes) : triggerTimeTypeList);

        CardPropertyFormRows.Add(cpfr_RemoveTriggerTime);
        cpfr_RemoveTriggerTime.SetReadOnly(isReadOnly);

        cpfr_RemoveTriggerRange = PropertyFormRow.BaseInitialize(PropertyFormRow.CardPropertyFormRowType.Dropdown, ExecuteRowContainer, "CardEditorPanel_RemoveTriggerRange",
                                                                 delegate(string value_str)
        {
            SideEffectExecute.TriggerRange value    = (SideEffectExecute.TriggerRange)Enum.Parse(typeof(SideEffectExecute.TriggerRange), value_str);
            see.M_ExecuteSetting.RemoveTriggerRange = value;
            onRefreshText?.Invoke();
        },
                                                                 out _setValueRemoveTriggerRange, SideEffectExecute.GetTriggerRangeListByTriggerTime(see.M_ExecuteSetting.RemoveTriggerTime));
        CardPropertyFormRows.Add(cpfr_RemoveTriggerRange);
        cpfr_RemoveTriggerRange.SetReadOnly(isReadOnly);
        ((PropertyFormRow_Dropdown)cpfr_RemoveTriggerRange).RefreshDropdownOptionList(SideEffectExecute.GetTriggerRangeListByTriggerTime(see.M_ExecuteSetting.RemoveTriggerTime));

        PropertyFormRow cpfr_RemoveTriggerTimes = PropertyFormRow.BaseInitialize(PropertyFormRow.CardPropertyFormRowType.InputField, ExecuteRowContainer, "CardEditorPanel_RemoveTriggerTimes",
                                                                                 delegate(string value_str)
        {
            if (int.TryParse(value_str, out int value))
            {
                see.M_ExecuteSetting.RemoveTriggerTimes = value;
                onRefreshText?.Invoke();
            }
        },
                                                                                 out UnityAction <string, bool> _setValueRemoveTriggerTimes);

        CardPropertyFormRows.Add(cpfr_RemoveTriggerTimes);
        cpfr_RemoveTriggerTimes.SetReadOnly(sesb != null ? sesb.LockedRemoveTriggerTimes != ScriptExecuteSettingBase.UNLOCKED_EXECUTESETTING_TIMES : isReadOnly);

        PropertyFormRow cpfr_RemoveTriggerDelayTimes = PropertyFormRow.BaseInitialize(PropertyFormRow.CardPropertyFormRowType.InputField, ExecuteRowContainer, "CardEditorPanel_RemoveTriggerDelayTimes",
                                                                                      delegate(string value_str)
        {
            if (int.TryParse(value_str, out int value))
            {
                see.M_ExecuteSetting.RemoveTriggerDelayTimes = value;
                onRefreshText?.Invoke();
            }
        },
                                                                                      out UnityAction <string, bool> _setValueRemoveTriggerDelayTimes);

        CardPropertyFormRows.Add(cpfr_RemoveTriggerDelayTimes);
        cpfr_RemoveTriggerDelayTimes.SetReadOnly(sesb != null ? sesb.LockedRemoveTriggerDelayTimes != ScriptExecuteSettingBase.UNLOCKED_EXECUTESETTING_TIMES : isReadOnly);

        _setValueTriggerTime(sesb != null ? (sesb.ValidTriggerTimes.Count != 0 ? sesb.ValidTriggerTimes.ToList()[0].ToString() : SideEffectExecute.TriggerTime.None.ToString()) : see.M_ExecuteSetting.TriggerTime.ToString(), isExecuteSettingTypeChanged);
        _setValueTriggerRange(see.M_ExecuteSetting.TriggerRange.ToString(), isExecuteSettingTypeChanged);
        _setValueTriggerTimes(sesb != null ? (sesb.LockedTriggerTimes != ScriptExecuteSettingBase.UNLOCKED_EXECUTESETTING_TIMES ? sesb.LockedTriggerTimes.ToString() : see.M_ExecuteSetting.TriggerTimes.ToString()) : see.M_ExecuteSetting.TriggerTimes.ToString(), isExecuteSettingTypeChanged);
        _setValueTriggerDelayTimes(sesb != null ? (sesb.LockedTriggerDelayTimes != ScriptExecuteSettingBase.UNLOCKED_EXECUTESETTING_TIMES ? sesb.LockedTriggerDelayTimes.ToString() : see.M_ExecuteSetting.TriggerDelayTimes.ToString()) : see.M_ExecuteSetting.TriggerDelayTimes.ToString(), isExecuteSettingTypeChanged);
        _setValueRemoveTriggerTime(sesb != null ? (sesb.ValidRemoveTriggerTimes.Count != 0 ? sesb.ValidRemoveTriggerTimes.ToList()[0].ToString() : SideEffectExecute.TriggerTime.None.ToString()) : see.M_ExecuteSetting.RemoveTriggerTime.ToString(), isExecuteSettingTypeChanged);
        _setValueRemoveTriggerRange(see.M_ExecuteSetting.RemoveTriggerRange.ToString(), isExecuteSettingTypeChanged);
        _setValueRemoveTriggerTimes(sesb != null ? (sesb.LockedRemoveTriggerTimes != ScriptExecuteSettingBase.UNLOCKED_EXECUTESETTING_TIMES ? sesb.LockedRemoveTriggerTimes.ToString() : see.M_ExecuteSetting.RemoveTriggerTimes.ToString()) : see.M_ExecuteSetting.RemoveTriggerTimes.ToString(), isExecuteSettingTypeChanged);
        _setValueRemoveTriggerDelayTimes(sesb != null ? (sesb.LockedRemoveTriggerDelayTimes != ScriptExecuteSettingBase.UNLOCKED_EXECUTESETTING_TIMES ? sesb.LockedRemoveTriggerDelayTimes.ToString() : see.M_ExecuteSetting.RemoveTriggerDelayTimes.ToString()) : see.M_ExecuteSetting.RemoveTriggerDelayTimes.ToString(), isExecuteSettingTypeChanged);

        Initializing = false;
    }