Ejemplo n.º 1
0
        /// <summary>
        /// Runs code that depends on the UI components have been initialised.
        /// Also starts two threads up, one for updating the UI and one for running the AI.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void OnWindowLoaded(object sender, RoutedEventArgs e)
        {
            MapInformation mapInformation = MapInformation.Instance;

            mapInformation.SetSizeOfMap = ((ushort)ImageBox.Width, (ushort)ImageBox.Height);
            Output output = Output.Instance;

            output.PaintEvent += Output_UpdateVisualEvent;
            output.TextEvent  += Output_UpdateInformationEvent;

            output.Map = new Bitmap(mapInformation.GetSizeOfMap.width, mapInformation.GetSizeOfMap.height);
            for (int i = 0; i < 8; i++)                                                                                                                                                                                                                                     //8
            {
                new SleepingCarnivore("Carnis Lupus", new Vector(mapInformation, Helper.Instance), new string[] { "Oryctolagus Cuniculus", "Antidorcas Marsupialis" }, Helper.Instance, Publisher.GetLifeformInstance, Publisher.GetDrawInstance, MapInformation.Instance); //here for testing and nothing else.
            }
            for (int i = 0; i < 20; i++)                                                                                                                                                                                                                                    //20
            {
                new HidingHerbavore("Oryctolagus Cuniculus", new Vector(mapInformation, Helper.Instance), new string[] { "Cucumis Melo", "Carica Papaya" }, Helper.Instance, Publisher.GetLifeformInstance, Publisher.GetDrawInstance, MapInformation.Instance);
            }
            for (int i = 0; i < 20; i++) //20 //find a species that makes more sense
            {
                new SleepingHerbavore("Antidorcas Marsupialis", new Vector(mapInformation, Helper.Instance), new string[] { "Cucumis Melo", "Carica Papaya" }, Helper.Instance, Publisher.GetLifeformInstance, Publisher.GetDrawInstance, MapInformation.Instance);
            }
            for (int i = 0; i < 2; i++) //2
            {
                new MonoeciousPlant("Cucumis Melo", new Vector(mapInformation, Helper.Instance), Helper.Instance, Publisher.GetLifeformInstance, Publisher.GetDrawInstance, MapInformation.Instance);
            }
            for (int i = 0; i < 30; i++) //30
            {
                new DioeciousPlant("Carica Papaya", new Vector(mapInformation, Helper.Instance), Helper.Instance, Publisher.GetLifeformInstance, Publisher.GetDrawInstance, MapInformation.Instance);
            }
            for (int i = 0; i < 6; i++) //6
            {
                new PackCarnivore("Crocuta Crocuta", new Vector(mapInformation, Helper.Instance), new string[] { "Oryctolagus Cuniculus", "Antidorcas Marsupialis" }, Helper.Instance, Publisher.GetLifeformInstance, Publisher.GetDrawInstance, MapInformation.Instance);
            }
            for (int i = 0; i < 6; i++) //6
            {
                new BirdCarnivore("Haliaeetus Albicilla", new Vector(mapInformation, Helper.Instance), new string[] { "Turdus Merula", "Antidorcas Marsupialis", "Oryctolagus Cuniculus", "Carnis Lupus" }, Helper.Instance, Publisher.GetLifeformInstance, Publisher.GetDrawInstance, MapInformation.Instance);
            }
            for (int i = 0; i < 10; i++) //6
            {
                new BirdHerbavore("Turdus Merula", new Vector(mapInformation, Helper.Instance), new string[] { "Carica Papaya", "Cucumis Melo" }, Helper.Instance, Publisher.GetLifeformInstance, Publisher.GetDrawInstance, MapInformation.Instance);
            }
            output.RunVisualThread();
            output.RunAIThread();
        }
        /// <summary>
        /// Sets all instances of classes and interfaces, sets properties that depends on these and subscribes the event handlers to the events.
        /// </summary>
        /// <param name="helper">The instance of IHelper.</param>
        /// <param name="lifeformPublisher">The instance of AnimalPublisher.</param>
        /// <param name="drawPublisher">The instance of DrawPublisher.</param>
        /// <param name="mapInformation">The instance of MapInformation.</param>
        private Eukaryote(IHelper helper, LifeformPublisher lifeformPublisher, DrawPublisher drawPublisher, MapInformation mapInformation)
        {
            this.helper            = helper;
            this.lifeformPublisher = lifeformPublisher;
            this.drawPublisher     = drawPublisher;
            this.mapInformation    = mapInformation;

            OneAgeInSeconds = mapInformation.OneAgeInSeconds;
            ID = helper.GenerateID();

            this.lifeformPublisher.RaiseFindPreyEvent   += IsPossiblePreyEventHandler;
            this.lifeformPublisher.RaiseSetPreyEvent    += IsPreyEventHandler;
            this.lifeformPublisher.RaiseRemovePreyEvent += RemovePredatorEventHandler;
            this.lifeformPublisher.RaiseAIEvent         += ControlEventHandler;
            this.lifeformPublisher.RaiseDied            += DeathEventHandler;
            this.lifeformPublisher.RaiseEaten           += EatenEventHandler;
            this.lifeformPublisher.RaiseGetLocation     += LocationEventHandler;
            this.lifeformPublisher.RaiseDamage          += DamageEventHandler;
            this.lifeformPublisher.RaiseGetAllLocations += GetAllLocationsEventHandler;

            this.drawPublisher.RaiseDrawEvent             += DrawEventHandler;
            this.drawPublisher.RaiseSpeciesAndAmountEvent += SpeciesAmountEventHandler;
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Default constructor. Initialises properites and variables to 'default' values.
        /// </summary>
        /// <param name="species">The species of this animal.</param>
        /// <param name="location">The start location of this animal.</param>
        /// <param name="foodSource">The food source of this animal.</param>
        /// <param name="helper">An instance of IHelper.</param>
        /// <param name="lifeformPublisher">An instance of AnimalPublisher.</param>
        /// <param name="drawPublisher">An instance of DrawPublisher.</param>
        /// <param name="mapInformation">An instance of MapInformation.</param>
        public BirdCarnivore(string species, Vector location, string[] foodSource, IHelper helper, LifeformPublisher animalPublisher, DrawPublisher drawPublisher, MapInformation mapInformation) : base(species, location, foodSource, helper, animalPublisher, drawPublisher, mapInformation)
        {
            MaximumHeight  = 100;
            CanDive        = true;
            AscendSpeed    = 8f;
            DiveSpeed      = 26f;
            DesendSpeed    = 12f;
            AscendModifier = 1.3f; //mention in the xml that 1 is 100 %
            DesendModifier = 0.8f;
            HoverModifier  = 0.4f;
            CircleRange    = 120f;

            MovementSpeed = 20;

            AttackRange           = 30;
            AttackSpeedMultiplier = 1.1f;

            BirthAmount          = (1, 1);
            reproductionCooldown = 40;
            lengthOfReproduction = 4;

            Design = new Point[] { new Point(0, 0), new Point(3, 3), new Point(6, 0), new Point(3, 6) };
            Colour = new Colour(100, 255, 255);
        }
Ejemplo n.º 4
0
        /// <summary>
        /// Default constructor. Initialises properites and variables to 'default' values.
        /// </summary>
        /// <param name="species">The species of this animal.</param>
        /// <param name="location">The start location of this animal.</param>
        /// <param name="foodSource">The food source of this animal.</param>
        /// <param name="helper">An instance of IHelper.</param>
        /// <param name="lifeformPublisher">An instance of AnimalPublisher.</param>
        /// <param name="drawPublisher">An instance of DrawPublisher.</param>
        /// <param name="mapInformation">An instance of MapInformation.</param>
        public BirdHerbavore(string species, Vector location, string[] foodSource, IHelper helper, LifeformPublisher animalPublisher, DrawPublisher drawPublisher, MapInformation mapInformation) : base(species, location, foodSource, helper, animalPublisher, drawPublisher, mapInformation)
        {
            CanDive        = false;
            MaximumHeight  = 80;
            AscendSpeed    = 10f;
            DiveSpeed      = 0f;
            DesendSpeed    = 14f;
            AscendModifier = 1.3f;
            DesendModifier = 0.7f;
            HoverModifier  = 0.8f;
            CircleRange    = 0;

            MovementSpeed        = 18;
            BirthAmount          = (1, 1);
            reproductionCooldown = 40;
            lengthOfReproduction = 4;

            Design = new Point[] { new Point(0, 0), new Point(3, 3), new Point(6, 0), new Point(3, 6) };
            Colour = new Colour(255, 255, 255);
        }
Ejemplo n.º 5
0
        /// <summary>
        /// Default constructor. Initialises properites and variables to 'default' values.
        /// </summary>
        /// <param name="species">The species of this animal.</param>
        /// <param name="location">The start location of this animal.</param>
        /// <param name="foodSource">The food source of this animal.</param>
        /// <param name="helper">An instance of IHelper.</param>
        /// <param name="lifeformPublisher">An instance of AnimalPublisher.</param>
        /// <param name="drawPublisher">An instance of DrawPublisher.</param>
        /// <param name="mapInformation">An instance of MapInformation.</param>
        public SleepingHerbavore(string species, Vector location, string[] foodSource, IHelper helper, LifeformPublisher lifeformPublisher, DrawPublisher drawPublisher, MapInformation mapInformation) : base(species, location, foodSource, helper, lifeformPublisher, drawPublisher, mapInformation)
        {
            MaxEnergyLevel     = 30;
            EnergyLevel        = MaxEnergyLevel;
            SleepLength        = 6;
            SleepModifer       = 0.4f;
            baseDiscoverChance = DiscoverChance;
            baseDiscoverRange  = DiscoverRange;

            BirthAmount = (2, 3);

            Colour = new Colour(0, 0, 255);
        }
Ejemplo n.º 6
0
 /// <summary>
 /// Creates an instance of the Vector class with a random location on the map.
 /// </summary>
 /// <param name="mapInformation">An instance of MapInformation.</param>
 /// <param name="helper">An instance of IHelper.</param>
 /// <param name="maxHeight">The maximum height.</param>
 public Vector(MapInformation mapInformation, IHelper helper, float maxHeight)
 {
     position[0] = helper.GenerateRandomNumber(0, mapInformation.GetSizeOfMap.width - 1);
     position[1] = helper.GenerateRandomNumber(0, mapInformation.GetSizeOfMap.height - 1);
     position[2] = helper.GenerateRandomNumber(0, (int)maxHeight);
 }
Ejemplo n.º 7
0
 /// <summary>
 /// Default constructor. Initialises properites and variables to 'default' values.
 /// </summary>
 /// <param name="species">The species of this animal.</param>
 /// <param name="location">The start location of this animal.</param>
 /// <param name="foodSource">The food source of this animal.</param>
 /// <param name="helper">An instance of IHelper.</param>
 /// <param name="lifeformPublisher">An instance of AnimalPublisher.</param>
 /// <param name="drawPublisher">An instance of DrawPublisher.</param>
 /// <param name="mapInformation">An instance of MapInformation.</param>
 public SleepingCarnivore(string species, Vector location, string[] foodSource, IHelper helper, LifeformPublisher lifeformPublisher, DrawPublisher drawPublisher, MapInformation mapInformation) : base(species, location, foodSource, helper, lifeformPublisher, drawPublisher, mapInformation)
 {
     AttackRange           = 20; //order these into groups.
     AttackSpeedMultiplier = 1.5f;
     lengthOfReproduction  = 9;
     genderInformation     = new (char Gender, byte Weight)[] { ('f', 50), ('m', 50) };
        /// <summary>
        /// Default constructor. Initialises properites and variables to 'default' values.
        /// </summary>
        /// <param name="species">The species of this animal.</param>
        /// <param name="location">The start location of this animal.</param>
        /// <param name="foodSource">The food source of this animal.</param>
        /// <param name="helper">An instance of IHelper.</param>
        /// <param name="lifeformPublisher">An instance of AnimalPublisher.</param>
        /// <param name="drawPublisher">An instance of DrawPublisher.</param>
        /// <param name="mapInformation">An instance of MapInformation.</param>
        public HidingHerbavore(string species, Vector location, string[] foodSource, IHelper helper, LifeformPublisher lifeformPublisher, DrawPublisher drawPublisher, MapInformation mapInformation) : base(species, location, foodSource, helper, lifeformPublisher, drawPublisher, mapInformation)
        {
            MovementSpeed        = 10;
            CurrentMovementSpeed = MovementSpeed;
            Colour        = new Colour(0, 120, 120);
            NutrientValue = 100;

            genderInformation    = new (char Gender, byte Weight)[] { ('f', 50), ('m', 50) };
Ejemplo n.º 9
0
        /// <summary>
        /// Default constructor. Initialises properites and variables to 'default' values.
        /// </summary>
        /// <param name="species">The species of this animal.</param>
        /// <param name="location">The start location of this animal.</param>
        /// <param name="foodSource">The food source of this animal.</param>
        /// <param name="helper">An instance of IHelper.</param>
        /// <param name="lifeformPublisher">An instance of AnimalPublisher.</param>
        /// <param name="drawPublisher">An instance of DrawPublisher.</param>
        /// <param name="mapInformation">An instance of MapInformation.</param>
        public DioeciousPlant(string species, Vector location, IHelper helper, LifeformPublisher lifeformPublisher, DrawPublisher drawPublisher, MapInformation mapInformation, char gender = (char)0) : base(species, location, helper, lifeformPublisher, drawPublisher, mapInformation, gender)
        {
            spreadRange     = 240;
            offspringAmount = (2, 3);

            lengthOfReproduction = 8;
            reproductionCooldown = OneAgeInSeconds * 3;

            NutrientValue = 40;

            MaxHealth       = 100;
            Health          = MaxHealth;
            MaxAge          = 7;
            ReproductionAge = 3;
            distanceDivider = 25;

            Colour = new Colour(200, 100, 0);
            Design = new Point[] { new Point(3, 0), new Point(6, 3), new Point(3, 6), new Point(0, 3) };
        }
 /// <summary>
 /// Default constructor. Initialises properites and variables to 'default' values.
 /// </summary>
 /// <param name="species">The species of this animal.</param>
 /// <param name="location">The start location of this animal.</param>
 /// <param name="foodSource">The food source of this animal.</param>
 /// <param name="helper">An instance of IHelper.</param>
 /// <param name="lifeformPublisher">An instance of AnimalPublisher.</param>
 /// <param name="drawPublisher">An instance of DrawPublisher.</param>
 /// <param name="mapInformation">An instance of MapInformation.</param>
 public Dioecious(string species, Vector location, IHelper helper, LifeformPublisher lifeformPublisher, DrawPublisher drawPublisher, MapInformation mapInformation, char gender = (char)0) : base(species, location, helper, lifeformPublisher, drawPublisher, mapInformation)
 {
     if (gender == 0)
     {
         Gender = GenderGenerator();
     }
     else
     {
         Gender = gender;
     }
     this.lifeformPublisher.RaisePossibleMatesEvent += CanMateEventHandler;
 }
    {                                         //after all, some plants reproduce through fire.
        /// <summary>
        /// Default constructor. Initialises properites and variables to 'default' values.
        /// </summary>
        /// <param name="species">The species of this animal.</param>
        /// <param name="location">The start location of this animal.</param>
        /// <param name="foodSource">The food source of this animal.</param>
        /// <param name="helper">An instance of IHelper.</param>
        /// <param name="lifeformPublisher">An instance of AnimalPublisher.</param>
        /// <param name="drawPublisher">An instance of DrawPublisher.</param>
        /// <param name="mapInformation">An instance of MapInformation.</param>
        public MonoeciousPlant(string species, Vector location, IHelper helper, LifeformPublisher lifeformPublisher, DrawPublisher drawPublisher, MapInformation mapInformation) : base(species, location, helper, lifeformPublisher, drawPublisher, mapInformation)
        {
            spreadRange     = 140;
            offspringAmount = (1, 3);

            lengthOfReproduction = 20;
            reproductionCooldown = OneAgeInSeconds * 2;

            NutrientValue = 14;

            MaxHealth       = 100;
            Health          = MaxHealth;
            MaxAge          = 4;
            ReproductionAge = 2;

            Colour = new Colour(100, 200, 0);
            Design = new Point[] { new Point(3, 0), new Point(6, 3), new Point(3, 6), new Point(0, 3) };
        }
 /// <summary>
 /// Default constructor. Initialises properites and variables to 'default' values.
 /// </summary>
 /// <param name="species">The species of this animal.</param>
 /// <param name="location">The start location of this animal.</param>
 /// <param name="foodSource">The food source of this animal.</param>
 /// <param name="helper">An instance of IHelper.</param>
 /// <param name="lifeformPublisher">An instance of AnimalPublisher.</param>
 /// <param name="drawPublisher">An instance of DrawPublisher.</param>
 /// <param name="mapInformation">An instance of MapInformation.</param>
 public Carnivore(string species, Vector location, string[] foodSource, IHelper helper, LifeformPublisher lifeformPublisher, DrawPublisher drawPublisher, MapInformation mapInformation) : base(species, location, foodSource, helper, lifeformPublisher, drawPublisher, mapInformation)
 {
     Design = new Point[] { new Point(0, 0), new Point(8, 0), new Point(8, 8), new Point(0, 8) };
 }
        /// <summary>
        /// Default constructor. Initialises properites and variables to 'default' values.
        /// </summary>
        /// <param name="species">The species of this animal.</param>
        /// <param name="location">The start location of this animal.</param>
        /// <param name="foodSource">The food source of this animal.</param>
        /// <param name="helper">An instance of IHelper.</param>
        /// <param name="lifeformPublisher">An instance of AnimalPublisher.</param>
        /// <param name="drawPublisher">An instance of DrawPublisher.</param>
        /// <param name="mapInformation">An instance of MapInformation.</param>
        public Eukaryote(string species, Vector location, IHelper helper, LifeformPublisher lifeformPublisher, DrawPublisher drawPublisher, MapInformation mapInformation) : this(helper, lifeformPublisher, drawPublisher, mapInformation)
        {
            Species       = species;
            Location      = location;
            HuntedBy      = new string[0];
            MaxHealth     = 100;
            Health        = MaxHealth;
            MaxAge        = 10;
            NutrientValue = 50;

            ContactCooldownLength = 0.5f;

            Colour = new Colour(122, 122, 122);
            Design = new Point[] { new Point(0, 0), new Point(4, 0), new Point(4, 4), new Point(0, 4) };
        }