Esempio n. 1
0
        public void AddAnimalTest()
        {
            Wagon wagon = new Wagon(new Carnivore(Size.Medium));

            Animal animal = new Herbivore(Size.Small);

            var result = wagon.AddAnimal(animal);

            Assert.IsFalse(result);
        }
Esempio n. 2
0
 /// <summary>
 /// Damages the herbivore if player presses the eat button
 /// </summary>
 /// <param name="col"></param>
 private void Eat(Character col)
 {
     if (InputManager.Instance.GetButton("Eat"))
     {
         Herbivore vor = col as Herbivore;
         Debug.Log("mums, mums....");
         EatHerbivore(slowDown, vor.Health);
         vor.GetEaten(damage);
     }
 }
Esempio n. 3
0
        public void HerbivoreAlreadyDeadTest()
        {
            // Check if IsAlive is set properly, or if it flips
            var rng      = new Random();
            var testHerb = new Herbivore(rng);

            testHerb.IsAlive = false;
            testHerb.Kill();
            Assert.False(testHerb.IsAlive);
        }
Esempio n. 4
0
 public void Initialize()
 {
     testTerrarium = new Terrarium(10, 10);
     plant         = new Plant();
     herbivore     = new Herbivore();
     carnivore     = new Carnivore();
     human         = new Human();
     earthquake    = new EarthQuake();
     time          = new TimeController(0, testTerrarium);
 }
Esempio n. 5
0
        public override string ToString()
        {
            Herbivore herbivore        = this.CreateHerbivore();
            string    herbivoreMessage = $"{nameof(Herbivore)}: {herbivore.GetType().Name}";

            Carnivore carnivore        = this.CreateCarnivore();
            string    carnivoreMessage = $"{nameof(Carnivore)}: {carnivore.GetType().Name}";

            return($"{this.GetType().Name}{Environment.NewLine}{herbivoreMessage}{Environment.NewLine}{carnivoreMessage}");
        }
Esempio n. 6
0
 public void EndMatchForPlayer(Herbivore player)
 {
     herbivoresWon += 1;
     player.EnablePlayer(false);
     player.EnablePlayerCamera(false);
     if (herbivoresWon == NetworkGameManager.Instance.InGamePlayerList.Count - 1)
     {
         EndMatch();
     }
 }
Esempio n. 7
0
 public void Initialize()
 {
     testTerrarium = new Terrarium(5, 5);
     plant         = new Plant();
     herbivore     = new Herbivore();
     carnivore     = new Carnivore();
     human         = new Human();
     vulcano       = new Vulcano();
     time          = new TimeController(0, testTerrarium);
 }
Esempio n. 8
0
        public void HerbivoresBreedAndAddNewHerbivore()
        {
            toAdd.Clear();
            Position  herbivore1Position = new Position(1, 1);
            Position  herbivore2Position = new Position(2, 1);
            Herbivore herbivore1         = new Herbivore(herbivore1Position, BeginTerrarium);
            Herbivore herbivore2         = new Herbivore(herbivore2Position, BeginTerrarium);

            herbivore1.Breed(toAdd);
            Assert.AreEqual(1, toAdd.Count); // test of nieuwe herbivoor is aangemaakt
        }
Esempio n. 9
0
        public void PlaceAnimalInWagonAdd2LargeHerbivores()
        {
            Train train = new Train();

            Herbivore Herbivore = new Herbivore(AnimalEnums.AnimalSize.Large);

            train.PlaceAnimalInWagon(Herbivore);
            bool actual = train.PlaceAnimalInWagon(Herbivore);

            Assert.IsTrue(actual);
        }
Esempio n. 10
0
      public void Test_Third_Animal_Doesnt_Fit_In_Wagon()
      {
          Herbivore animal1 = new Herbivore(Weight.Large);
          Herbivore animal2 = new Herbivore(Weight.Large);
          Herbivore animal3 = new Herbivore(Weight.Large);
          Wagon     wagon   = new Wagon();

          wagon.PlaceAnimal(animal1);
          wagon.PlaceAnimal(animal2);
          Assert.IsFalse(wagon.CanAnimalBePlaced(animal3));
      }
Esempio n. 11
0
        public void HerbivoreFeedingIncreasesFitnessTest()
        {
            /*food => Phat*/
            var testHerbivore = new Herbivore(new Random(), testCoor);
            var food          = 100;

            testHerbivore.Params.F = 25;
            var initialFitness = testHerbivore.Fitness;
            var remainder      = testHerbivore.Feed(food);
            var endFitness     = testHerbivore.Fitness;
        }
Esempio n. 12
0
        public void HerbivoreFeedWhenLessThanFTest()
        {
            Herbivore testHerb = new Herbivore(new Random());
            double    F        = testHerb.Params.F;


            double available = F - 5.0;
            double remainder = testHerb.Feed(available);

            Assert.Equal(0, remainder);
        }
Esempio n. 13
0
    public void UpdateMatchUI(Character source)
    {
        if (source.GetType() == typeof(Herbivore))
        {
            Herbivore h = source.GetComponent <Herbivore>();

            HUDController.Instance.MaxHealth   = (int)h.Maxhealth;
            HUDController.Instance.CurProgress = h.Experience;
            HUDController.Instance.CurHealth   = (int)h.Health;
        }
    }
Esempio n. 14
0
        public void HerbivoreFeedZeroAvailableTest()
        {
            Herbivore testHerb      = new Herbivore(new Random());
            double    initialWeight = testHerb.Weight;
            double    initalAmount  = 0.0;
            double    remainder     = testHerb.Feed(initalAmount);
            double    endWeight     = testHerb.Weight;

            Assert.Equal(0, remainder);
            Assert.Equal(initialWeight, endWeight);
        }
Esempio n. 15
0
        public void GetFoodPrice_When_Invalid_Weight_Throws_Exception()
        {
            // Arrange

            var specie = new Herbivore {
                Specie = AnimalSpecieNames.Giraffe, Rate = 0.5, PricePerKg = 2
            };


            // Act, Assert
            Assert.Throws <ArgumentException>(() => specie.GetFoodPrice(-100));
        }
Esempio n. 16
0
    private new void Update()
    {
        switch (state)
        {
        case State.Nourished:
            NormalFly();
            break;

        case State.Hungry:
            if (food == null)
            {
                if (!foodOnSight)
                {
                    SearchFood();
                    NormalFly();
                }
            }
            else
            {
                Herbivore herbivore = food.GetComponent <Herbivore>();
                if (canMove && !herbivore.IsAtTree)
                {
                    Hunt(herbivore);
                }
                else
                {
                    NormalFly();
                }
            }
            break;

        case State.Thirsty:
            if (water == null)
            {
                if (!riverOnSight)
                {
                    SearchRiver();
                }
            }
            else
            {
                if (canMove)
                {
                    Flyby(water);
                }
                else
                {
                    NormalFly();
                }
            }
            break;
        }
    }
Esempio n. 17
0
        public void IsFriendsWithTest()
        {
            Animal animal  = new Herbivore(Size.Medium);
            var    animals = new List <Animal>()
            {
                new Carnivore(Size.Large)
            };

            var result = animal.IsFriendsWith(animals);

            Assert.IsFalse(result);
        }
Esempio n. 18
0
        public void SpaceAvailableTest()
        {
            Wagon wagon = new Wagon(new Carnivore(Size.Medium));

            wagon.AddAnimal(new Herbivore(Size.Large));

            Animal animal = new Herbivore(Size.Large);

            var result = wagon.SpaceAvailable(animal);

            Assert.IsFalse(result);
        }
Esempio n. 19
0
        public void LegalToAddLargerCarnivoreByHerbivore()
        {
            Wagon wagon = new Wagon();

            Herbivore herbivore = new Herbivore(AnimalEnums.AnimalSize.Small);
            Carnivore carnivore = new Carnivore(AnimalEnums.AnimalSize.Medium);

            wagon.AddToWagon(herbivore);

            bool actual = wagon.LegalToAdd(carnivore);

            Assert.IsFalse(actual);
        }
Esempio n. 20
0
    private void OnCollisionEnter(Collision col)
    {
        GameObject gObject = col.gameObject;

        if (gObject.CompareTag("Herbivore"))
        {
            Herbivore herbivore = gObject.GetComponent <Herbivore>();
            if (nutritionManager.IsHungry())
            {
                EatFood(herbivore);
            }
        }
    }
Esempio n. 21
0
        public void PlaceAnimalInWagonExceedCapacity()
        {
            Train train = new Train();

            Herbivore Herbivore = new Herbivore(AnimalEnums.AnimalSize.Large);

            train.PlaceAnimalInWagon(Herbivore);
            train.PlaceAnimalInWagon(Herbivore);
            bool actual = train.PlaceAnimalInWagon(Herbivore);


            Assert.IsFalse(actual);
        }
Esempio n. 22
0
 protected override void Hunt(Herbivore preyToHunt)
 {
     if (flybyCount == 0)
     {
         actualSpeed *= flybySpeedRate;
         flybyCount++;
     }
     if (preyToHunt != null)
     {
         SetPrey(preyToHunt);
         MoveToThis(prey.transform.position);
     }
 }
Esempio n. 23
0
    private void OnTriggerEnter(Collider other)
    {
        if (other.gameObject.layer == LayerMask.NameToLayer("Herbivore"))
        {
            Herbivore p = other.gameObject.GetComponent <Herbivore>();

            if (p.Experience == 100)
            {
                Debug.Log("Herbivore won!");
                InGameManager.Instance.EndMatchForPlayer(p);
            }
        }
    }
Esempio n. 24
0
        public void Animal_Herbivoor1_Wont_Be_eaten()
        {
            Herbivore     animal  = new Herbivore(Weight.Small);
            List <Animal> animals = new List <Animal>()
            {
                new Herbivore(Weight.Small),
                new Herbivore(Weight.Small),
                new Herbivore(Weight.Small),
                new Herbivore(Weight.Small),
                new Herbivore(Weight.Small)
            };

            Assert.IsTrue(animal.WontBeEaten(animals));
        }
Esempio n. 25
0
    public float EatAnimal()
    {
        if (grazers.Count == 0)
        {
            return(0.0f);
        }

        int       index = Random.Range(0, grazers.Count);
        Herbivore meal  = grazers[index];
        float     meat  = meal.GetEaten();

        grazers.RemoveAt(index);
        return(meat);
    }
Esempio n. 26
0
        public void GiveWagonAmountAdd2HerbivoresLarge()
        {
            Train train = new Train();

            Herbivore Herbivore = new Herbivore(AnimalEnums.AnimalSize.Large);

            train.PlaceAnimalInWagon(Herbivore);
            train.PlaceAnimalInWagon(Herbivore);

            int actual   = train.GiveWagonAmount();
            int expected = 1;

            Assert.AreEqual(expected, actual);
        }
Esempio n. 27
0
        public void HerbivoreLosesWeightTest()
        {
            /*Description*/
            var rng          = new Random();
            var testHerb     = new Herbivore(rng);
            var presetWeight = 100;

            testHerb.Weight = presetWeight;
            testHerb.UpdateWeight();
            var amountToLose = presetWeight * testHerb.Params.Eta;

            Assert.True(presetWeight > testHerb.Weight);
            Assert.True(presetWeight - testHerb.Weight == amountToLose);
        }
Esempio n. 28
0
        public void LegalToAddExceedCapicity()
        {
            Wagon wagon = new Wagon();

            Herbivore herbivore = new Herbivore(AnimalEnums.AnimalSize.Large);


            wagon.AddToWagon(herbivore);
            wagon.AddToWagon(herbivore);

            bool actual = wagon.LegalToAdd(herbivore);

            Assert.IsFalse(actual);
        }
Esempio n. 29
0
        public void FeedingUpdatesFitnessTest()
        {
            var rng      = new Random();
            var testHerb = new Herbivore(rng)
            {
                Weight = 5, Age = 50
            };
            var initialF = testHerb.Fitness;
            var food     = 100.0;

            testHerb.Feed(food);
            var endF = testHerb.Fitness;

            Assert.True(initialF < endF);
        }
Esempio n. 30
0
        public void CarnivoreEetHerbivore()
        {
            Position  carnivorePosition = new Position(1, 1);
            Position  herbivorePosition = new Position(1, 2);
            Herbivore testHerbivore     = new Herbivore(herbivorePosition, BeginTerrarium);

            testHerbivore.Health = 2;
            carnivore            = new Carnivore(carnivorePosition, BeginTerrarium);
            carnivore.Health     = 3;
            var BeginHealthCarnivore = carnivore.Health;
            var HealthHerbivore      = testHerbivore.Health;

            carnivore.Eat(testHerbivore, toDelete);
            Assert.AreEqual(carnivore.Health, BeginHealthCarnivore + HealthHerbivore);
        }
Esempio n. 31
0
        public override void Eat(Herbivore h)
        {
          // Eat Bison
          Console.WriteLine(this.GetType().Name +
            " eats " + h.GetType().Name);
        }
Esempio n. 32
0
 // Methods
 public override void Eat(Herbivore h)
 {
     // Eat bison
     Console.WriteLine(this + " eats " + h);
 }
Esempio n. 33
0
 // Methods
 public override void Eat(Herbivore h)
 {
     // eat wildebeest
     Console.WriteLine(this + " eats " + h);
 }
Esempio n. 34
0
 // Methods
 abstract public void Eat(Herbivore h);
Esempio n. 35
0
 public override void Stomp(Herbivore h)
 {
     Console.WriteLine(this.GetType().Name +
         " lightly stomps on " + h.GetType().Name);
 }
Esempio n. 36
0
 public override void Eat(Herbivore h)
 {
     Console.WriteLine(string.Format("{0} eats {1}",this.GetType().Name,h.GetType().Name));
 }
Esempio n. 37
0
        // Constructor
        public AnimalWorld(ContinentFactory factory)
        {
          _carnivore = factory.CreateCarnivore();
          _herbivore = factory.CreateHerbivore();
        }
Esempio n. 38
0
 public override void Eat(Herbivore herbivore)
 {
     Console.WriteLine(GetType().Name + " eats " + herbivore.GetType().Name);
 }
Esempio n. 39
0
 // Constructor
 public AnimalWorld(ContinentFactory factory)
 {
     _carnivore = factory.CreateCarnivore();
       _herbivore = factory.CreateHerbivore();
 }
 public string Eats(Herbivore herbivore)
 {
     return $"{GetType().Name} eats {herbivore.GetType().Name}";
 }
Esempio n. 41
0
 public override void Eat(Herbivore h)
 {
     // Eat Wildebeest
     Console.WriteLine(GetType().Name +
                       " eats " + h.GetType().Name);
 }
Esempio n. 42
0
 public override void Eat(Herbivore h)
 {
     // Eat Bison
       Console.WriteLine(this.GetType().Name +
     " eats " + h.GetType().Name);
 }
Esempio n. 43
0
 // Constructor
 public AnimalWorld(ContinentFactory factory)
 {
     _carnivore = factory.CreateCarnivore();
     _herbivore = factory.CreateHerbivore();
     _problem = factory.CreateProblem();
     _giant = factory.CreateGiant();
     _giant2 = factory.CreateSmallGiant();
 }
Esempio n. 44
0
 public abstract void Eat(Herbivore h);
Esempio n. 45
0
 public abstract void Stomp(Herbivore h);