/** 计算属性 (int * (1 + intPer) + add) * (1 + per) */ public static void Calculate(this float[] src) { List <PropIdGroup> list = PropId.GetPropListA(); foreach (PropIdGroup group in list) { // final = (int * (1 + intPer) + add) * (1 + per) src[group.final] = (src[group.init] * (1 + src[group.initPer]) + src[group.add]) * (1 + src[group.per] / 100F); src[group.final].Limit(group.final); } list = PropId.GetPropListC(); foreach (PropIdGroup group in list) { // final = (int * (1 + intPer) + add + convertFinal * convertRate) * (1 + per) // src[group.final] = ( src[group.init] * ( 1 + src[group.initPer] ) + src[group.add] + src[group.cFinal] * group.cRate) * (1 + src[group.per] / 100F); src[group.final] = ((src[group.init] + src[group.cInit] * group.cRate) * (1 + src[group.initPer] + src[group.cInitPer] * group.cRate) + src[group.add] + src[group.cAdd] * group.cRate) * (1 + (src[group.per] + src[group.cPer] * group.cRate) / 100F); src[group.final].Limit(group.final); // if(group.final == PropId.MoveSpeed) // { // Debug.Log("solider src[group.final]=" + src[group.final] + " src[group.convertFinal]=" + src[group.convertFinal] + " group.convertRate=" + group.convertRate + " src[group.init]=" + src[group.init] + " src[group.per]=" + src[group.per]); // } } list = PropId.GetPropListB(); foreach (PropIdGroup group in list) { src[group.final] = (src[group.final] + src[group.init] * src[group.initPer] + src[group.add]) * (1 + src[group.per] / 100F); src[group.initPer] = 0; src[group.add] = 0; src[group.per] = 0; } }
public static float[] PropsToInit(this float[] src) { float[] props = new float[PropId.MAX]; List <PropIdGroup> list = PropId.GetPropListA(); foreach (PropIdGroup group in list) { props[group.init] = src[group.add] * (1 + src[group.per] / 100F); } list = PropId.GetPropListC(); foreach (PropIdGroup group in list) { props[group.init] = src[group.add] * (1 + src[group.per] / 100F); } list = PropId.GetPropListB(); foreach (PropIdGroup group in list) { props[group.init] = src[group.add] * (1 + src[group.per] / 100F); } return(props); }