示例#1
0
 public AddEditFaunaViewModel() : base(-1)
 {
     ValidInanimateTemplates = TemplateCache.GetAll <IInanimateTemplate>();
     ValidMaterials          = TemplateCache.GetAll <IMaterial>();
     ValidRaces = TemplateCache.GetAll <IRace>();
     DataObject = new Fauna();
 }
示例#2
0
        public Fauna GetFaunaById(int id)
        {
            Fauna result = (from f in Faunas
                            where f.FaunaId == id
                            select f).FirstOrDefault <Fauna>();

            return(result);
        }
示例#3
0
        public void DeleteFauna(int id)
        {
            Fauna result = (from f in faunas
                            where f.FaunaId == id
                            select f).FirstOrDefault <Fauna>();

            faunas.Remove(result);
        }
示例#4
0
        public void UpdateFauna(Fauna f)
        {
            int index = faunas.FindIndex(p => p.FaunaId == f.FaunaId);

            if (index < 0)
            {
                faunas.Add(f);
            }
            else
            {
                faunas[index] = f;
            }
        }
示例#5
0
        public void FaunaRepositoryMock_UpdateFauna()
        {
            FaunaRepositoryMock urm = new FaunaRepositoryMock();
            Fauna fauna             = new Fauna()
            {
                FaunaName = "Njajal Gan", FaunaId = 1
            };

            urm.UpdateFauna(fauna);
            var a = urm.GetFaunaById(1);

            Assert.AreEqual(fauna, a);
        }
示例#6
0
        public void FaunaRepositoryDb_UpdateFauna()
        {
            FaunaRepositoryDb urd   = new FaunaRepositoryDb();
            Fauna             fauna = new Fauna()
            {
                FaunaName = "Njajal Gan", FaunaId = 1
            };

            urd.UpdateFauna(fauna);
            var a = urd.GetFaunaById(1);

            Assert.AreEqual(fauna, a);
        }
示例#7
0
        public void FaunaRepositoryMock_AddFauna()
        {
            FaunaRepositoryMock urm = new FaunaRepositoryMock();
            Fauna fauna             = new Fauna()
            {
                FaunaName = "Njajal Gan", FaunaId = 1000
            };

            urm.AddFauna(fauna);
            var a = urm.GetFaunaById(1000);

            Assert.IsNotNull(a);
        }
示例#8
0
        public void FaunaRepositoryDb_AddFauna()
        {
            FaunaRepositoryDb urd   = new FaunaRepositoryDb();
            Fauna             fauna = new Fauna()
            {
                FaunaName = "Njajal Gan", FaunaId = 1000
            };

            urd.AddFauna(fauna);
            var a = urd.GetFaunaById(1000);

            Assert.IsNotNull(a);
        }
示例#9
0
    /// <summary>
    /// This is a mock function.
    /// </summary>
    virtual public void MockInstantiate(UInt64 maxWealth)
    {
        /**** ORDER IS ESSENTIAL ****/
        Amiability = new Amiability.Amiability(Seed);        // Will have a bearing on TechLevel
        TechLevel  = Tech.TechLevel.WESTERN;                 // Need to determine how to set this
        Wealth     = new Wealth(Seed, TechLevel, maxWealth); // Dependent on TechLevel

        Population = new Population(this);                   // Dependent on Tech, Amiability, and Wealth

        RaceMakeup = new RaceMakeup(Seed);
        Weather    = new Weather.Weather();
        Flora      = new Flora(Weather);
        Fauna      = new Fauna(Weather);
    }
示例#10
0
    // Use this for initialization
    void Start()
    {
        planet = GetComponentInParent <Planet>();
        //print ("planetModifiers on currentresources = " + planetModifiers[0] + ", also nresMultipliers = " + planet.nResourceMultipliers + ", planet.resourcemult[0] = " + planet.resourceMultipliers[0]);

        //add resources
        pop    = new Population(this);
        food   = new Food(this);
        water  = new Water(this);
        oxygen = new Oxygen(this);
        power  = new Power(this);
        flora  = new Flora(this);
        fauna  = new Fauna(this);
        //@@ volgorde moet later aangepast..
        res = new Resource[7] {
            pop, food, water, oxygen, power, flora, fauna
        };
    }
        public IActionResult Create(string name, IFormFile picture, string description, int height, int length, string color, string latitude, string longitude, DateTime date)
        {
            byte[] newPicture = new byte[0];
            if (picture != null)
            {
                using (Stream fileStream = picture.OpenReadStream())
                    using (MemoryStream ms = new MemoryStream())
                    {
                        fileStream.CopyTo(ms);
                        newPicture = ms.ToArray();
                    }
            }
            Fauna newFauna = new Fauna(newPicture, name, description, length, height, color, latitude, longitude, date);

            newFauna.UserId = User.Identity.Name;
            db.Faunas.Add(newFauna);
            db.SaveChanges();
            return(RedirectToAction("Index", "Account"));
        }
示例#12
0
        private static List <Fauna> GetFauna(int x, int y, int faunaCount = 35)
        {
            var fauna = new List <Fauna>();
            var rng   = new Random();

            for (var i = 0; i < faunaCount; i++)
            {
                var newFauna = new Fauna()
                {
                    Name      = "plant" + i,
                    PositionX = rng.Next(0, x),
                    PositionY = rng.Next(0, y - 1),
                    Resources = rng.Next(1, 25),
                    Health    = rng.Next(35, 100)                                                            // health of fauna is directly proportional to how many resource they provide
                };
                if (!fauna.Any(x => x.PositionY == newFauna.PositionY && x.PositionX == newFauna.PositionX)) // if fauna doesn't already exist at this position, add it
                {
                    fauna.Add(newFauna);
                }
            }
            return(fauna);
        }
示例#13
0
 public ActionResult AddFauna(FormCollection form)
 {
     if (Session["UserName"] != null)
     {
         Fauna fauna = new Fauna();
         fauna.FaunaName             = form.Get("name");
         fauna.FaunaLatinName        = form.Get("latin");
         fauna.FaunaLongitude        = float.Parse(form.Get("longitude"));
         fauna.FaunaLatitude         = float.Parse(form.Get("latitude"));
         fauna.FaunaOtherDescription = form.Get("description");
         fauna.FaunaReference        = form.Get("reference");
         fauna.FaunaPhoto            = form.Get("photolink");
         fauna.FaunaDate             = DateTime.Now;
         fauna.UserId = int.Parse(Session["UserId"].ToString());
         fns.AddFauna(fauna);
         return(View());
     }
     else
     {
         return(RedirectToAction("Index"));
     }
 }
示例#14
0
    public override String ToString()
    {
        string pop      = String.Format("\nPopulation:    {0:N0}", Population.Pop);
        string wealth   = String.Format("\nWealth:        ${0:N2}", Wealth.RegionWealth);
        string income   = String.Format("\nIncome:        ${0:N2}", Income);
        string distance = String.Format("\nDistFrmCntr:   {0:f6}", DistanceFromCenter);

        string printstr = "Region Information:" +
                          pop +
                          wealth +
                          income +
                          "\nAmiability:    " + Amiability.AmiabilityLevel +
                          "\nTechLevel:     " + TechLevel +
                          //"\nWorldCulture:  " + WorldCulture +
                          distance +
                          "\nNclrWstlnd:    " + NuclearWasteland +
                          "\n" + RaceMakeup.ToString() +
                          "\n" + Weather.ToString() +
                          "\n" + Flora.ToString() +
                          "\n" + Fauna.ToString();

        return(printstr);
    }
示例#15
0
        public AddEditFaunaViewModel(long templateId) : base(templateId)
        {
            ValidInanimateTemplates = TemplateCache.GetAll <IInanimateTemplate>();
            ValidMaterials          = TemplateCache.GetAll <IMaterial>();
            ValidRaces = TemplateCache.GetAll <IRace>();
            DataObject = new Fauna();

            //apply template
            if (DataTemplate != null)
            {
                DataObject.AmountMultiplier      = DataTemplate.AmountMultiplier;
                DataObject.CanSpawnInSystemAreas = DataTemplate.CanSpawnInSystemAreas;
                DataObject.ElevationRange        = DataTemplate.ElevationRange;
                DataObject.FemaleRatio           = DataTemplate.FemaleRatio;
                DataObject.HumidityRange         = DataTemplate.HumidityRange;
                DataObject.OccursIn          = DataTemplate.OccursIn;
                DataObject.PopulationHardCap = DataTemplate.PopulationHardCap;
                DataObject.PuissanceVariance = DataTemplate.PuissanceVariance;
                DataObject.Rarity            = DataTemplate.Rarity;
                DataObject.Race             = DataTemplate.Race;
                DataObject.TemperatureRange = DataTemplate.TemperatureRange;
            }
        }
示例#16
0
 public void UpdateFauna(Fauna f)
 {
     context.Entry(f).State = EntityState.Modified;
     context.SaveChanges();
 }
示例#17
0
 public void UpdateFauna(Fauna f)
 {
     faunaRepository.UpdateFauna(f);
 }
示例#18
0
 public void AddFauna(Fauna f)
 {
     faunas.Add(f);
 }
示例#19
0
 public void AddFauna(Fauna f)
 {
     context.Faunas.Add(f);
     context.SaveChanges();
 }
示例#20
0
 public void AddFauna(Fauna f)
 {
     faunaRepository.AddFauna(f);
 }
 public static Genome Combination(Fauna father, Fauna mother) =>
 Combination(father.genome, mother.genome);