private void Awake()
        {
            Lion henk = Instantiate(lion, transform).GetComponent <Lion>();

            henk.name            = "1";
            henk.helloMessage    = "roooaoaaaaar";
            henk.feedMeatMessage = "nomnomnom thx mate";
            Hippo elsa = Instantiate(hippo, transform).GetComponent <Hippo>();

            elsa.name = "2";
            Pig dora = Instantiate(pig, transform).GetComponent <Pig>();

            dora.name = "3";
            Tiger wally = Instantiate(tiger, transform).GetComponent <Tiger>();

            wally.name = "4";
            Zebra marty = Instantiate(zebra, transform).GetComponent <Zebra>();

            marty.name = "5";
            Donkey sam = Instantiate(donkey, transform).GetComponent <Donkey>();

            sam.name = "6";
            Elephant bernard = Instantiate(elephant, transform).GetComponent <Elephant>();

            bernard.name = "7";
        }
Exemple #2
0
        protected override void CheckHunger()
        {
            base.CheckHunger();

            if (isHungry())
            {
                theZoo.lastMessage = "Lion is hungry, be weary zebras...";
                foreground         = ConsoleColor.Red;

                if (theZoo.GetAnimalsOfType <Zebra>().Count() > 0)
                {
                    Zebra zebra = FindAdjacentAnimal <Zebra>();

                    if (zebra == null)
                    {
                        theZoo.lastMessage = "Hungry lion can't find a zebra.... :(";
                    }
                    else
                    {
                        zebra.isDead       = true;
                        this.currentFood   = 1000;
                        theZoo.lastMessage = "Lion ate a zebra. Yum!";
                    }
                }
            }
            else
            {
                foreground = ConsoleColor.Yellow;
            }
        }
Exemple #3
0
        protected double EvaluateSquare(int x, int y)
        {
            double attraction = theZoo.map.terrain[y, x].foodStock;

            // look at the given square and decide how attractive it is
            // grass - proximity to lions + proximity to other zebras
            foreach (Lion lion in theZoo.GetAnimalsOfType <Lion>())
            {
                double distance = lion.DistanceFrom(x, y) + 1;
                attraction -= (255 / (distance * distance));
            }

            // maybe move closer to nearest zebra
            Zebra zebra = FindClosest <Zebra>();

            if (zebra != null)
            {
                if (this.DistanceFrom(zebra) > zebra.DistanceFrom(x, y))
                {
                    attraction += 1;
                }
                else
                {
                    attraction -= 1;
                }
            }

            // avoid swimming into very deep water
            if (theZoo.map.terrain[y, x].waterLevel > 50)
            {
                attraction -= 100;
            }

            return(attraction);
        }
Exemple #4
0
        static void Main(string[] args)
        {
            Zebra Zebra1 = new Zebra();

            Zebra1.Name         = "Stripes";
            Zebra1.NumberOfLegs = 4;
            Zebra1.Sound        = "Zebra sound";

            // Object initializer

            Zebra Zebra2 = new Zebra()
            {
                Name         = "Stripes",
                NumberOfLegs = 4,
                Sound        = "Zebra sound",
            };

            PandaBear Pandabear1 = new PandaBear("Peter", "M");

            Console.WriteLine(Pandabear1.Sex);



            Gorilla Gorilla1 = new Gorilla("George", "male");
            Gorilla Gorilla2 = new Gorilla("Grace", "female", 0);

            //Testting if ouputs Gorilla sound
            // Console.WriteLine(Gorilla1.Sound);


            //List<Type>
            List <Animal> ListOfAnimals = new List <Animal>();

            //Adding excisting animals
            ListOfAnimals.Add(Gorilla1);
            ListOfAnimals.Add(Gorilla2);
            ListOfAnimals.Add(Zebra1);
            ListOfAnimals.Add(Zebra2);
            //Adding new animals, cannot input name of object
            ListOfAnimals.Add(new Zebra());


            //Console.WriteLine(ListOfAnimals); or else only output is Zoo.animal
            //Console.WriteLine(ListOfAnimals[0]) Seeing certain Animal in list
            //Console.WriteLine(ListOfAnimals[1].Name); Ouptuts the name of second animal in list



            // (Type newNameForeach in List)
            foreach (Animal animal in ListOfAnimals)
            {
                Console.WriteLine($"{animal.GetType()} {animal.NumberOfLegs} {animal.Sound}");

                //Need animal from the list to refer to the method, not from the class
                animal.Eat();
            }

            Console.ReadKey();
        }
Exemple #5
0
        static void Main(string[] args)
        {
            Console.WriteLine("Enter q to quit!");

            var zoo = new Zoo();

            while (true)
            {
                Console.WriteLine();
                Console.WriteLine("Enter Animal Type: ");
                Console.WriteLine("1. Lion");
                Console.WriteLine("2. Tiger");
                Console.WriteLine("3. Zebra");

                Console.Write("Type (number): ");
                var type = Console.ReadLine();
                if (type == "q")
                {
                    break;
                }

                Animal animal = null;
                switch (type)
                {
                case "1":
                    animal = new Lion();
                    break;

                case "2":
                    animal = new Tiger();
                    break;

                case "3":
                    animal = new Zebra();
                    break;

                default:
                    Console.WriteLine("Not a valid animal type!");
                    break;
                }

                if (animal != null)
                {
                    Console.WriteLine();
                    Console.WriteLine($"Feed the : {animal.Type()}.");
                    animal.WrongFoodProvided += OnWrongFoodProvided;
                    FeedAnimal(animal);
                    zoo.AddAnimal(animal);
                }
            }

            Console.WriteLine($"Total Expenses for all animals: {zoo.TotalExpenses()}");
            var mostExpensive = zoo.MostExpensive();

            Console.WriteLine($"Most expensive animal to keep is: {mostExpensive.Type()}");
            Console.WriteLine($"It eats: {zoo.CostByAnimal(mostExpensive)}");
        }
Exemple #6
0
        protected Boolean ChaseZebras()
        {
            Boolean hasMoved = false;

            if (isHungry())
            {
                Zebra zebra = FindClosest <Zebra>();

                if (zebra != null)
                {
                    hasMoved = MoveToward(zebra);
                }
            }

            return(hasMoved);
        }
Exemple #7
0
 private void Start()
 {
     henk        = Instantiate(lion, transform).GetComponent <Lion>();
     henk.name   = "henk";
     elsa        = Instantiate(hippo, transform).GetComponent <Hippo>();
     elsa.name   = "elsa";
     dora        = Instantiate(pig, transform).GetComponent <Pig>();
     dora.name   = "dora";
     wally       = Instantiate(tiger, transform).GetComponent <Tiger>();
     wally.name  = "wally";
     marty       = Instantiate(zebra, transform).GetComponent <Zebra>();
     marty.name  = "marty";
     steven      = Instantiate(captainAmerica, transform).GetComponent <CaptainAmerica>();
     steven.name = "steven";
     logan       = Instantiate(wolverine, transform).GetComponent <Wolverine>();
     logan.name  = "logan";
 }
        /// <summary>
        /// Instantiates every animal and adds them to the scene.
        /// </summary>
        private void Start()
        {
            Lion   henk   = Instantiate(lion, transform).GetComponent <Lion>();
            Hippo  elsa   = Instantiate(hippo, transform).GetComponent <Hippo>();
            Pig    dora   = Instantiate(pig, transform).GetComponent <Pig>();
            Tiger  wally  = Instantiate(tiger, transform).GetComponent <Tiger>();
            Zebra  marty  = Instantiate(zebra, transform).GetComponent <Zebra>();
            Monkey ceaser = Instantiate(monkey, transform).GetComponent <Monkey>();
            Toucan duif   = Instantiate(toucan, transform).GetComponent <Toucan>();

            animals.Add(henk);
            animals.Add(elsa);
            animals.Add(dora);
            animals.Add(wally);
            animals.Add(marty);
            animals.Add(ceaser);
            animals.Add(duif);
        }
Exemple #9
0
        private void Start()
        {
            Lion henk = Instantiate(lion, transform).GetComponent <Lion>();

            henk.Name = "henk";
            Hippo elsa = Instantiate(hippo, transform).GetComponent <Hippo>();

            elsa.Name = "elsa";
            Pig dora = Instantiate(pig, transform).GetComponent <Pig>();

            dora.Name = "dora";
            Tiger wally = Instantiate(tiger, transform).GetComponent <Tiger>();

            wally.Name = "wally";
            Zebra marty = Instantiate(zebra, transform).GetComponent <Zebra>();

            marty.Name = "marty";
            Squirrel stamper = Instantiate(rabbit, transform).GetComponent <Squirrel>();

            stamper.Name = "stamper";
            Wolf kiba = Instantiate(wolf, transform).GetComponent <Wolf>();

            kiba.Name = "kiba";
        }
Exemple #10
0
        private void Start()
        {
            Lion henk = Instantiate(lion, transform).GetComponent <Lion>();

            henk.name = "henk";
            Hippo elsa = Instantiate(hippo, transform).GetComponent <Hippo>();

            elsa.name = "elsa";
            Pig dora = Instantiate(pig, transform).GetComponent <Pig>();

            dora.name = "dora";
            Tiger wally = Instantiate(tiger, transform).GetComponent <Tiger>();

            wally.name = "wally";
            Zebra marty = Instantiate(zebra, transform).GetComponent <Zebra>();

            marty.name = "marty";
            Tyler1 tyler1 = Instantiate(fourHead, transform).GetComponent <Tyler1>();

            tyler1.name = "tyler1";
            Mike mike = Instantiate(bruh, transform).GetComponent <Mike>();

            mike.name = "mike";
        }
        static void Main(string[] args)
        {
            // The zoo now is only a list of animals which have no cages of whatever. Every Animal can interact with any other.
            // This is probably not going to work out well...



            List <Animal> AnimalsInZoo = new List <Animal>();


            // Herbivores
            Bunny Bella = new Bunny("Bella", 4, 2, Animal.ESex.female, 0);

            AnimalsInZoo.Add(Bella);
            Zebra Zali = new Zebra("Zali", 4, 400, Animal.ESex.female, 0);

            AnimalsInZoo.Add(Zali);
            // Carnivores

            Tiger Timmy = new Tiger("Timmy", 4, 400, Animal.ESex.male, 0.7f, 0);

            AnimalsInZoo.Add(Timmy);



            List <FoodItem> AvailableFood = new List <FoodItem>();

            Grass StartingGrass = new Grass(150);

            AvailableFood.Add(StartingGrass);

            /*
             * There is a list of all available food in the zoo which every iteration is supplied with grass.
             * If a herbivore is killed, its meat gets added to the foodlist. The attacking carnivore will eat untill full and leave the rest.
             *
             *
             * List<FoodItem> AvailableFood = new List<FoodItem();
             *
             *
             * while(not all herbivores are dead)
             * {
             * flavour text about how all animals go about their day and therefore get hungry
             * herbivore can just eat grass and be all happy about it.
             *
             *
             *
             * Carnivores cannot and have to find food.
             * When a carnivore gets hungry, it will kill and eat a herbivore.
             *
             * At the end of day, reduce the AmountOfEnergy by the DailyEnergyConsumption. IF AmountOfEnergy gets lower than twice??
             * the DailyEnergyConsumption, the animal gets hungry and will look for food.
             * If they hit 0, they die.
             *
             *
             * List<Animal> HungryAnimals = Animals.Where(a => a.isHungry).ToList();
             * Foreach( IHerbivore herbivore in HungryAnimals)
             * {
             * if (AvailableFood.Contains(Grass)
             * {
             *  herbivore.eat(grass)
             *  }
             *
             * Foreach (ICarnivore in HungryAnimals)
             * {
             * if (AvailableFood.Contains(Meat)
             *  {
             *  Carnivore.eat(meat)
             *  }
             *  else
             *  {
             *  Carnivore.kill(prey)
             *  Carnivore.eat(meat)
             *  }
             *
             *
             *
             * Foreach(Animal a in Zoo)
             * {
             * a.AmountOfEnergy -= DailyEnergyConsumption;
             *
             * if(a.AmountOfEnergy <= 0)
             * {
             *      a.Die();
             * }else if(a.AmountOfEnergy <= DailyEnergyConsumption)
             * {
             *     a.IsHungry = true;
             *    }else if(a.AmountOfEnergy > DailyEnergyConsumption)
             * {
             *     a.IsHungy = false;
             * }
             *
             * Console.Readkey in between to make it readable.
             *
             *
             * carnivore.kill(IHerbivore prey)
             * {
             * prey.Die();
             * Meat justkilled = new Meat(prey.FoodValue)
             * AvailableFood.add(justkilled)
             *
             * }
             * AvailableMeat = AvailableFood.OfType<Meat>();
             *
             * While(carnivore.AmountOfEnergy <= MaxAmountOfEnery)
             * {
             *
             *  carnivore.eat(AvailableMeat.First())
             *
             *  if carnivore.AmountOfEnergy > carnivore.MaxAmountOfEnergy
             *  {
             *  AmountOfEnergy = MaxAmountOfEnergy;
             * }
             *
             */



            // LESSON THINGY
            // extensions:
            AnimalsInZoo.NumberOfAnimalsOfType <Animal, Tiger>();
        }