Example #1
0
 public virtual void Display()
 {
     WhoIAm();
     SwimBehavior.Swim();
     FlyBehavior.Fly();
     QuackBehavior.Quack();
 }
Example #2
0
 public Duck(
     FlyBehavior flyBehavior,
     QuackBehavior quackBehavior,
     DisplayBehavior displayBehavior)
 {
     this.flyBehavior_     = flyBehavior;
     this.quackBehavior_   = quackBehavior;
     this.displayBehavior_ = displayBehavior;
 }
Example #3
0
 public void PerformFly()
 {
     if (FlyBehavior != null)
     {
         FlyBehavior.Fly();
     }
     else
     {
         Console.WriteLine("Уточка не умеет летать!");
     }
 }
Example #4
0
        static void Main(string [] args)
        {
            MallardDuck mallardDuck = new MallardDuck();

            PlayWithDuck(mallardDuck);
            RedheadDuck redheadDuck = new RedheadDuck();

            PlayWithDuck(redheadDuck);
            RubberDuck rubberDuck = new RubberDuck();

            PlayWithDuck(rubberDuck);
            DecoyDuck decoyDuck = new DecoyDuck();

            PlayWithDuck(decoyDuck);
            ModelDuck modelDuck = new ModelDuck();

            PlayWithDuck(modelDuck);
            modelDuck.SetFlyBehavior(FlyBehavior.FlyWithWingsAction());
            PlayWithDuck(modelDuck);
        }
Example #5
0
 // Update is called once per frame
 void Update()
 {
     while (flies.Count < spawnNumber)
     {
         randomize.x = Random.Range(1, 5);
         randomize.y = Random.Range(1, 5);
         randomize.z = Random.Range(1, 5);
         FlyBehavior newFly = Instantiate(fly, transform.position + randomize, transform.rotation);
         if (state == 1)
         {
             newFly.target   = playerTransform;
             secondaryTarget = newFly.GetComponent <Transform>();
             state++;
         }
         else if (state == 2)
         {
             newFly.target = secondaryTarget;
         }
         flies.Add(newFly);
     }
 }
        /// <summary>
        /// Creates a movement behavior based on the passed-in type.
        /// </summary>
        /// <param name="type">The type of behavior to create.</param>
        /// <returns>The created behavior.</returns>
        public static IMoveBehavior CreateMoveBehavior(MoveBehaviorType type)
        {
            IMoveBehavior result = null;

            switch (type)
            {
            case MoveBehaviorType.Climb:
                result = new ClimbBehavior();
                break;

            case MoveBehaviorType.Fly:
                result = new FlyBehavior();
                break;

            case MoveBehaviorType.Hover:
                result = new HoverBehavior();
                break;

            case MoveBehaviorType.Pace:
                result = new PaceBehavior();
                break;

            case MoveBehaviorType.Swim:
                result = new SwimBehavior();
                break;

            case MoveBehaviorType.NoMove:
                result = new NoMoveBehavior();
                break;

            default:
                break;
            }

            return(result);
        }
Example #7
0
 public RedHeadDuck(FlyBehavior fly) : base(fly)
 {
 }
Example #8
0
 public void TestFly()
 {
     flyer = new FlyWithWings();
     flyer.Fly();
     Assert.AreEqual("I'm flying!!", console.Output());
 }
Example #9
0
 public void PerformFly()
 {
     FlyBehavior.Fly();
 }
Example #10
0
 /// <summary>
 /// Присвоение объекта FlyBehavior для делегирования.
 /// </summary>
 /// <param name="fb">Делегируемый FlyBehavior</param>
 public void setFlyBehavior(FlyBehavior fb)
 {
     flyBehavior = fb;
 }
Example #11
0
 public void setFlyBehavior(FlyBehavior fb)
 {
     this.flyBehavior = fb;
 }
Example #12
0
 public DecoyDuck()
     : base(FlyBehavior.FlyWithWings(), QuackBehavior.MuteQuack, DanceBehavior.NoDance)
 {
 }
Example #13
0
 public string Fly()
 {
     return(FlyBehavior.Fly());
 }
Example #14
0
 public void SetFly(FlyBehavior flyBehavior)
 {
     this.flyBehavior = flyBehavior;
 }
Example #15
0
 public virtual void Fly()
 {
     FlyBehavior.Fly();
 }
Example #16
0
 public DecoyDuck(FlyBehavior flyBehavior, QuackBehavior quackBehavior) : base(flyBehavior, quackBehavior)
 {
 }
Example #17
0
 public void PerformLand()
 {
     FlyBehavior.Land();
 }
Example #18
0
 public void SetFlyBehavior(FlyBehavior _flyBehavior)
 {
     flyBehavior = _flyBehavior;
 }
Example #19
0
 // Replace behavior A when need
 public void setFlyBehavior(FlyBehavior newFlyBehavior)
 {
     flyBehavior = newFlyBehavior;
 }
 public void setFlyBehaviour(FlyBehavior flyBehavior)
 {
     this.flyBehavior = flyBehavior;
 }
 public void PerformFly() => FlyBehavior?.Fly();
Example #22
0
 public string PerformFly()
 {
     return(FlyBehavior.Fly());
 }
Example #23
0
 public DuckCall()
 {
     fb = new FlyNoWay();
     qb = new MuteQuack();
 }
Example #24
0
 public MallardDuck(FlyBehavior fly) : base(fly)
 {
 }
Example #25
0
 public void performFly()
 {
     FlyBehavior.fly();
 }
Example #26
0
 public void SetFlyBehavior(FlyBehavior fb)
 {
     FlyBehavior = fb;
 }
Example #27
0
 public void TestFly()
 {
     flyer = new FlyNoWay();
     flyer.Fly();
     Assert.AreEqual("I can't fly", console.Output());
 }
Example #28
0
 public MallardDuck()
     : base(FlyBehavior.FlyWithWings(), QuackBehavior.Quack, DanceBehavior.DanceWaltz)
 {
 }
Example #29
0
 public RedheadDuck()
     : base(FlyBehavior.FlyWithWings(), QuackBehavior.Quack, DanceBehavior.DanceMenuet)
 {
 }
Example #30
0
 void Awake()
 {
     flyBehavior = GetComponent <FlyBehavior>();
 }
Example #31
0
 public RedheadDuck()
     : base(FlyBehavior.FlyWithWingsAction(), DanceBehavior.DanceMinuet, QuackBehavior.Quack)
 {
 }
Example #32
0
 public RedheadDuck(FlyBehavior flyBehavior, QuackBehavior quackBehavior) : base(flyBehavior, quackBehavior)
 {
 }
Example #33
0
 public void SetFlyBehavior(FlyBehavior flyBehavior)
 {
     FlyBehavior = flyBehavior;
 }
Example #34
0
 public void setFlybehavior(FlyBehavior fb)
 {
     flyBehavior = fb;
 }
Example #35
0
 public void SetFlyBehavior(FlyBehavior fb)
 {
     flyBehavior = fb;
 }