Exemplo n.º 1
0
 static int AdditionField(IntPtr L)
 {
     try
     {
         ToLua.CheckArgsCount(L, 5);
         System.Reflection.FieldInfo arg0 = (System.Reflection.FieldInfo)ToLua.CheckObject(L, 1, typeof(System.Reflection.FieldInfo));
         VOBase arg1 = (VOBase)ToLua.CheckObject(L, 2, typeof(VOBase));
         VOBase arg2 = (VOBase)ToLua.CheckObject(L, 3, typeof(VOBase));
         VOBase arg3 = (VOBase)ToLua.CheckObject(L, 4, typeof(VOBase));
         System.Collections.Generic.IDictionary <string, ChangeDataType> arg4 = (System.Collections.Generic.IDictionary <string, ChangeDataType>)ToLua.CheckObject(L, 5, typeof(System.Collections.Generic.IDictionary <string, ChangeDataType>));
         SkillBase.AdditionField(arg0, arg1, arg2, arg3, arg4);
         return(0);
     }
     catch (Exception e)
     {
         return(LuaDLL.toluaL_exception(L, e));
     }
 }
Exemplo n.º 2
0
    /// <summary>
    /// 生成行为
    /// </summary>
    /// <param name="paramsPacker"></param>
    /// <returns>行为节点</returns>
    public override IFormula GetFormula(FormulaParamsPacker paramsPacker)
    {
        IFormula result = null;

        string errorMsg = null;

        if (paramsPacker == null)
        {
            errorMsg = "调用参数 paramsPacker 为空.";
        }
        else if (string.IsNullOrEmpty(PropertyName) || property == null)
        {
            errorMsg = "属性名称为空.";
        }
        else if (string.IsNullOrEmpty(Value))
        {
            errorMsg = "属性值为空";
        }

        if (!string.IsNullOrEmpty(errorMsg))
        {
            throw new Exception(errorMsg);
        }

        // 替换数据
        ReplaceData(paramsPacker);
        // 数据本地化
        var myFormulaType    = FormulaType;
        var myPropertyName   = PropertyName;
        var myValue          = Value;
        var myChangeDataType = ChangeDataType;
        var myProperty       = property;
        var myField          = field;
        var target           = ReceivePos == 0 ? paramsPacker.ReleaseMember.ClusterData.AllData.MemberData : paramsPacker.ReceiverMenber.ClusterData.AllData.MemberData;

        result = new Formula((callback, scope) =>
        {
            var changeData = new VOBase();
            // 给目标增加属性
            if (myProperty != null)
            {
                myProperty.SetValue(changeData, Convert.ChangeType(myValue, myProperty.PropertyType), null);
            }
            else if (myField != null)
            {
                myField.SetValue(changeData, Convert.ChangeType(myValue, myField.FieldType));
            }

            ChangeDataType tmpType = ChangeDataType.Absolute;
            if (paramsPacker.Skill.ChangeDataTypeDic.ContainsKey(myPropertyName))
            {
                tmpType = paramsPacker.Skill.ChangeDataTypeDic[myPropertyName];
                paramsPacker.Skill.ChangeDataTypeDic[myPropertyName] = myChangeDataType;
            }
            else
            {
                paramsPacker.Skill.ChangeDataTypeDic.Add(myPropertyName, myChangeDataType);
            }
            SkillBase.AdditionField(myField, target, changeData, paramsPacker.Skill.ChangedData, paramsPacker.Skill.ChangeDataTypeDic);

            paramsPacker.Skill.ChangeDataTypeDic[myPropertyName] = tmpType;
        },
                             myFormulaType);

        return(result);
    }