示例#1
0
        public static SkAttribsModifier Create(string desc)
        {
            if (desc.Equals("0") || desc.Equals(""))
            {
                return(null);
            }

            SkAttribsModifier modifier = new SkAttribsModifier();

            string[] strMods = desc.Split('#');                 // use this as splitter because it is not used in expression
            foreach (string strMod in strMods)
            {
                string[] descOp = strMod.Split(new Char[] { ',' }, 2);
                switch (descOp[0].ToLower())
                {
                case "mat":     {
                    SkAttribsOpMAT op = new SkAttribsOpMAT(descOp[1]);
                    modifier._tmpOps.Add(op);
                    modifier._tmpOpsIdxs.Add(op._idx);
                }
                break;

                case "mad":
                    modifier._ops.Add(new SkAttribsOpMAD(descOp[1]));
                    break;

                case "exp":
                {
                    SkAttribsOpEXP op = new SkAttribsOpEXP(descOp[1]);
                    if (op._bTmpOp)
                    {
                        modifier._tmpOps.Add(op);
                        modifier._tmpOpsIdxs.Add(op._idx);
                    }
                    else
                    {
                        modifier._ops.Add(op);
                    }
                }
                break;

                case "get":
                    modifier._ops.Add(new SkAttribsOpGET(descOp[1]));
                    break;

                case "rnd":
                    modifier._ops.Add(new SkAttribsOpRND(descOp[1]));
                    break;

                default:
                    Debug.Log("[Error]:Unrecognized atttribModifier." + strMod);
                    continue;
                }
            }
            return(modifier);
        }
示例#2
0
        public void TryExecTmp(ISkAttribs dst, ISkAttribs paraCaster, ISkAttribs paraTarget, ISkAttribsModPara para, int idxToMod, int times = 1)
        {
            int n = _tmpOpsIdxs.Count;

            for (int i = 0; i < n; i++)
            {
                if (_tmpOpsIdxs[i] == idxToMod)
                {
                    for (int j = 0; j < times; j++)
                    {
                        _tmpOps[i].Exec(dst, paraCaster, paraTarget, para);

                        SkAttribsOpMAT op = _tmpOps[i] as SkAttribsOpMAT;
                        if (op != null)
                        {
                            dst.buffMul     += op._mul;
                            dst.buffPreAdd  += op._preAdd;
                            dst.buffPostAdd += op._postAdd;
                        }
                    }
                }
            }
        }