Ejemplo n.º 1
0
        public void TestMethod1()
        {
            IFlyBehaviour flyBehaviour = new FlyBehaviour();

            MallardDuck mallardDuck = new MallardDuck(flyBehaviour);
            RedheadDuck redheadDuck = new RedheadDuck(flyBehaviour);

            IFlyBehaviour noFlyBehaviour = new NoFlyBehaviour();
            RubberDuck    rubberDuck     = new RubberDuck(noFlyBehaviour);


            mallardDuck.Display();
            mallardDuck.Fly();

            redheadDuck.Display();
            redheadDuck.Fly();

            rubberDuck.Display();
            rubberDuck.Fly();

            rubberDuck.ChangeFlyBehaviour(flyBehaviour);
            rubberDuck.Fly();

            redheadDuck.Swim();
            mallardDuck.Swim();
            rubberDuck.Swim();
        }
Ejemplo n.º 2
0
 private void Pickup(string powerUpType)
 {
     if (powerUpType == "PowerUpElectric")
     {
         this.hasPlasma = true;
     }
     else if (powerUpType == "PowerUpRocket")
     {
         this.hasRocket = true;
     }
     else if (powerUpType == "PowerUpHealthBlue") // defend for car  , fly power for shooter
     {
         if (isShooter)
         {
             FlyBehaviour flyBehaviour = this.GetComponent <FlyBehaviour>();
             flyBehaviour.setFlyPoints();
         }
         else if (isDriver)
         {
             CarHealthManager carHealthManager = this.GetComponent <CarHealthManager>();
             carHealthManager.SetDefendPoints();
         }
     }
     else if (powerUpType == "PowerUpHealthRed")
     {
         if (isShooter)
         {
             HealthManager healthManager = this.GetComponent <HealthManager>();
             healthManager.SetHealthPoints();
         }
         else if (isDriver)
         {
             CarHealthManager carHealthManager = this.GetComponent <CarHealthManager>();
             carHealthManager.SetHealthPoints();
             try
             {
                 Destroy((transform.Find("SmokeEffect(Clone)")).gameObject);
             }
             catch (Exception e)
             {
                 print("no effect");
             }
         }
     }
     else if (powerUpType == "PowerUpEuro") // defend for ran over for shooter
     {
         HealthManager healthManager = this.GetComponent <HealthManager>();
         healthManager.hasDefened = true;
     }
     else if (powerUpType == "PowerUpDollar") // fireball for cars
     {
         this.hasBall = true;
     }
 }
Ejemplo n.º 3
0
    // Start is always called after any Awake functions.
    void Start()
    {
        flys = GetComponent <FlyBehaviour>();
        // Set up the references.
        aimBool = Animator.StringToHash("Aim");

        cornerBool = Animator.StringToHash("Corner");

        initialRootRotation  = behaviourManager.GetAnim.GetBoneTransform(HumanBodyBones.Hips).parent.localEulerAngles;
        initialHipsRotation  = behaviourManager.GetAnim.GetBoneTransform(HumanBodyBones.Hips).localEulerAngles;
        initialSpineRotation = behaviourManager.GetAnim.GetBoneTransform(HumanBodyBones.Spine).localEulerAngles;
    }
Ejemplo n.º 4
0
        static void Main(string[] args)
        {
            SimulateDuck(new MallardDuck());
            SimulateDuck(new RedHeadDuck());
            SimulateDuck(new RubberDuck());
            SimulateDuck(new DecoyDuck());
            SimulateDuck(new ModelDuck());

            Duck duck = new MallardDuck();

            duck.Fly();
            duck.Fly();
            duck.SetFlight(FlyBehaviour.FlyWithWings());
            duck.Fly();
        }
 public void Fly()
 {
     FlyBehaviour.Fly();
 }
 public void PerformFly()
 {
     WriteLine(FlyBehaviour.Fly());
 }
Ejemplo n.º 7
0
 public void performFly()
 {
     FlyBehaviour.fly();
 }
Ejemplo n.º 8
0
 public void DuckFly()
 {
     Console.WriteLine("Duck.DuckFly");
     FlyBehaviour.Fly();
 }
Ejemplo n.º 9
0
 private void Awake()
 {
     myCurrentStrategyNormal = new NormalFly(this);
     myCurrentStrategyNitro  = new NitrousFly(this);
 }
Ejemplo n.º 10
0
 public void SetFlyBehaviour(FlyBehaviour fb)
 {
     flyBehaviour = fb;
 }
Ejemplo n.º 11
0
 public void PerformFly() => FlyBehaviour?.Fly();
Ejemplo n.º 12
0
 public void setFlyBehavior(FlyBehaviour fb)
 {
     flyBehaviour = fb;
 }
Ejemplo n.º 13
0
 // 实现动态更变行为
 public void SetFlyMethod(FlyBehaviour fb)
 {
     flyBehaviour = fb;
 }
Ejemplo n.º 14
0
 public RedHeadDuck()
     : base(FlyBehaviour.FlyWithWings(), QuackBehaviour.Quack, DanceBehaviour.Manuette)
 {
 }
Ejemplo n.º 15
0
 //this is also called constructor injection
 public Duck(string duckName, WalkBehaviour wb, FlyBehaviour fb)
 {
     name          = duckName;
     walkBehaviour = wb;
     flyBehaviour  = fb;
 }
Ejemplo n.º 16
0
 public void PerformFly()
 {
     FlyBehaviour.Fly();
 }
Ejemplo n.º 17
0
 public string Fly()
 {
     return(FlyBehaviour.Fly());
 }
Ejemplo n.º 18
0
 public void Fly()
 {
     // Delegation not carry out the fly behaviour actually delegation to another method that resposible to Fly
     FlyBehaviour.Fly();
 }
Ejemplo n.º 19
0
 public MallardDuck()
     : base(FlyBehaviour.FlyWithWings(), QuackBehaviour.Quack, DanceBehaviour.Waltz)
 {
 }
Ejemplo n.º 20
0
 public Batta()
 {
     this.Id             = Counter++;
     this.Name           = "Batta#" + this.Id;
     this.MyFlyBehaviour = new FlyWithWings();
 }