示例#1
0
        private static void addNewHatchedAnimal(string name)
        {
            Building   building   = parentAnimal.home;
            FarmAnimal farmAnimal = new FarmAnimal(parentAnimal.type.Value, DataLoader.Helper.Multiplayer.GetNewID(), (long)Game1.player.UniqueMultiplayerID)
            {
                Name        = name,
                displayName = name,

                home = building,
            };

            farmAnimal.parentId.Value     = parentAnimal.myID.Value;
            farmAnimal.homeLocation.Value = new Vector2((float)building.tileX.Value, (float)building.tileY.Value);
            farmAnimal.setRandomPosition(farmAnimal.home.indoors.Value);
            (building.indoors.Value as AnimalHouse).animals.Add(farmAnimal.myID.Value, farmAnimal);
            (building.indoors.Value as AnimalHouse).animalsThatLiveHere.Add(farmAnimal.myID.Value);

            PregnancyItem pregnacyItem = PregnancyController.GetPregnancyItem(parentAnimal.myID.Value);

            parentAnimal.allowReproduction.Value = pregnacyItem.AllowReproductionBeforeInsemination;
            PregnancyController.RemovePregnancyItem(pregnacyItem.Id);
            parentAnimal = null;

            Game1.exitActiveMenu();
        }
示例#2
0
 public override void performHoverAction(int x, int y)
 {
     base.performHoverAction(x, y);
     if (_movingAnimal.GetValue())
     {
         Vector2  tile             = new Vector2((float)((x + Game1.viewport.X) / Game1.tileSize), (float)((y + Game1.viewport.Y) / Game1.tileSize));
         Farm     locationFromName = Game1.getLocationFromName("Farm") as Farm;
         Building buildingAt       = locationFromName.getBuildingAt(tile);
         if (buildingAt != null)
         {
             if (buildingAt.color.Equals(Color.LightGreen * 0.8f) &&
                 PregnancyController.IsAnimalPregnant(this._farmAnimal.myID.Value) &&
                 PregnancyController.CheckBuildingLimit((buildingAt.indoors.Value as AnimalHouse)))
             {
                 buildingAt.color.Value = Color.Red * 0.8f;
             }
         }
     }
     else
     {
         if (this.meatButton != null)
         {
             if (this.meatButton.containsPoint(x, y))
             {
                 this.meatButton.scale = Math.Min(4.1f, this.meatButton.scale + 0.05f);
                 _hoverText.SetValue(DataLoader.i18n.Get("Menu.AnimalQueryMenu.ExchangeAnimalForMeat"));
             }
             else
             {
                 this.meatButton.scale = Math.Max(4f, this.sellButton.scale - 0.05f);
             }
         }
         if (this.pregnantStatus != null)
         {
             if (this.pregnantStatus.containsPoint(x, y))
             {
                 int daysUtilBirth = PregnancyController.GetPregnancyItem(this._farmAnimal.myID.Value).DaysUntilBirth;
                 if (daysUtilBirth > 1)
                 {
                     _hoverText.SetValue(DataLoader.i18n.Get("Menu.AnimalQueryMenu.DaysUntilBirth", new { numberOfDays = daysUtilBirth }));
                 }
                 else
                 {
                     _hoverText.SetValue(DataLoader.i18n.Get("Menu.AnimalQueryMenu.ReadyForBirth"));
                 }
             }
         }
         if (this.treatStatus != null)
         {
             if (this.treatStatus.containsPoint(x, y))
             {
                 int daysUntilNextTreat = TreatsController.DaysUntilNextTreat(this._farmAnimal);
                 if (daysUntilNextTreat > 1)
                 {
                     _hoverText.SetValue(DataLoader.i18n.Get("Menu.AnimalQueryMenu.WantsTreatInDays", new { numberOfDays = daysUntilNextTreat }));
                 }
                 else if (daysUntilNextTreat == 1)
                 {
                     _hoverText.SetValue(DataLoader.i18n.Get("Menu.AnimalQueryMenu.WantsTreatTomorrow"));
                 }
                 else
                 {
                     _hoverText.SetValue(DataLoader.i18n.Get("Menu.AnimalQueryMenu.WantsTreat"));
                 }
             }
         }
         if (this.animalContestIndicator != null)
         {
             if (this.animalContestIndicator.containsPoint(x, y))
             {
                 if (AnimalContestController.CanChangeParticipant(this._farmAnimal))
                 {
                     _hoverText.SetValue(DataLoader.i18n.Get("Menu.AnimalQueryMenu.ChangeParticipant"));
                 }
                 else if (AnimalContestController.HasParticipated(this._farmAnimal) && AnimalContestController.HasWon(this._farmAnimal))
                 {
                     SDate date = AnimalContestController.GetParticipantDate(this._farmAnimal);
                     _hoverText.SetValue(DataLoader.i18n.Get("Menu.AnimalQueryMenu.Winner", new { contestDate = Utility.getDateStringFor(date.Day, Utility.getSeasonNumber(date.Season), date.Year) }));
                 }
                 else
                 {
                     SDate date = AnimalContestController.GetParticipantDate(this._farmAnimal);
                     _hoverText.SetValue(DataLoader.i18n.Get("Menu.AnimalQueryMenu.ContestParticipant", new { contestDate = Utility.getDateStringFor(date.Day, Utility.getSeasonNumber(date.Season), date.Year) }));
                 }
             }
         }
     }
 }