Exemplo n.º 1
0
        private void button1_Click(object sender, EventArgs e)
        {
            int lMax  = 8;
            int lAccu = 0;

            catcher.SetEvent(listBox1, new EventHandler <string>(this.EvHandler));
            PointActor pa   = new PointActor();
            BaseActor  accu = new BaseActor(new Behavior <int>(
                                                i =>
            {
                lAccu++;
                catcher.SendMessage(lAccu.ToString());
            }
                                                ));

            pa.SendMessage("AddLevel", 0, lMax);
            pa.SendMessage("GiveLevel", (IActor)accu);
        }
Exemplo n.º 2
0
 public PointActor()
 {
     Become(new Behavior <string, int, int>(
                (s, i, m) =>
     {
         fLevel = i;
         fMax   = m;
         if (fLevel < m)
         {
             if (s == "AddLevel")
             {
                 fLeft  = new PointActor();
                 fRight = new PointActor();
                 fLeft.SendMessage(s, fLevel + 1, fMax);
                 fRight.SendMessage(s, fLevel + 1, fMax);
             }
         }
     }));
     AddBehavior(new Behavior <string, IActor>(
                     (s, a) =>
     {
         if (s == "GiveLevel")
         {
             a.SendMessage(fLevel);
             if (fLeft != null)
             {
                 fLeft.SendMessage(s, a);
             }
             if (fRight != null)
             {
                 fRight.SendMessage(s, a);
             }
         }
     }
                     ));
 }