/// <summary> /// Called when left click is performed in our menu /// </summary> /// <param name="x">The x coordinate.</param> /// <param name="y">The y coordinate.</param> /// <param name="playSound">If set to <c>true</c> play sound.</param> public override void receiveLeftClick(int x, int y, bool playSound = true) { // invoke base class method base.receiveLeftClick(x, y, playSound); // if we are fading then ignore if (Game1.globalFade) { return; } // get cursor tile location var tileLocation = new Vector2( (Game1.viewport.X + x) / Game1.tileSize, (Game1.viewport.Y + y) / Game1.tileSize ); if (cancelButton.containsPoint(x, y)) { handleCancelAction(); return; } if (flipButton.containsPoint(x, y)) { flipTree(); return; } if (!canPlace && selectedTree != null) { Notifier.Message("Can't place here!"); Game1.playSound("cancel"); } else if (selectedTree != null && tileLocation == selectedTreeLocation) { selectedTree.propFlip(); selectedTree = null; Game1.playSound("shwip"); } else if (Game1.currentLocation.terrainFeatures.ContainsKey(tileLocation)) { // get our terrain feature TerrainFeature terrainFeature = Game1.currentLocation.terrainFeatures[tileLocation]; // make sure its the type we care about if (terrainFeature is FruitTree || terrainFeature is Tree) { if (terrainFeature is Tree && (terrainFeature as Tree).tapped.Value) { Notifier.Message("Can't move tree with a tree tap!"); Game1.playSound("cancel"); return; } // set the selected tree selectedTree = new TreeRenderer(terrainFeature); selectedTreeLocation = tileLocation; Game1.playSound("bigSelect"); } } else if (selectedTree != null) { // remove the original Game1.currentLocation.terrainFeatures.Remove(selectedTreeLocation); // perform the flip that's done in memory selectedTree.propFlip(); // add a new one in the spot selected Game1.currentLocation.terrainFeatures.Add(tileLocation, selectedTree.tree.getTerrainFeature()); // play sound of tree Game1.playSound("bigDeSelect"); // deselect the tree selectedTree = null; selectedTreeLocation = Vector2.Zero; } }