예제 #1
0
 public override void receiveGamePadButton(Buttons b)
 {
     base.receiveGamePadButton(b);
     if (!this.onFarm && b == Buttons.LeftTrigger)
     {
         this.currentBlueprintIndex--;
         if (this.currentBlueprintIndex < 0)
         {
             this.currentBlueprintIndex = this.blueprints.Count - 1;
         }
         this.setNewActiveBlueprint();
         Game1.playSound("shwip");
     }
     if (!this.onFarm && b == Buttons.RightTrigger)
     {
         this.currentBlueprintIndex = (this.currentBlueprintIndex + 1) % this.blueprints.Count;
         this.setNewActiveBlueprint();
         Game1.playSound("shwip");
     }
     if (!this.onFarm && b == Buttons.LeftShoulder)
     {
         currentFarm = framework.swapFarm(currentFarm);
         this.currentBlueprintIndex = 0;
         this.populateFarmBlueprints();
         this.setNewActiveBlueprint();
         Game1.playSound("shwip");
         previousFarmButton.scale = previousFarmButton.baseScale;
     }
     if (!this.onFarm && b == Buttons.RightShoulder)
     {
         currentFarm = framework.swapFarm(currentFarm);
         this.currentBlueprintIndex = 0;
         this.populateFarmBlueprints();
         this.setNewActiveBlueprint();
         nextFarmButton.scale = nextFarmButton.baseScale;
         Game1.playSound("shwip");
     }
 }
예제 #2
0
        private void swapFarm()
        {
            // clean up before leaving the area
            Game1.currentLocation.cleanupBeforePlayerExit();
            // move to the opposite farm
            Game1.currentLocation = Game1.currentLocation.GetType().FullName.Contains("Expansion") ? Game1.getFarm() : Game1.getLocationFromName("FarmExpansion");
            // reset the location for our entry
            Game1.currentLocation.resetForPlayerEntry();
            // ensure the TreeTransplant menu is checking the right farm when determining whether a tree can be placed
            Farm farm = framework.helper.Reflection.GetField <Farm>(TreeTransplantMenu, "farm").GetValue();

            framework.helper.Reflection.GetField <Farm>(TreeTransplantMenu, "farm").SetValue(framework.swapFarm(farm));
            // set the new viewport
            Game1.viewport.Location = new Location(49 * Game1.tileSize, 5 * Game1.tileSize);
            // pan the screen
            Game1.panScreen(0, 0);
            // fade the screen in with no callback
            Game1.globalFadeToClear();
        }
 public override void receiveLeftClick(int x, int y, bool playSound = true)
 {
     if (Game1.globalFade || this.freeze)
     {
         return;
     }
     if (this.okButton != null && this.okButton.containsPoint(x, y) && this.readyToClose())
     {
         if (this.onFarm)
         {
             Game1.globalFadeToBlack(new Game1.afterFadeFunction(this.setUpForReturnToShopMenu), 0.02f);
             Game1.playSound("smallSelect");
         }
         else
         {
             Game1.exitActiveMenu();
             Game1.playSound("bigDeSelect");
         }
     }
     if (this.onFarm)
     {
         Vector2  tile       = new Vector2((float)((x + Game1.viewport.X) / Game1.tileSize), (float)((y + Game1.viewport.Y) / Game1.tileSize));
         Building buildingAt = currentFarm.getBuildingAt(tile);
         if (buildingAt != null && !this.namingAnimal)
         {
             if (buildingAt.buildingType.Contains(this.animalBeingPurchased.buildingTypeILiveIn.Value))
             {
                 if ((buildingAt.indoors.Value as AnimalHouse).isFull())
                 {
                     Game1.showRedMessage(Game1.content.LoadString("Strings\\StringsFromCSFiles:PurchaseAnimalsMenu.cs.11321", new object[0]));
                 }
                 else if (this.animalBeingPurchased.harvestType.Value != 2)
                 {
                     this.namingAnimal  = true;
                     this.newAnimalHome = buildingAt;
                     if (this.animalBeingPurchased.sound.Value != null && Game1.soundBank != null)
                     {
                         ICue expr_15B = Game1.soundBank.GetCue(this.animalBeingPurchased.sound.Value);
                         expr_15B.SetVariable("Pitch", (float)(1200 + Game1.random.Next(-200, 201)));
                         expr_15B.Play();
                     }
                     this.textBox.OnEnterPressed        += this.e;
                     this.textBox.Text                   = this.animalBeingPurchased.displayName;
                     Game1.keyboardDispatcher.Subscriber = this.textBox;
                     if (Game1.options.SnappyMenus)
                     {
                         this.currentlySnappedComponent = base.getComponentWithID(104);
                         this.snapCursorToCurrentSnappedComponent();
                     }
                 }
                 else if (Game1.player.Money >= this.priceOfAnimal)
                 {
                     this.newAnimalHome             = buildingAt;
                     this.animalBeingPurchased.home = this.newAnimalHome;
                     this.animalBeingPurchased.homeLocation.Value = new Vector2((float)this.newAnimalHome.tileX.Value, (float)this.newAnimalHome.tileY.Value);
                     this.animalBeingPurchased.setRandomPosition(this.animalBeingPurchased.home.indoors.Value);
                     (this.newAnimalHome.indoors.Value as AnimalHouse).animals.Add(this.animalBeingPurchased.myID.Value, this.animalBeingPurchased);
                     (this.newAnimalHome.indoors.Value as AnimalHouse).animalsThatLiveHere.Add(this.animalBeingPurchased.myID.Value);
                     this.newAnimalHome = null;
                     this.namingAnimal  = false;
                     if (this.animalBeingPurchased.sound.Value != null && Game1.soundBank != null)
                     {
                         ICue expr_2DC = Game1.soundBank.GetCue(this.animalBeingPurchased.sound.Value);
                         expr_2DC.SetVariable("Pitch", (float)(1200 + Game1.random.Next(-200, 201)));
                         expr_2DC.Play();
                     }
                     Game1.player.Money -= this.priceOfAnimal;
                     Game1.addHUDMessage(new HUDMessage(Game1.content.LoadString("Strings\\StringsFromCSFiles:PurchaseAnimalsMenu.cs.11324", new object[]
                     {
                         this.animalBeingPurchased.displayType
                     }), Color.LimeGreen, 3500f));
                     this.animalBeingPurchased = new FarmAnimal(this.animalBeingPurchased.type.Value, ModEntry.ModHelper.Multiplayer.GetNewID(), Game1.player.UniqueMultiplayerID);
                 }
                 else if (Game1.player.Money < this.priceOfAnimal)
                 {
                     Game1.dayTimeMoneyBox.moneyShakeTimer = 1000;
                 }
             }
             else
             {
                 Game1.showRedMessage(Game1.content.LoadString("Strings\\StringsFromCSFiles:PurchaseAnimalsMenu.cs.11326", new object[]
                 {
                     this.animalBeingPurchased.displayType
                 }));
             }
         }
         if (this.namingAnimal)
         {
             if (this.doneNamingButton.containsPoint(x, y))
             {
                 this.textBoxEnter(this.textBox);
                 Game1.playSound("smallSelect");
             }
             else if (this.namingAnimal && this.randomButton.containsPoint(x, y))
             {
                 this.animalBeingPurchased.Name        = Dialogue.randomName();
                 this.animalBeingPurchased.displayName = this.animalBeingPurchased.Name;
                 this.textBox.Text       = this.animalBeingPurchased.displayName;
                 this.randomButton.scale = this.randomButton.baseScale;
                 Game1.playSound("drumkit6");
             }
             this.textBox.Update();
             return;
         }
     }
     else
     {
         if (this.previousFarmButton.containsPoint(x, y))
         {
             currentFarm = framework.swapFarm(currentFarm);
             this.populateAnimalStock();
             this.previousFarmButton.scale = this.previousFarmButton.baseScale;
         }
         if (this.nextFarmButton.containsPoint(x, y))
         {
             currentFarm = framework.swapFarm(currentFarm);
             this.populateAnimalStock();
             this.nextFarmButton.scale = this.nextFarmButton.baseScale;
         }
         foreach (ClickableTextureComponent current in this.animalsToPurchase)
         {
             if (current.containsPoint(x, y) && (current.item as Object).Type == null)
             {
                 int num = current.item.salePrice();
                 if (Game1.player.Money >= num)
                 {
                     Game1.globalFadeToBlack(new Game1.afterFadeFunction(this.setUpForAnimalPlacement), 0.02f);
                     Game1.playSound("smallSelect");
                     this.onFarm = true;
                     this.animalBeingPurchased = new FarmAnimal(current.hoverText, ModEntry.ModHelper.Multiplayer.GetNewID(), Game1.player.UniqueMultiplayerID);
                     this.priceOfAnimal        = num;
                 }
                 else
                 {
                     Game1.addHUDMessage(new HUDMessage(Game1.content.LoadString("Strings\\StringsFromCSFiles:PurchaseAnimalsMenu.cs.11325", new object[0]), Color.Red, 3500f));
                 }
             }
         }
     }
 }