コード例 #1
0
 public Action this[ConditionInt c]
 {
     get
     {
         Action val;
         if (!conditionDict.TryGetValue(c, out val))
         {
             if (DefaultAction != null)
             {
                 return(DefaultAction);
             }
             else
             {
                 return delegate() { Debug.Log("Unimplemented combination: " + c); }
             };
         }
         else
         {
             return(conditionDict[c]);
         }
     }
     set
     {
         conditionDict[c] = value;
     }
 }
コード例 #2
0
        public void TestInt()
        {
            var c1 = new ConditionInt(1, 2, 3, 4);
            var c2 = new ConditionInt(3, 4, 5, 6, 7, 8);
            var c3 = new ConditionInt(2, 4);
            var c4 = new ConditionInt(1);

            var funcTable = new FuncTableInt();

            funcTable[c1] = delegate() { Debug.Log(c1); };
            funcTable[c2] = delegate() { Debug.Log(c2); };
            funcTable[c3] = delegate() { Debug.Log(c3); };
            funcTable[c4] = delegate() { Debug.Log(c4); };

            Debug.Log("Test exact objects ---- >");

            funcTable[c1]();
            funcTable[c2]();
            funcTable[c3]();
            funcTable[c4]();

            Debug.Log("Test ephemeral indices ---- >");

            funcTable[new ConditionInt(1, 2, 3, 4)]();
            funcTable[new ConditionInt(3, 4, 5, 6, 7, 8)]();
            funcTable[new ConditionInt(2, 4)]();
            funcTable[new ConditionInt(1)]();
        }