public ReferenceExpressionEater(IEater eater, ExpressionKindHelper kindHelper, EatExpressionHelper eatExpressionHelper, ITypeEater typeEater)
     : base(eater)
 {
     _kindHelper          = kindHelper;
     _eatExpressionHelper = eatExpressionHelper;
     _typeEater           = typeEater;
 }
예제 #2
0
    protected override void Start()
    {
        FoodTargets     = new List <Transform>();
        PredatorTargets = new List <Transform>();

        base.Start();
        PredatorDetected = false;
        FoodDetected     = false;

        Detection = GetComponent <UnitDetection>();
        Eater     = GetComponent <IEater>();
        Eatable   = GetComponent <IEatable>();
        Exhausted = GetComponent <Exhaustion>();

        SubGoal s1 = new SubGoal(State.NotHungry, 1, false);

        // Add it to the goals
        goals.Add(s1, 0);

        SubGoal s2 = new SubGoal(State.NotExhausted, 1, false);

        // Add it to the goals
        goals.Add(s2, 0);

        SubGoal s3 = new SubGoal(State.NotEaten, 1, false);

        // Add it to the goals
        goals.Add(s3, 2);

        Detection.OnTargetsUpdated += FilterEatableTargets;
        Detection.OnTargetsUpdated += FilterEaterTargets;
    }
예제 #3
0
        /// <summary>
        /// The animal eats.
        /// </summary>
        /// <param name="eater">The intended animal.</param>
        /// <param name="food">The animal's food.</param>
        public void Eat(IEater eater, Food food)
        {
            // Increase animal's weight as a result of eating food.
            eater.Weight += food.Weight * (eater.WeightGainPercentage / 100);

            this.ShowAffection();
        }
예제 #4
0
 static void Main(string[] args)
 {
     IWorker[] workers = new IWorker[3]
     {
         new Manager(), new Worker(), new Robot()
     };
     foreach (var worker in workers)
     {
         worker.Work();
     }
     IEater[] eaters = new IEater[2]
     {
         new Manager(), new Worker()
     };
     foreach (var eater in eaters)
     {
         eater.Eat();
     }
     ISalary[] salaries = new ISalary[2]
     {
         new Manager(), new Worker()
     };
     foreach (var salary in salaries)
     {
         salary.GetSalary();
     }
     Console.ReadLine();
 }
        public ParentReferenceEater([NotNull] IEater eater)
        {
            if (eater == null)
                throw new ArgumentNullException("eater");

            _eater = eater;
        }
예제 #6
0
        /// <summary>
        /// Eats the food.
        /// </summary>
        /// <param name="eater"> The eater eating the food.</param>
        /// <param name="food"> The food being ate,</param>
        public void Eat(IEater eater, Food food)
        {
            // Eats the food.

            // Happy they ate food.
            this.ShowAffection();
        }
예제 #7
0
 public Fish(IMap map, IGrowable growable, IMovable movable, IEater eater, IEatable eatable, IGender gender,
             DeathEvent deathEvent, IEventRecorder eventRecorder)
     : base(map, growable, movable, eater, gender, deathEvent, eventRecorder)
 {
     Hp       = 10;
     _eatable = eatable;
     _eatable.EatableOwner = this;
 }
 private void Start()
 {
     Eater        = GetComponent <IEater>();
     Eatable      = GetComponent <IEatable>();
     Exhaustion   = GetComponent <Exhaustion>();
     WanderOrigin = new Vector3(0, 0, 1);
     aiActive     = true;
 }
예제 #9
0
 protected StatementEater([NotNull] IEater eater)
 {
     if (eater == null)
     {
         throw new ArgumentNullException("eater");
     }
     Eater = eater;
 }
        protected VariableDeclarationEater([NotNull] IEater eater)
        {
            if (eater == null)
            {
                throw new ArgumentNullException("eater");
            }

            Eater = eater;
        }
        protected QueryClauseEater([NotNull] IEater eater)
        {
            if (eater == null)
            {
                throw new ArgumentNullException("eater");
            }

            Eater = eater;
        }
        public ParentReferenceEater([NotNull] IEater eater)
        {
            if (eater == null)
            {
                throw new ArgumentNullException("eater");
            }

            _eater = eater;
        }
예제 #13
0
        /// <summary>
        /// The animal eats.
        /// </summary>
        /// <param name="eater">The intended animal.</param>
        /// <param name="food">The animal's food.</param>
        public void Eat(IEater eater, Food food)
        {
            this.BuryBone(food);
            this.DigUpAndEatBone();

            // Increase animal's weight as a result of eating food.
            eater.Weight += food.Weight * (eater.WeightGainPercentage / 100);

            this.Bark();
        }
        /// <summary>
        /// Eats the specified food.
        /// </summary>
        /// <param name="eater">The eater that will consume the food.</param>
        /// <param name="food">The food to eat.</param>
        public void Eat(IEater eater, Food food)
        {
            this.BuryBone(food);

            this.DigUpAndEatBone();

            // Increase the animal's weight by the weight of the food eaten.
            eater.Weight += food.Weight;

            this.Bark();
        }
예제 #15
0
        /// <summary>
        /// Eats the food.
        /// </summary>
        /// <param name="eater"> The item that is an eater.</param>
        /// <param name="food"> The food item being ate.</param>
        public void Eat(IEater eater, Food food)
        {
            // Bury's the food.
            this.BuryBone(food);

            // Eats the food.
            this.DigUpAndEatBone();

            // Barks in satisfaction.
            this.Bark();
        }
예제 #16
0
 public void Eat(IEater eater, Food food)
 {
     // Eater buries bone.
     this.BuryBone(food);
     // Eater digs up the bone.
     this.DigUpAndEatBone();
     // Eater eats the bone.
     eater.Eat(food);
     // Eater barks in satisfaction.
     this.Bark();
 }
예제 #17
0
 protected Animal(IMap map, IGrowable growable, IMovable movable, IEater eater, IGender gender,
                  DeathEvent deathEvent, IEventRecorder eventRecorder) : base(map, growable, deathEvent, eventRecorder)
 {
     IsPregnant          = false;
     _gender             = gender;
     _gender.GenderOwner = this;
     _eater                = eater;
     _eater.EaterOwner     = this;
     _movable              = movable;
     _movable.MovableOwner = this;
 }
 public InvocationExpressionEater(IEater eater,
                                  EatExpressionHelper expressionHelper,
                                  ExpressionKindHelper expressionKindHelper,
                                  IParentReferenceEater parentReferenceEater,
                                  IArgumentsEater argumentsEater,
                                  IMockOfInvocationEater mockOfInvocationEater)
     : base(eater)
 {
     _expressionHelper      = expressionHelper;
     _expressionKindHelper  = expressionKindHelper;
     _parentReferenceEater  = parentReferenceEater;
     _argumentsEater        = argumentsEater;
     _mockOfInvocationEater = mockOfInvocationEater;
 }
예제 #19
0
        /// <summary>
        /// Feeds the specified eater.
        /// </summary>
        /// <param name="eater">The eater to be fed.</param>
        /// <param name="animalSnackMachine">The animal snack machine from which to buy food.</param>
        public void FeedAnimal(IEater eater, VendingMachine animalSnackMachine)
        {
            // Find food price.
            decimal price = animalSnackMachine.DetermineFoodPrice(eater.Weight);

            // Get money from wallet.
            decimal payment = this.wallet.RemoveMoney(price);

            // Buy food.
            Food food = animalSnackMachine.BuyFood(payment);

            // Feed animal.
            eater.Eat(food);
        }
예제 #20
0
파일: Mammal.cs 프로젝트: mtaylorhayden/OOP
        /// <summary>
        /// Feeds a baby eater.
        /// </summary>
        /// <param name="newborn">The eater to feed.</param>
        private void FeedNewborn(IEater newborn)
        {
            // Determine milk weight.
            double milkWeight = this.Weight * 0.005;

            // Generate milk.
            Food milk = new Food(milkWeight);

            // Feed baby.
            newborn.Eat(milk);

            // Reduce parent's weight.
            this.Weight -= milkWeight;
        }
예제 #21
0
파일: Fruit.cs 프로젝트: Jimmie-gh/Froggy
    private void OnCollisionEnter2D(Collision2D collision)
    {
        IEater eater = collision.gameObject.GetComponent <IEater>();

        if (eater == null)
        {
            //TODO score substruct, smash animation
            scoreController.Score -= score;
            Destroy(gameObject);
        }
        else
        {
            eater.Eat(this);
            scoreController.Score += score;
        }
    }
예제 #22
0
        /// <summary>
        /// Feeds the specified eater.
        /// </summary>
        /// <param name="eater">The eater to be fed.</param>
        /// <param name="animalSnackMachine">The animal snack machine from which to buy food.</param>
        public void FeedAnimal(IEater eater, VendingMachine animalSnackMachine)
        {
            // Find food price.
            decimal price = animalSnackMachine.DetermineFoodPrice(eater.Weight);

            if (this.wallet.MoneyBalance < price)
            {
                // Withdraw 10 times the price of the food.
                this.WithdrawMoney(price * 10);
            }

            // Get money from wallet.
            decimal payment = this.wallet.RemoveMoney(price);

            // Buy food.
            Food food = animalSnackMachine.BuyFood(payment);

            // Feed animal.
            eater.Eat(food);
        }
예제 #23
0
        /// <summary>
        /// Feeds the specified eater.
        /// </summary>
        /// <param name="eater">The eater to be fed.</param>
        /// <param name="animalSnackMachine">The animal snack machine from which to buy food.</param>
        public void FeedAnimal(IEater eater)
        {
            VendingMachine animalSnackMachine = this.GetVendingMachine();

            // Find food price.
            decimal price = animalSnackMachine.DetermineFoodPrice(eater.Weight);

            // Check if guest has enough money on hand and withdraw from account if necessary.
            if (this.wallet.MoneyBalance < price)
            {
                this.WithdrawMoney(price * 10);
            }

            // Get money from wallet.
            decimal payment = this.wallet.RemoveMoney(price);

            // Buy food.
            Food food = animalSnackMachine.BuyFood(payment);

            // Feed animal.
            eater.Eat(food);
        }
 public UncheckedStatementEater(IEater eater) : base(eater)
 {
 }
 public UnsafeCodeFixedStatementEater(IEater eater)
     : base(eater)
 {
 }
 public UnsafeCodeUnsafeStatementEater(IEater eater)
     : base(eater)
 {
 }
 public DefaultExpressionEater(IEater eater, ITypeEater typeEater)
     : base(eater)
 {
     _typeEater = typeEater;
 }
 public VariableInitializerEater(IEater eater)
 {
     _eater = eater;
 }
예제 #29
0
 public SwitchLabelStatementEater(IEater eater) : base(eater)
 {
 }
예제 #30
0
파일: Eating.cs 프로젝트: norniel/Game
 public Eating(IEater eater, GameObject objectToEat)
 {
     _eater = eater;
     _objectToEat = objectToEat;
 }
 public ArrayCreationExpressionEater(IEater eater, IVariableInitializerEater variableInitializerEater) : base(eater)
 {
     _variableInitializerEater = variableInitializerEater;
 }
 public ArgumentsEater(IEater eater)
 {
     _eater = eater;
 }
예제 #33
0
        static void Main(string[] args)
        {
            if (args.Length < 4)
            {
                Console.Error.WriteLine("dxf2bmp input.dxf output.bmp cx cy ");
                Environment.Exit(1);
            }
            using (StreamReader rr = new StreamReader(args[0], Encoding.Default)) {
                IEater        eater = null;
                List <IEater> al    = new List <IEater>();
                while (true)
                {
                    String row0 = rr.ReadLine();
                    String row1 = rr.ReadLine();
                    int    ty;
                    if (row1 == null || !int.TryParse(row0.Trim(), out ty))
                    {
                        break;
                    }
                    if (ty == 0)
                    {
                        if (false)
                        {
                        }
                        else if (row1 == "LINE")
                        {
                            al.Add(eater = new Line());
                        }
                        else if (row1 == "CIRCLE")
                        {
                            al.Add(eater = new Circle());
                        }
                        else
                        {
                            eater = null;
                        }
                    }
                    else if (eater != null)
                    {
                        eater.Eat(ty, row1);
                    }
                }

                BBox bbox = new BBox();
                {
                    foreach (var q in al.Where(p => p is Line).Cast <Line>())
                    {
                        bbox.Eat(q);
                    }
                    foreach (var q in al.Where(p => p is Circle).Cast <Circle>())
                    {
                        bbox.Eat(q);
                    }
                }

                bbox.InflateRate(0.02f, 0.02f);

                using (Bitmap pic = new Bitmap(int.Parse(args[2]), int.Parse(args[3]))) {
                    using (Graphics cv = Graphics.FromImage(pic)) {
                        cv.TranslateTransform(0, pic.Height);
                        cv.ScaleTransform(1, -1);

                        cv.SmoothingMode = SmoothingMode.HighQuality;

                        CBox cb = new CBox(pic.Width, pic.Height, bbox);

                        cv.Clear(Color.White);

                        foreach (IEater eat in al)
                        {
                            if (eat is Line)
                            {
                                Line t = (Line)eat;
                                cv.DrawLine(
                                    new Pen(t.color),
                                    (float)cb.X(t.x0),
                                    (float)cb.Y(t.y0),
                                    (float)cb.X(t.x1),
                                    (float)cb.Y(t.y1)
                                    );
                            }
                            else if (eat is Circle)
                            {
                                Circle t = (Circle)eat;
                                cv.DrawEllipse(
                                    Pens.Black,
                                    RectangleF.FromLTRB(
                                        (float)cb.X(t.x - t.r),
                                        (float)cb.Y(t.y - t.r),
                                        (float)cb.X(t.x + t.r),
                                        (float)cb.Y(t.y + t.r)
                                        )
                                    );
                            }
                        }

#if false
                        cv.FillRectangle(
                            new LinearGradientBrush(new Point(0, 0), new Point(pic.Width, pic.Height), Color.Black, Color.Gray),
                            new RectangleF(PointF.Empty, pic.Size)
                            );
                        cv.DrawString(
                            "A DXF thumbnail",
                            new Font(FontFamily.GenericSerif, 8),
                            Brushes.WhiteSmoke,
                            new RectangleF(PointF.Empty, pic.Size)
                            );
#endif
                    }
                    pic.Save(args[1], System.Drawing.Imaging.ImageFormat.Bmp);
                }
            }
        }
 public MoqStubOptionsEater(IEater eater, IMoqStubOptionTargetEater moqStubOptionTargetEater)
 {
     _eater = eater;
     _moqStubOptionTargetEater = moqStubOptionTargetEater;
 }
예제 #35
0
 public DeclarationStatementEater(IEater eater)
     : base(eater)
 {
 }
예제 #36
0
 public UnitTestEater(IEater eater)
 {
     _eater = eater;
 }