Наследование: MonoBehaviour
        public async Task <ActionResult> AddCrop([FromBody] CropForAddDto crop)
        {
            int id          = int.Parse(User.FindFirst(ClaimTypes.NameIdentifier).Value);
            var logineduser = await _auth.VerifyUser(id);

            Crops newcrop = new Crops()
            {
                CropCategory = await _context.CropCategories.FirstOrDefaultAsync(s => s.Id == crop.CategoryId),
                Company      = logineduser.Company,
                Status       = true
            };
            await _context.Crops.AddAsync(newcrop);

            await _context.SaveChangesAsync();

            foreach (var item in crop.Content)
            {
                CropLanguage cropLang = new CropLanguage()
                {
                    Crops    = newcrop,
                    Name     = item.Content,
                    Language = await _context.Languages.FirstOrDefaultAsync(s => s.code == item.Languagename)
                };
                await _context.CropLanguages.AddAsync(cropLang);

                await _context.SaveChangesAsync();
            }
            return(StatusCode(201));
        }
Пример #2
0
 public string LoadVegetationParameter(Guid datasetid, string dataname, bool isLAI, string paramName, string value)
 {
     try
     {
         if (Crops == null || Crops.Count == 0)
         {
             Crops = new List <_CustomCropInputsModel>();
         }
         var crop = Crops.FirstOrDefault(x => x.Id == datasetid);
         if (crop == null)
         {
             if (isLAI)
             {
                 crop = new HowLeakyInputs_LAIVeg(datasetid, dataname);
             }
             else
             {
                 crop = new HowLeakyInputs_CoverVeg(datasetid, dataname);
             }
             Crops.Add(crop);
         }
         if (TryLoadParameter(crop, paramName, value) == false)
         {
             return(paramName);
         }
     }
     catch (Exception ex)
     {
         throw ErrorLogger.CreateException(ex);
     }
     return(null);
 }
Пример #3
0
        public async Task <IActionResult> AddNewCrop(int?id, addnewCrop addnewCrop)
        {
            if (ModelState.IsValid)
            {
                var seller_email = User.Identity.Name;

                String uniqefileName = null;
                if (addnewCrop.crop_image != null)
                {
                    string uplodeFolder = Path.Combine(hostEnvironment.WebRootPath, "CropImage");
                    uniqefileName = Guid.NewGuid().ToString() + "_" + addnewCrop.crop_image.FileName;
                    string filepath = Path.Combine(uplodeFolder, uniqefileName);
                    addnewCrop.crop_image.CopyTo(new FileStream(filepath, FileMode.Create));
                }
                Crops crop = new Crops
                {
                    buyOrsell         = addnewCrop.youwanttosell,
                    Crops_description = addnewCrop.crop_description,
                    Crops_image       = uniqefileName,
                    Crops_price       = addnewCrop.crop_price,
                    Crops_name        = addnewCrop.crop_name,
                    Crops_quantity    = addnewCrop.crop_quantity,
                    Farmers_id        = _context.Farmers.Where(x => x.Farmers_email == seller_email).FirstOrDefault().Farmers_id,
                    itComplited       = false,
                };
                _context.Crops.Add(crop);
                await _context.SaveChangesAsync();

                return(RedirectToAction("HomepageFarmer", "Farmers"));
            }
            return(View(addnewCrop));
        }
                /// <summary>
                /// Applies the configuration to ensure only valid crops are kept and have the correct width/height.
                /// </summary>
                /// <param name="configuration">The configuration.</param>
                public void ApplyConfiguration(MediaPicker3Configuration?configuration)
                {
                    var crops = new List <ImageCropperValue.ImageCropperCrop>();

                    var configuredCrops = configuration?.Crops;

                    if (configuredCrops != null)
                    {
                        foreach (var configuredCrop in configuredCrops)
                        {
                            var crop = Crops?.FirstOrDefault(x => x.Alias == configuredCrop.Alias);

                            crops.Add(new ImageCropperValue.ImageCropperCrop
                            {
                                Alias       = configuredCrop.Alias,
                                Width       = configuredCrop.Width,
                                Height      = configuredCrop.Height,
                                Coordinates = crop?.Coordinates
                            });
                        }
                    }

                    Crops = crops;

                    if (configuration?.EnableLocalFocalPoint == false)
                    {
                        FocalPoint = null;
                    }
                }
Пример #5
0
        public void TestPerennialMaximumCropsProfit()
        {
            TestHelpers.InMethod();
            //log4net.Config.XmlConfigurator.Configure();

            AddBuyPoints();
            AddPlayers(Farmer.Singleton);
            StartGame();

            m_controller.State.BuyLandRights(bp1, p1);

            // Level 3 is perennial grapes
            Crops c1 = (Crops)AddGameAsset(bp1, 0, Crops.Template, 3);

            Assert.That(
                c1.NominalMaximumProfitThisTurn,
                Is.EqualTo(c1.RevenueThisTurn - c1.MaintenanceCost));

            EndTurns(1);

            m_controller.State.UseWater(c1, p1, c1.WaterUsage);
            EndTurns(1);

            Assert.That(
                c1.NominalMaximumProfitThisTurn,
                Is.EqualTo(c1.RevenueThisTurn - c1.MaintenanceCost));
        }
Пример #6
0
        public async Task <IActionResult> Edit(int id, [Bind("Crops_id,Crops_name,Crops_quantity,Crops_price,Crops_description,Crops_image,Farmers_id")] Crops crops)
        {
            if (id != crops.Crops_id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(crops);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!CropsExists(crops.Crops_id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(crops));
        }
Пример #7
0
 public ImageCrop this[string alias]
 {
     get
     {
         return(Crops.FirstOrDefault(x => x.Alias == alias));
     }
 }
Пример #8
0
 /// <summary>
 /// Adds the parent crop to all seeds
 /// </summary>
 public static void LinkSeedParents()
 {
     foreach (KeyValuePair <string, Seed> entry in _seedDic)
     {
         entry.Value.ParentCrop = Crops.GetStandardCrop(entry.Key);
     }
 }
Пример #9
0
        /// <summary>
        /// Harvests a single crop from this seed
        /// </summary>
        /// <param name="index">Index of the crop to harvest</param>
        public void Harvest(int[] indexes)
        {
            Crop[] cropsToRemove = new Crop[indexes.Length];

            foreach (int i in indexes)
            {
                cropsToRemove[i - 1] = Crops[i - 1];
            }

            foreach (Crop crop in cropsToRemove)
            {
                Program.Game.AddCropToInventory(crop);
                Crops.Remove(crop);
            }

            if (Crops.Count == 0)
            {
                if (SeedType == Enumerations.SeedType.Vegetable)
                {
                    Field.RemoveSeed();
                }
                else
                {
                    InitializeCrops();
                }
            }
        }
Пример #10
0
    public void PotatoesChoice()
    {
        _chosenVegetable = _potatoIcon;
        _time            = _potatoIcon.GetGrowthTime;
        _countPortions   = _potatoIcon.GetCountPortions;

        StartGrowth();
    }
Пример #11
0
    public void CornChoice()
    {
        _chosenVegetable = _cornIcon;
        _time            = _cornIcon.GetGrowthTime;
        _countPortions   = _cornIcon.GetCountPortions;

        StartGrowth();
    }
Пример #12
0
    public static void InitGame(params Type[] exceptions)
    {
        Screen.sleepTimeout = SleepTimeout.NeverSleep;
        ActionStack.Clear();
        Crops.Clear();
        foreach (var enemykvp in Enemies)
        {
            enemykvp.Value.RemoveAll(x => !x || !x.gameObject);
        }

        EnemyInfos.Clear();
        var enemies = Resources.LoadAll <EnemyInformation>("Configuration");

        foreach (var e in enemies)
        {
            EnemyInfos.Add(e.ID, e);
        }

        Items.Clear();
        var items = Resources.LoadAll <ItemBase>("Configuration");

        foreach (var i in items)
        {
            Items.Add(i.ID, i);
        }

        TalkerInfos.Clear();
        var talkers = Resources.LoadAll <TalkerInformation>("Configuration");

        foreach (var t in talkers)
        {
            TalkerInfos.Add(t.ID, t);
        }

        if (exceptions == null || !exceptions.Contains(typeof(TriggerHolder)))
        {
            foreach (var tholder in FindObjectsOfType <TriggerHolder>())
            {
                tholder.Init();
            }
        }
        PlayerManager.Instance.Init();
        DialogueManager.Instance.Init();
        if (!UIManager.Instance || !UIManager.Instance.gameObject)
        {
            Instantiate(Instance.UIPrefab);
        }
        UIManager.Instance.Init();
        FieldManager.Instance.Init();
        QuestManager.Instance.Init();
        MessageManager.Instance.Init();
        MapManager.Instance.Init();
        MapManager.Instance.SetPlayer(PlayerManager.Instance.PlayerTransform);
        MapManager.Instance.RemakeCamera();
        GatherManager.Instance.Init();
        WindowsManager.Clear();
    }
Пример #13
0
        /// <summary>
        /// Initializes all standard seeds & crops and links their parents
        /// </summary>
        public static void InitializeStandards()
        {
            InitializeGameObjects();
            Seeds.InitializeStandardSeeds();
            Crops.InitializeStandardCrops();
            Crops.LinkCropParents();
            Seeds.LinkSeedParents();

            Crops.SingleValues.Prices.InitializeStandardCropPrices();
        }
Пример #14
0
    // Update is called once per frame
    void Update()
    {
        //increment time
        currentTime += Time.deltaTime * daySpeedMultiplier;
        //reset time
        if (currentTime >= 24.0f)
        {
            currentTime %= 24.0f;
            foreach (Transform Crops in Field.transform)
            {
                if (Crops.childCount > 0)
                {
                    if (Crops.GetChild(0).transform.localScale.x < 1)
                    {
                        Crops.GetChild(0).transform.localScale += new Vector3(1f / Crops.GetComponent <Plant>().DayToGrowth, 1f / Crops.GetComponent <Plant>().DayToGrowth, 1f / Crops.GetComponent <Plant>().DayToGrowth);
                    }
                    else if (Crops.GetChild(0).GetComponent <Fruit>().isGrowth == false)
                    {
                        GameObject Fruit = Instantiate(Crops.GetChild(0).GetComponent <Fruit>().FruitObject, Crops.GetChild(0).transform, false);
                        Fruit.transform.localPosition = Crops.GetChild(0).GetComponent <Fruit>().P_Position;
                        Fruit.GetComponent <Rigidbody>().isKinematic      = true;
                        Crops.GetChild(0).GetComponent <Fruit>().isGrowth = true;
                    }
                    else if (Crops.GetChild(0).childCount == 0)
                    {
                        Destroy(Crops.transform.gameObject);
                    }
                }
            }
        }
        //Check for sunlight
        if (sunLight)
        {
            ControlLight();
        }
        //Check for cloudsphere
        if (cloudSpheres.Length > 0)
        {
            ControlClouds();
        }
        //Check for starsphere
        if (starSpheres.Length > 0)
        {
            StarSphere();
        }

        if (Input.GetKeyDown(KeyCode.T))
        {
            currentTime += 12;
        }
        //Camera control
        ControlCamera();
        //Gets The timeString;
        CalculateTime();
    }
Пример #15
0
        public async Task <IActionResult> Create([Bind("Crops_id,Crops_name,Crops_quantity,Crops_price,Crops_description,Crops_image,Farmers_id")] Crops crops)
        {
            if (ModelState.IsValid)
            {
                _context.Add(crops);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(crops));
        }
Пример #16
0
 public SummerModel()
 {
     _CalendarService       = new CalendarService();
     TravelingCart          = Shops.TravelingCart;
     DaysOfTheWeek          = _CalendarService.GetDaysOfWeek();
     TimesOfDay             = _CalendarService.GetTimesOfDay();
     CalendarDays           = _CalendarService.GetCalendarDaysForSummer();
     CropsInSeason          = Crops.GetSummerCrops();
     SeasonalForagingBundle = Bundles.SummerForagingBundle;
     SeasonalCropsBundle    = Bundles.SummerCropsBundle;
     Reminders = _CalendarService.GetRemindersForSummer();
 }
Пример #17
0
 public override int GetHashCode()
 {
     unchecked
     {
         // properties are, practically, readonly
         // ReSharper disable NonReadonlyMemberInGetHashCode
         var hashCode = Src?.GetHashCode() ?? 0;
         hashCode = (hashCode * 397) ^ (FocalPoint?.GetHashCode() ?? 0);
         hashCode = (hashCode * 397) ^ (Crops?.GetHashCode() ?? 0);
         return(hashCode);
         // ReSharper restore NonReadonlyMemberInGetHashCode
     }
 }
Пример #18
0
        /// <summary>
        /// Registers a new crop
        /// </summary>
        /// <param name="crop">Information of crop to register</param>
        public static void RegisterCrop <T>(CropInformation crop)
        {
            if (Game1.cropSpriteSheet == null)
            {
                throw new Exception("objectInformation is null! This likely occurs if you try to register a crop before AfterContentLoaded");
            }

            crop.Id = Farmhand.API.Content.ContentManager.Load <Dictionary <int, string> >("Data\\Crops").Count() + 1;

            Crops.Add(crop.Seed, crop);
            TextureUtility.AddSpriteToSpritesheet(ref Game1.cropSpriteSheet, crop.Texture, crop.Id, 128, 32);
            RegisteredTypeInformation[typeof(T)] = crop;
        }
Пример #19
0
        public override void ProcessRow(IList <object> row)
        {
            FieldModel newField = new FieldModel()
            {
                Field   = (string)row[FieldNameIndex],
                Farm    = (string)row[FarmNameIndex],
                Id      = Convert.ToInt32(row[IdIndex]),
                Acreage = 0.0M
            };

            bool validDecimal = decimal.TryParse((string)row[AcreageIndex], out decimal acreage);

            if (validDecimal && acreage > 0)
            {
                newField.Acreage = acreage;
            }


            foreach (var rotationColumn in RotationColumns)
            {
                int           columnIndex = rotationColumn.Value;
                RotationModel newRotation = new RotationModel()
                {
                    FieldId      = newField.Id,
                    RotationYear = rotationColumn.Key
                };
                string plannedCrop = (string)row[columnIndex];

                if (plannedCrop.Length > 0)
                {
                    // convert names to lowercase so just the text is being compared
                    ProductModel matchedCrop = Crops.Where(crop => crop.ItemName.ToLower() == plannedCrop.ToLower())
                                               .ToList().First();

                    if (matchedCrop == null)
                    {
                        throw new Exception($"Crop matching error. Current crop count is: {plannedCrop}");
                    }
                    else
                    {
                        newRotation.ProductId = matchedCrop.Id;
                        newField.Rotations.Add(newRotation);
                    }
                }
            }
            GlobalConfig.Connection.CreateField(newField);
            Fields.Add(newField);
            IList <object> updateRow = new string[] { newField.Farm, newField.Field, newField.Id.ToString() };

            UpdateValues.Add(updateRow);
        }
Пример #20
0
 public override void _PhysicsProcess(float delta)
 {
     if (PlayerColliding && Input.IsActionJustPressed("Player_Action"))
     {
         HeldItem = PlayerBody.Inventory[PlayerBody.Inventory.HeldSlot];
         if (HeldItem.Type == Item.Types.Crop)
         {
             PlayerBody.Money += Crops.GetCrops(HeldItem.ID).Price;
             PlayerBody.Inventory.Remove(HeldItem);
         }
     }
     OutLine.Visible = false;
     PlayerColliding = false;
 }
        private void InitializeCalendarDaysForFall()
        {
            var days = new Dictionary <int, SVCalendarDay>();

            for (var i = 1; i < 29; i++)
            {
                days.Add(i, new SVCalendarDay()
                {
                    DayOfMonth = i,
                });
            }

            days[2].Birthday  = People.Penny;
            days[5].Birthday  = People.Elliott;
            days[11].Birthday = People.Jodi;
            days[13].Birthday = People.Abigail;
            days[15].Birthday = People.Sandy;
            days[18].Birthday = People.Marnie;
            days[21].Birthday = People.Robin;
            days[24].Birthday = People.George;

            days[16].Festival = new SVWikiLink("Stardew Valley Fair", "https://stardewvalleywiki.com/Stardew_Valley_Fair");
            days[27].Festival = new SVWikiLink("Spirit's Eve", "https://stardewvalleywiki.com/Spirit%27s_Eve");

            days[8].Notes.Add("Blackberry Season");
            days[9].Notes.Add("Blackberry Season");
            days[10].Notes.Add("Blackberry Season");
            days[11].Notes.Add("Blackberry Season");
            days[16].Notes.Add("Blacksmith closes at 10:30am");
            days[28].Notes.Add("Reminder: Krobus' birthday is on Winter 1st");

            var crops = Crops.GetFallCrops();

            foreach (var crop in crops)
            {
                days[(int)crop.CalculatedValues.FirstDayToPlant.Normal].FirstDayToPlant.Add(crop);
                days[(int)crop.CalculatedValues.FirstDayToPlant.SpeedGroOrAgriculturalist].FirstDayToPlantTen.Add(crop);
                days[(int)crop.CalculatedValues.FirstDayToPlant.SpeedGroAndAgriculturalist].FirstDayToPlantTwenty.Add(crop);
                days[(int)crop.CalculatedValues.FirstDayToPlant.Deluxe].FirstDayToPlantTwentyFive.Add(crop);
                days[(int)crop.CalculatedValues.FirstDayToPlant.DeluxeAndAgriculturalist].FirstDayToPlantThirtyFive.Add(crop);

                days[(int)crop.CalculatedValues.LastDayToPlant.Normal].LastDayToPlant.Add(crop);
                days[(int)crop.CalculatedValues.LastDayToPlant.SpeedGroOrAgriculturalist].LastDayToPlantTen.Add(crop);
                days[(int)crop.CalculatedValues.LastDayToPlant.SpeedGroAndAgriculturalist].LastDayToPlantTwenty.Add(crop);
                days[(int)crop.CalculatedValues.LastDayToPlant.Deluxe].LastDayToPlantTwentyFive.Add(crop);
                days[(int)crop.CalculatedValues.LastDayToPlant.DeluxeAndAgriculturalist].LastDayToPlantThirtyFive.Add(crop);
            }

            CalendarDaysForFall = days.Select(x => x.Value).ToList();
        }
        private void InitializeCalendarDaysForSpring()
        {
            var days = new Dictionary <int, SVCalendarDay>();

            for (var i = 1; i < 29; i++)
            {
                days.Add(i, new SVCalendarDay()
                {
                    DayOfMonth = i,
                });
            }

            days[4].Birthday  = People.Kent;
            days[7].Birthday  = People.Lewis;
            days[10].Birthday = People.Vincent;
            days[14].Birthday = People.Haley;
            days[18].Birthday = People.Pam;
            days[20].Birthday = People.Shane;
            days[26].Birthday = People.Pierre;
            days[27].Birthday = People.Emily;

            days[13].Festival = new SVWikiLink("Egg Festival", "https://stardewvalleywiki.com/Egg_Festival");
            days[24].Festival = new SVWikiLink("Flower Dance", "https://stardewvalleywiki.com/Flower_Dance");

            days[13].Notes.Add("Strawberry seeds are only sold at the Egg Festival");
            days[15].Notes.Add("Salmonberry season");
            days[16].Notes.Add("Salmonberry season");
            days[17].Notes.Add("Salmonberry season");
            days[18].Notes.Add("Salmonberry season");
            days[25].Notes.Add("Pam's doctor appointment - Bus doesn't run");

            var crops = Crops.GetSpringCrops();

            foreach (var crop in crops)
            {
                days[(int)crop.CalculatedValues.FirstDayToPlant.Normal].FirstDayToPlant.Add(crop);
                days[(int)crop.CalculatedValues.FirstDayToPlant.SpeedGroOrAgriculturalist].FirstDayToPlantTen.Add(crop);
                days[(int)crop.CalculatedValues.FirstDayToPlant.SpeedGroAndAgriculturalist].FirstDayToPlantTwenty.Add(crop);
                days[(int)crop.CalculatedValues.FirstDayToPlant.Deluxe].FirstDayToPlantTwentyFive.Add(crop);
                days[(int)crop.CalculatedValues.FirstDayToPlant.DeluxeAndAgriculturalist].FirstDayToPlantThirtyFive.Add(crop);

                days[(int)crop.CalculatedValues.LastDayToPlant.Normal].LastDayToPlant.Add(crop);
                days[(int)crop.CalculatedValues.LastDayToPlant.SpeedGroOrAgriculturalist].LastDayToPlantTen.Add(crop);
                days[(int)crop.CalculatedValues.LastDayToPlant.SpeedGroAndAgriculturalist].LastDayToPlantTwenty.Add(crop);
                days[(int)crop.CalculatedValues.LastDayToPlant.Deluxe].LastDayToPlantTwentyFive.Add(crop);
                days[(int)crop.CalculatedValues.LastDayToPlant.DeluxeAndAgriculturalist].LastDayToPlantThirtyFive.Add(crop);
            }

            CalendarDaysForSpring = days.Select(x => x.Value).ToList();
        }
Пример #23
0
    public bool SubCrosCanRelive()
    {
        Crops mSubCrops = PlayerController.Instance.GetSubCropsControlObj() as Crops;

        if (mSubCrops == null)
        {
            return(false);
        }
        if (mSubCropsReliveTimes < mRes.mCropsReliveTimes)
        {
            return(true);
        }

        return(false);
    }
        private void InitializeCalendarDaysForSummer()
        {
            var days = new Dictionary <int, SVCalendarDay>();

            for (var i = 1; i < 29; i++)
            {
                days.Add(i, new SVCalendarDay()
                {
                    DayOfMonth = i,
                });
            }

            days[4].Birthday  = People.Jas;
            days[8].Birthday  = People.Gus;
            days[10].Birthday = People.Maru;
            days[13].Birthday = People.Alex;
            days[17].Birthday = People.Sam;
            days[19].Birthday = People.Demetrius;
            days[22].Birthday = People.Dwarf;
            days[24].Birthday = People.Willy;

            days[11].Festival = new SVWikiLink("Luau", "https://stardewvalleywiki.com/Luau");
            days[28].Festival = new SVWikiLink("Dance of the Moonlight Jellies", "https://stardewvalleywiki.com/Dance_of_the_Moonlight_Jellies");

            days[12].Notes.Add("Extra forageables at the beach");
            days[13].Notes.Add("Extra forageables at the beach");
            days[14].Notes.Add("Extra forageables at the beach");
            days[18].Notes.Add("Robin's doctor appointment - Carpenter Shop Closed");

            var crops = Crops.GetSummerCrops();

            foreach (var crop in crops)
            {
                days[(int)crop.CalculatedValues.FirstDayToPlant.Normal].FirstDayToPlant.Add(crop);
                days[(int)crop.CalculatedValues.FirstDayToPlant.SpeedGroOrAgriculturalist].FirstDayToPlantTen.Add(crop);
                days[(int)crop.CalculatedValues.FirstDayToPlant.SpeedGroAndAgriculturalist].FirstDayToPlantTwenty.Add(crop);
                days[(int)crop.CalculatedValues.FirstDayToPlant.Deluxe].FirstDayToPlantTwentyFive.Add(crop);
                days[(int)crop.CalculatedValues.FirstDayToPlant.DeluxeAndAgriculturalist].FirstDayToPlantThirtyFive.Add(crop);

                days[(int)crop.CalculatedValues.LastDayToPlant.Normal].LastDayToPlant.Add(crop);
                days[(int)crop.CalculatedValues.LastDayToPlant.SpeedGroOrAgriculturalist].LastDayToPlantTen.Add(crop);
                days[(int)crop.CalculatedValues.LastDayToPlant.SpeedGroAndAgriculturalist].LastDayToPlantTwenty.Add(crop);
                days[(int)crop.CalculatedValues.LastDayToPlant.Deluxe].LastDayToPlantTwentyFive.Add(crop);
                days[(int)crop.CalculatedValues.LastDayToPlant.DeluxeAndAgriculturalist].LastDayToPlantThirtyFive.Add(crop);
            }

            CalendarDaysForSummer = days.Select(x => x.Value).ToList();
        }
Пример #25
0
        /// <summary>
        /// Harvest all crops from this seed
        /// </summary>
        public void Harvest()
        {
            Crop[] cropsToRemove = Crops.ToArray(); //used because you cant remove from Crops while enumerating it

            foreach (Crop crop in cropsToRemove)
            {
                Program.Game.AddCropToInventory(crop);
                this.Crops.Remove(crop);
            }

            if (SeedType == Enumerations.SeedType.Vegetable)
            {
                Field.RemoveSeed();
            }
            else
            {
                InitializeCrops();
            }
        }
Пример #26
0
 // Constructor
 public Habitat(int[] habitatCounters, float oceanPer)
 {
     typePercents = new double[13];
     percentOcean = oceanPer;
     if (percentOcean != 1f)
     {
         CreateInitialPercentage(habitatCounters);
     }
     // Once the habitats have been loaded figure out which one is dominant
     dominantType = CheckDominantType();
     // Create base quality
     // Temporarily quality = 50;
     quality = 50;
     // Create empty Plant & Animal Habitat objects
     crops   = new Crops();
     grazing = new Graze();
     forest  = new Trees();
     game    = new Game();
 }
Пример #27
0
 /// <summary>
 /// Initialises the instance from the db value
 /// </summary>
 public void Initialise(string dbValue)
 {
     if (!string.IsNullOrWhiteSpace(dbValue))
     {
         JsonConvert.PopulateObject(dbValue, this);
         _underlying = JsonConvert.DeserializeObject <ImageCropDataSet>(dbValue);                //This is useful as it has logic for generating the crop URLs
         Effects.SetUnderlyingDataset(_underlying);
         if (Crops == null)
         {
             Crops = new List <ImageCrop>();
         }
         Crops.ForEach(x => x.SetUnderlyingDataset(_underlying));
         var crops = GetCropsFromProperties();
         foreach (var crop in crops)
         {
             crop.Key.SetValue(this, Crops.FirstOrDefault(x => x.Alias == crop.Value.Alias));
         }
     }
 }
Пример #28
0
        /// <summary>
        /// Initializes the crops added when planting this seed
        /// </summary>
        public void InitializeCrops()
        {
            Random rnd = new Random((int)DateTime.Now.Ticks.GetHashCode());

            //TODO: this will be used when extracting seeds from the finished crop
            //int extraCropChance = 0;
            //extraCropChance += (int)SeedQuality;
            //if (rnd.Next(extraCropChance, 100) == extraCropChance)
            //  _cropRate++;

            int cropsToGrow = _cropRate;

            cropsToGrow += rnd.Next(-2, 2);

            for (int i = 0; i < cropsToGrow; i++)
            {
                double num       = rnd.Next(-10, 10);
                double newWeight = ((double)((num / 100) * -(int)SeedQuality) * ParentCrop.EndWeight) + ParentCrop.EndWeight;
                Crops.Add(new Crop(Name, newWeight, this));
            }
        }
Пример #29
0
    // 复活答复
    private void onMainCropsReliveRespond(EventBase evt)
    {
        CropsEvent e = evt as CropsEvent;

        if (e == null)
        {
            return;
        }

        Crops mMainCrops = PlayerController.Instance.GetMainCropsControlObj() as Crops;

        if (mMainCrops == null)
        {
            return;
        }
        if (mMainCropsReliveTimes < mRes.mCropsReliveTimes)
        {
            mMainCrops.Relive((int)mMainCrops.GetMaxHP(), (int)mMainCrops.GetMaxMana());
            mMainCropsReliveTimes++;
        }
    }
Пример #30
0
    private void ToggleWindows(bool activation)
    {
        switch (currentWindows)
        {
        case Windows.Calendar:
            Calendar.SetActive(activation);
            break;

        case Windows.Ground:
            TypesOfGround.SetActive(activation);
            break;

        case Windows.Climate:
            TypesOfClimate.SetActive(activation);
            break;

        case Windows.Crops:
            Crops.SetActive(activation);
            break;

        case Windows.Pests:
            Pests.SetActive(activation);
            break;

        case Windows.Profile:
            Profile.SetActive(activation);
            break;

        case Windows.Tomato_info:
            Tomato_info.SetActive(activation);
            break;

        case Windows.General_info:
            General_info.SetActive(activation);
            break;
        }
    }