Example #1
0
        public VarRef(VarValue v)
        {
            mVarName = null;
            mTrigger = null;

            Value = v;
        }
Example #2
0
 //冥
 public static VarValue Power(VarValue lhs, VarValue rhs)
 {
     if (false == lhs.IsNil || false == rhs.IsNil)
     {
         if (lhs.mEType == rhs.mEType)
         {
             if (rhs.mEType == EType.Int)
             {
                 return(new VarValue((int)UnityEngine.Mathf.Pow((int)lhs.mValue, (int)rhs.mValue)));
             }
             else if (rhs.mEType == EType.Float)
             {
                 return(new VarValue((float)UnityEngine.Mathf.Pow((float)lhs.mValue, (float)rhs.mValue)));
             }
         }
         else
         {
             if (rhs.mEType == EType.Float)
             {
                 if (lhs.mEType == EType.Int)
                 {
                     return(new VarValue((int)UnityEngine.Mathf.Pow((int)lhs.mValue, (float)rhs.mValue)));
                 }
             }
             else if (rhs.mEType == EType.Int)
             {
                 if (lhs.mEType == EType.Float)
                 {
                     return(new VarValue((float)UnityEngine.Mathf.Pow((float)lhs.mValue, (int)rhs.mValue)));
                 }
             }
         }
     }
     throw new System.NotSupportedException(lhs.ToString() + " Pow(" + rhs.ToString() + ") not supported.");
 }
Example #3
0
        public static VarRef Deserialize(Stream stream, Trigger trigger)
        {
            using (BinaryReader r = new BinaryReader(stream))
            {
                if (r.ReadBoolean())
                {
                    BinaryFormatter b        = new BinaryFormatter();
                    VarValue        varValue = b.Deserialize(stream) as VarValue;
                    return(new VarRef(varValue));
                }
                else
                {
                    string name = r.ReadString();

                    return(new VarRef(name, trigger));
                }
            }
        }
Example #4
0
        //if is variable name, it must be bracketed in %
        public static VarRef GetVarRefOrValue(XmlNode xmlNode, string name, VarValue.EType eType, Trigger trigger)
        {
            VarRef varRef = null;

            string text = Util.GetString(xmlNode, name);

            if (IsVarName(text))
            {
                string varName = GetVarName(text);
                varRef = new VarRef(varName, trigger);
            }
            else
            {
                VarValue varValue = GetVarValue(text, eType);
                varRef = new VarRef(varValue);
            }

            return(varRef);
        }
Example #5
0
 public override void Do()
 {
     mTarget.Value = VarValue.Power(mTarget.Value, mArg.Value);
 }
Example #6
0
 public Variable()
 {
     mValue = null;
 }
Example #7
0
 public Variable(VarValue v)
 {
     mValue = v;
 }