Inheritance: MonoBehaviour
示例#1
0
        public void RunSimulator()
        {
            // Dog Door Simulator

            DogDoor door   = new DogDoor();
            Remote  remote = new Remote(door);
            //Create the BarkRecognizer, connect it to the door, and let it listen for some barking.
            BarkRecognizer barkRecognizer = new BarkRecognizer(door);

            String sound = "bark";
            Bark   bark  = new Bark(sound);

            //Thread currentThread = Thread.CurrentThread;

            door.addAllowedBark(new Bark("rowlf"));
            door.addAllowedBark(new Bark("rooowlf"));
            door.addAllowedBark(new Bark("rawlf"));
            door.addAllowedBark(new Bark("woof"));


            // Simulate the hardware hearing a bark
            Console.WriteLine("Bruce starts barking.");
            barkRecognizer.Recognize(new Bark("rowlf"));

            Console.WriteLine("\nBruce has gone outside...");
            DogLockedOut(barkRecognizer);

            // Simulate the hardware hearing a bark (not Bruce!)
            Bark smallDogBark = new Bark("yip");

            Console.WriteLine("A small dog starts barking");
            barkRecognizer.Recognize(smallDogBark);

            try
            {
                Thread.Sleep(5000);
            }
            catch (ThreadInterruptedException) { }

            Console.WriteLine("Bruce starts barking.");
            barkRecognizer.Recognize(new Bark("rooowlf"));

            Console.WriteLine("\n Bruce's back inside");
        }
示例#2
0
 public Dog()
 {
     Sound = new Bark();
 }
示例#3
0
 void Start()
 {
     speakBehavior = new Bark();
     moveBehavior  = new Walk();
 }