Beispiel #1
0
 static public int get_id(IntPtr l)
 {
     try {
         TableConfig.Const self = (TableConfig.Const)checkSelf(l);
         pushValue(l, true);
         pushValue(l, self.id);
         return(2);
     }
     catch (Exception e) {
         return(error(l, e));
     }
 }
Beispiel #2
0
 static public int constructor(IntPtr l)
 {
     try {
         TableConfig.Const o;
         o = new TableConfig.Const();
         pushValue(l, true);
         pushValue(l, o);
         return(2);
     }
     catch (Exception e) {
         return(error(l, e));
     }
 }
Beispiel #3
0
 static public int GetId(IntPtr l)
 {
     try {
         TableConfig.Const self = (TableConfig.Const)checkSelf(l);
         var ret = self.GetId();
         pushValue(l, true);
         pushValue(l, ret);
         return(2);
     }
     catch (Exception e) {
         return(error(l, e));
     }
 }
Beispiel #4
0
 static public int set_id(IntPtr l)
 {
     try {
         TableConfig.Const self = (TableConfig.Const)checkSelf(l);
         System.Int32      v;
         checkType(l, 2, out v);
         self.id = v;
         pushValue(l, true);
         return(1);
     }
     catch (Exception e) {
         return(error(l, e));
     }
 }
Beispiel #5
0
 static public int WriteToBinary(IntPtr l)
 {
     try {
         TableConfig.Const         self = (TableConfig.Const)checkSelf(l);
         GameFramework.BinaryTable a1;
         checkType(l, 2, out a1);
         self.WriteToBinary(a1);
         pushValue(l, true);
         return(1);
     }
     catch (Exception e) {
         return(error(l, e));
     }
 }
Beispiel #6
0
 static public int ReadFromBinary(IntPtr l)
 {
     try {
         TableConfig.Const         self = (TableConfig.Const)checkSelf(l);
         GameFramework.BinaryTable a1;
         checkType(l, 2, out a1);
         System.Int32 a2;
         checkType(l, 3, out a2);
         var ret = self.ReadFromBinary(a1, a2);
         pushValue(l, true);
         pushValue(l, ret);
         return(2);
     }
     catch (Exception e) {
         return(error(l, e));
     }
 }
            internal long Calc(SceneContextInfo context, CharacterProperty source, CharacterProperty target, long[] args, Dictionary <int, long> variables)
            {
                m_Stack.Clear();
                for (int i = 0; i < m_Codes.Count; ++i)
                {
                    Instruction ins = m_Codes[i];
                    switch (ins.Opcode)
                    {
                    case InsEnum.CONST:
                        m_Stack.Push(ins.Operand);
                        break;

                    case InsEnum.ATTR: {
                        int  id  = (int)ins.Operand;
                        long val = source.GetLong((CharacterPropertyEnum)id);
                        m_Stack.Push(val);
                    }
                    break;

                    case InsEnum.ATTR2: {
                        int  id  = (int)ins.Operand;
                        long val = target.GetLong((CharacterPropertyEnum)id);
                        m_Stack.Push(val);
                    }
                    break;

                    case InsEnum.VALUE: {
                        int id = (int)ins.Operand;
                        TableConfig.Const cfg = TableConfig.ConstProvider.Instance.GetConst(id);
                        if (null != cfg)
                        {
                            m_Stack.Push(cfg.value);
                        }
                        else
                        {
                            m_Stack.Push(0);
                        }
                    }
                    break;

                    case InsEnum.ARG: {
                        int index = (int)ins.Operand;
                        if (index >= 0 && index < args.Length)
                        {
                            m_Stack.Push(args[index]);
                        }
                        else
                        {
                            m_Stack.Push(0);
                        }
                    }
                    break;

                    case InsEnum.VAR: {
                        int  id = (int)ins.Operand;
                        long ret;
                        if (!variables.TryGetValue(id, out ret))
                        {
                            ret = 0;
                        }
                        m_Stack.Push(ret);
                    }
                    break;

                    case InsEnum.ATTRSET: {
                        long op2 = m_Stack.Pop();
                        int  id  = (int)ins.Operand;
                        TableConfig.AttrDefine cfg = TableConfig.AttrDefineProvider.Instance.GetAttrDefine(id);
                        if (null != cfg)
                        {
                            if (op2 < cfg.minValue)
                            {
                                op2 = cfg.minValue;
                            }
                            if (op2 > cfg.maxValue)
                            {
                                op2 = cfg.maxValue;
                            }
                        }
                        source.SetLong((CharacterPropertyEnum)id, op2);
                        m_Stack.Push(op2);
                    }
                    break;

                    case InsEnum.VARSET: {
                        long op2 = m_Stack.Pop();
                        int  id  = (int)ins.Operand;
                        variables[id] = op2;
                        m_Stack.Push(op2);
                    }
                    break;

                    case InsEnum.ADD: {
                        long op2 = m_Stack.Pop();
                        long op1 = m_Stack.Pop();
                        m_Stack.Push(op1 + op2);
                    }
                    break;

                    case InsEnum.SUB: {
                        long op2 = m_Stack.Pop();
                        long op1 = m_Stack.Pop();
                        m_Stack.Push(op1 - op2);
                    }
                    break;

                    case InsEnum.MUL: {
                        long op2 = m_Stack.Pop();
                        long op1 = m_Stack.Pop();
                        m_Stack.Push(op1 * op2);
                    }
                    break;

                    case InsEnum.DIV: {
                        long op2 = m_Stack.Pop();
                        long op1 = m_Stack.Pop();
                        m_Stack.Push(op1 / op2);
                    }
                    break;

                    case InsEnum.MOD: {
                        long op2 = m_Stack.Pop();
                        long op1 = m_Stack.Pop();
                        m_Stack.Push(op1 % op2);
                    }
                    break;

                    case InsEnum.MAX: {
                        long op2 = m_Stack.Pop();
                        long op1 = m_Stack.Pop();
                        m_Stack.Push(op1 >= op2 ? op1 : op2);
                    }
                    break;

                    case InsEnum.MIN: {
                        long op2 = m_Stack.Pop();
                        long op1 = m_Stack.Pop();
                        m_Stack.Push(op1 <= op2 ? op1 : op2);
                    }
                    break;

                    case InsEnum.ABS: {
                        long op2 = m_Stack.Pop();
                        m_Stack.Push(op2 >= 0 ? op2 : -op2);
                    }
                    break;

                    case InsEnum.CLAMP: {
                        long op3 = m_Stack.Pop();
                        long op2 = m_Stack.Pop();
                        long op1 = m_Stack.Pop();
                        if (op3 < op1)
                        {
                            m_Stack.Push(op1);
                        }
                        else if (op3 > op2)
                        {
                            m_Stack.Push(op2);
                        }
                        else
                        {
                            m_Stack.Push(op3);
                        }
                    }
                    break;
                    }
                }
                return(m_Stack.Pop());
            }