Beispiel #1
0
 public override void receiveLeftClick(int x, int y, bool playSound = true)
 {
     base.receiveLeftClick(x, y, playSound);
     textBox.Update();
     if (doneNamingButton.containsPoint(x, y))
     {
         textBoxEnter(textBox);
         Game1.playSound("smallSelect");
     }
     else if (randomButton.containsPoint(x, y))
     {
         textBox.Text       = Dialogue.randomName();
         randomButton.scale = randomButton.baseScale;
         Game1.playSound("drumkit6");
     }
     textBox.Update();
 }
 public override void receiveLeftClick(int x, int y, bool playSound = true)
 {
     if (leftButton.containsPoint(x, y))
     {
         int tempNumber2 = currentValue - 1;
         if (tempNumber2 >= minValue)
         {
             leftButton.scale       = leftButton.baseScale;
             currentValue           = tempNumber2;
             numberSelectedBox.Text = string.Concat(currentValue);
             Game1.playSound("smallSelect");
         }
     }
     if (rightButton.containsPoint(x, y))
     {
         int tempNumber = currentValue + 1;
         if (tempNumber <= maxValue && (price == -1 || tempNumber * price <= Game1.player.Money))
         {
             rightButton.scale      = rightButton.baseScale;
             currentValue           = tempNumber;
             numberSelectedBox.Text = string.Concat(currentValue);
             Game1.playSound("smallSelect");
         }
     }
     if (okButton.containsPoint(x, y))
     {
         if (currentValue > maxValue || currentValue < minValue)
         {
             currentValue           = Math.Max(minValue, Math.Min(maxValue, currentValue));
             numberSelectedBox.Text = string.Concat(currentValue);
         }
         else
         {
             behaviorFunction(currentValue, price, Game1.player);
         }
         Game1.playSound("smallSelect");
     }
     if (cancelButton.containsPoint(x, y))
     {
         Game1.exitActiveMenu();
         Game1.playSound("bigDeSelect");
         Game1.player.canMove = true;
     }
     numberSelectedBox.Update();
 }
Beispiel #3
0
 public override void receiveLeftClick(int x, int y, bool playSound = true)
 {
     if (Game1.globalFade)
     {
         return;
     }
     if (movingAnimal)
     {
         if (okButton != null && okButton.containsPoint(x, y))
         {
             Game1.globalFadeToBlack(prepareForReturnFromPlacement);
             Game1.playSound("smallSelect");
         }
         Vector2  clickTile = new Vector2((Game1.viewport.X + Game1.getOldMouseX(ui_scale: false)) / 64, (Game1.viewport.Y + Game1.getOldMouseY(ui_scale: false)) / 64);
         Building selection = (Game1.getLocationFromName("Farm") as Farm).getBuildingAt(clickTile);
         if (selection == null)
         {
             return;
         }
         if (selection.buildingType.Value.Contains(animal.buildingTypeILiveIn.Value))
         {
             if ((selection.indoors.Value as AnimalHouse).isFull())
             {
                 Game1.showRedMessage(Game1.content.LoadString("Strings\\UI:AnimalQuery_Moving_BuildingFull"));
                 return;
             }
             if (selection.Equals(animal.home))
             {
                 Game1.showRedMessage(Game1.content.LoadString("Strings\\UI:AnimalQuery_Moving_AlreadyHome"));
                 return;
             }
             (animal.home.indoors.Value as AnimalHouse).animalsThatLiveHere.Remove(animal.myID);
             if ((animal.home.indoors.Value as AnimalHouse).animals.ContainsKey(animal.myID))
             {
                 (selection.indoors.Value as AnimalHouse).animals.Add(animal.myID, animal);
                 (animal.home.indoors.Value as AnimalHouse).animals.Remove(animal.myID);
             }
             animal.home = selection;
             animal.homeLocation.Value = new Vector2((int)selection.tileX, (int)selection.tileY);
             (selection.indoors.Value as AnimalHouse).animalsThatLiveHere.Add(animal.myID);
             animal.makeSound();
             Game1.globalFadeToBlack(finishedPlacingAnimal);
         }
         else
         {
             Game1.showRedMessage(Game1.content.LoadString("Strings\\UI:AnimalQuery_Moving_CantLiveThere", animal.shortDisplayType()));
         }
         return;
     }
     if (confirmingSell)
     {
         if (yesButton.containsPoint(x, y))
         {
             Game1.player.Money += animal.getSellPrice();
             (animal.home.indoors.Value as AnimalHouse).animalsThatLiveHere.Remove(animal.myID);
             animal.health.Value = -1;
             if (animal.foundGrass != null && FarmAnimal.reservedGrass.Contains(animal.foundGrass))
             {
                 FarmAnimal.reservedGrass.Remove(animal.foundGrass);
             }
             int numClouds = animal.frontBackSourceRect.Width / 2;
             for (int i = 0; i < numClouds; i++)
             {
                 int nonRedness = Game1.random.Next(25, 200);
                 Game1.multiplayer.broadcastSprites(Game1.currentLocation, new TemporaryAnimatedSprite(5, animal.Position + new Vector2(Game1.random.Next(-32, animal.frontBackSourceRect.Width * 3), Game1.random.Next(-32, animal.frontBackSourceRect.Height * 3)), new Color(255 - nonRedness, 255, 255 - nonRedness), 8, flipped: false, (Game1.random.NextDouble() < 0.5) ? 50 : Game1.random.Next(30, 200), 0, 64, -1f, 64, (!(Game1.random.NextDouble() < 0.5)) ? Game1.random.Next(0, 600) : 0)
                 {
                     scale  = (float)Game1.random.Next(2, 5) * 0.25f,
                     alpha  = (float)Game1.random.Next(2, 5) * 0.25f,
                     motion = new Vector2(0f, (float)(0.0 - Game1.random.NextDouble()))
                 });
             }
             Game1.playSound("newRecipe");
             Game1.playSound("money");
             Game1.exitActiveMenu();
         }
         else if (noButton.containsPoint(x, y))
         {
             confirmingSell = false;
             Game1.playSound("smallSelect");
             if (Game1.options.SnappyMenus)
             {
                 currentlySnappedComponent = getComponentWithID(103);
                 snapCursorToCurrentSnappedComponent();
             }
         }
         return;
     }
     if (okButton != null && okButton.containsPoint(x, y) && readyToClose())
     {
         Game1.exitActiveMenu();
         if (textBox.Text.Length > 0 && !Utility.areThereAnyOtherAnimalsWithThisName(textBox.Text))
         {
             animal.displayName = textBox.Text;
             animal.Name        = textBox.Text;
         }
         Game1.playSound("smallSelect");
     }
     if (sellButton.containsPoint(x, y))
     {
         confirmingSell = true;
         yesButton      = new ClickableTextureComponent(new Microsoft.Xna.Framework.Rectangle(Game1.uiViewport.Width / 2 - 64 - 4, Game1.uiViewport.Height / 2 - 32, 64, 64), Game1.mouseCursors, Game1.getSourceRectForStandardTileSheet(Game1.mouseCursors, 46), 1f)
         {
             myID            = 111,
             rightNeighborID = 105
         };
         noButton = new ClickableTextureComponent(new Microsoft.Xna.Framework.Rectangle(Game1.uiViewport.Width / 2 + 4, Game1.uiViewport.Height / 2 - 32, 64, 64), Game1.mouseCursors, Game1.getSourceRectForStandardTileSheet(Game1.mouseCursors, 47), 1f)
         {
             myID           = 105,
             leftNeighborID = 111
         };
         Game1.playSound("smallSelect");
         if (Game1.options.SnappyMenus)
         {
             populateClickableComponentList();
             currentlySnappedComponent = noButton;
             snapCursorToCurrentSnappedComponent();
         }
         return;
     }
     if (moveHomeButton.containsPoint(x, y))
     {
         Game1.playSound("smallSelect");
         Game1.globalFadeToBlack(prepareForAnimalPlacement);
     }
     if (allowReproductionButton != null && allowReproductionButton.containsPoint(x, y))
     {
         Game1.playSound("drumkit6");
         animal.allowReproduction.Value = !animal.allowReproduction;
         if ((bool)animal.allowReproduction)
         {
             allowReproductionButton.sourceRect.X = 128;
         }
         else
         {
             allowReproductionButton.sourceRect.X = 137;
         }
     }
     textBox.Update();
 }
Beispiel #4
0
 public override void receiveLeftClick(int x, int y, bool playSound = true)
 {
     if (Game1.globalFade || freeze)
     {
         return;
     }
     if (okButton != null && okButton.containsPoint(x, y) && readyToClose())
     {
         if (onFarm)
         {
             setUpForReturnToShopMenu();
             Game1.playSound("smallSelect");
         }
         else
         {
             Game1.exitActiveMenu();
             Game1.playSound("bigDeSelect");
         }
     }
     if (onFarm)
     {
         Vector2  clickTile = new Vector2((x + Game1.viewport.X) / 64, (y + Game1.viewport.Y) / 64);
         Building selection = (Game1.getLocationFromName("Farm") as Farm).getBuildingAt(clickTile);
         if (selection != null && !namingAnimal)
         {
             if (selection.buildingType.Value.Contains(animalBeingPurchased.buildingTypeILiveIn.Value))
             {
                 if ((selection.indoors.Value as AnimalHouse).isFull())
                 {
                     Game1.showRedMessage(Game1.content.LoadString("Strings\\StringsFromCSFiles:PurchaseAnimalsMenu.cs.11321"));
                 }
                 else if ((byte)animalBeingPurchased.harvestType != 2)
                 {
                     namingAnimal  = true;
                     newAnimalHome = selection;
                     if (animalBeingPurchased.sound.Value != null && Game1.soundBank != null)
                     {
                         ICue cue = Game1.soundBank.GetCue(animalBeingPurchased.sound.Value);
                         cue.SetVariable("Pitch", 1200 + Game1.random.Next(-200, 201));
                         cue.Play();
                     }
                     textBox.OnEnterPressed += e;
                     textBox.Text            = animalBeingPurchased.displayName;
                     Game1.keyboardDispatcher.Subscriber = textBox;
                     if (Game1.options.SnappyMenus)
                     {
                         currentlySnappedComponent = getComponentWithID(104);
                         snapCursorToCurrentSnappedComponent();
                     }
                 }
                 else if (Game1.player.Money >= priceOfAnimal)
                 {
                     newAnimalHome             = selection;
                     animalBeingPurchased.home = newAnimalHome;
                     animalBeingPurchased.homeLocation.Value = new Vector2((int)newAnimalHome.tileX, (int)newAnimalHome.tileY);
                     animalBeingPurchased.setRandomPosition(animalBeingPurchased.home.indoors);
                     (newAnimalHome.indoors.Value as AnimalHouse).animals.Add(animalBeingPurchased.myID, animalBeingPurchased);
                     (newAnimalHome.indoors.Value as AnimalHouse).animalsThatLiveHere.Add(animalBeingPurchased.myID);
                     newAnimalHome = null;
                     namingAnimal  = false;
                     if (animalBeingPurchased.sound.Value != null && Game1.soundBank != null)
                     {
                         ICue cue2 = Game1.soundBank.GetCue(animalBeingPurchased.sound.Value);
                         cue2.SetVariable("Pitch", 1200 + Game1.random.Next(-200, 201));
                         cue2.Play();
                     }
                     Game1.player.Money -= priceOfAnimal;
                     Game1.addHUDMessage(new HUDMessage(Game1.content.LoadString("Strings\\StringsFromCSFiles:PurchaseAnimalsMenu.cs.11324", animalBeingPurchased.displayType), Color.LimeGreen, 3500f));
                     animalBeingPurchased = new FarmAnimal(animalBeingPurchased.type, Game1.multiplayer.getNewID(), Game1.player.uniqueMultiplayerID);
                 }
                 else if (Game1.player.Money < priceOfAnimal)
                 {
                     Game1.dayTimeMoneyBox.moneyShakeTimer = 1000;
                 }
             }
             else
             {
                 Game1.showRedMessage(Game1.content.LoadString("Strings\\StringsFromCSFiles:PurchaseAnimalsMenu.cs.11326", animalBeingPurchased.displayType));
             }
         }
         if (namingAnimal)
         {
             if (doneNamingButton.containsPoint(x, y))
             {
                 textBoxEnter(textBox);
                 Game1.playSound("smallSelect");
             }
             else if (namingAnimal && randomButton.containsPoint(x, y))
             {
                 animalBeingPurchased.Name        = Dialogue.randomName();
                 animalBeingPurchased.displayName = animalBeingPurchased.Name;
                 textBox.Text       = animalBeingPurchased.displayName;
                 randomButton.scale = randomButton.baseScale;
                 Game1.playSound("drumkit6");
             }
             textBox.Update();
         }
     }
     else
     {
         foreach (ClickableTextureComponent c in animalsToPurchase)
         {
             if (c.containsPoint(x, y) && (c.item as Object).Type == null)
             {
                 int price = c.item.salePrice();
                 if (Game1.player.Money >= price)
                 {
                     Game1.globalFadeToBlack(setUpForAnimalPlacement);
                     Game1.playSound("smallSelect");
                     onFarm = true;
                     animalBeingPurchased = new FarmAnimal(c.hoverText, Game1.multiplayer.getNewID(), Game1.player.UniqueMultiplayerID);
                     priceOfAnimal        = price;
                 }
                 else
                 {
                     Game1.addHUDMessage(new HUDMessage(Game1.content.LoadString("Strings\\StringsFromCSFiles:PurchaseAnimalsMenu.cs.11325"), Color.Red, 3500f));
                 }
             }
         }
     }
 }
 public override void receiveLeftClick(int x, int y)
 {
     textBox.SelectMe();
     textBox.Update();
 }