コード例 #1
0
ファイル: PropertyBag.cs プロジェクト: mdwheele/bomberman
 public float GetSingleValue(int variableNameId, float defaultValue = 0f)
 {
     foreach (IntVariable variable in IntVariables)
     {
         if (((uint)variable.Id | 0x80000000) == (uint)variableNameId)
         {
             Debug.Assert(((uint)variable.Id & 0x80000000) != 0, "bool variable stored here");
             Int32SingleUnion temp = new Int32SingleUnion(variable.Value);
             return(temp.AsSingle);
         }
     }
     return(defaultValue);
 }
コード例 #2
0
ファイル: PropertyBag.cs プロジェクト: mdwheele/bomberman
        public void SetValue(int variableNameId, float value)
        {
            Int32SingleUnion temp = new Int32SingleUnion(value);
            int intValue          = temp.AsInt32;

            bool found = false;

            for (int i = 0; !found && (i < IntVariables.Count); i++)
            {
                IntVariable bv = IntVariables[i];
                found = (((uint)bv.Id | 0x80000000) == (uint)variableNameId);
                if (found)
                {
                    Debug.Assert(((uint)bv.Id & 0x80000000) != 0, "bool variable stored here");
                    bv.Value        = intValue;
                    IntVariables[i] = bv;
                }
            }
            if (!found)
            {
                IntVariables.Add(new IntVariable(variableNameId, intValue));
            }
        }