public Button(Texture2D texture, Vector2 position, string text, SpriteFont font, Game1 game) : base(position) { base.Text = text; this.texture = texture; this.Font = font; bounds = new Rectangle((int)position.X, (int)position.Y, texture.Width, texture.Height); switch (Text) { case "Create": change = MenuState.Create; break; case "Join": change = MenuState.Join; break; case "Exit to menu": case "Back": change = MenuState.Menu; break; default: change = null; break; } if (Text.Contains("Level")) change = MenuState.Start; WireUpEvents(game); }
/// <summary> /// Constructeur /// </summary> /// <param name="port">Port d'ecoute</param> /// <param name="cl"></param> public Recepteur(int port, Game1 cl) { this._client = cl; this._portReception = port; this._ip = GestionReseau.GetMyLocalIp(); _reception = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp); }
public void Initialize(Vector2 screenDimension, SpriteFont font, Game1 game) { this.screenDimension = screenDimension; spFont = font; this.game = game; }
/// <summary> /// The main entry point for the application. /// </summary> static void Main(string[] args) { using (Game1 game = new Game1()) { game.Run(); } }
// ReSharper restore UnusedParameter.Local /// <summary> /// The main entry point for the application. /// </summary> // ReSharper disable UnusedParameter.Local private static void Main(string[] args) { using (var game = new Game1()) { game.Run(); } }
public ModeInputSystem(Game1 game) : base(game) { this.wasPressed = false; this.filled = false; this._game = game; }
public GameObject(Game1 game, Vector2 startLocation) { this.Game = game; this.Location = startLocation; this.Transparency = 1; SpriteEffect = SpriteEffects.None; }
public Player(Game game, Character character) { gameRef = (Game1)game; camera = new Camera(gameRef.ScreenRectangle); this.character = character; Sprite.Position = new Vector2(1000, 1000); }
public SplashScreen(Game game) : base(game) { this.game = game; game1 = (Game1)game; // TODO: Construct any child components here }
public GameLobby(Game1 g, MenuManager mm) : base(g, mm) { // pos is proportional to screen size (IE, SCREENWIDTH / 20 * pos) AddFlavorItem("Class Type", new Vector2(1, 11)); AddFlavorItem("_________", new Vector2(1, 12)); AddMenuItem("Mapmaker", new Vector2(1, 13), 0, delegate() { classType = "mapmaker"; SendClass(); ActivateItem(0, 0); }); AddMenuItem("Ninja", new Vector2(1, 14), 0, delegate() { classType = "ninja"; SendClass(); ActivateItem(1, 0); }); AddMenuItem("Powdermonkey", new Vector2(1, 15), 0, delegate() { classType = "powdermonkey"; SendClass(); ActivateItem(2, 0); }); AddMenuItem("Capitalist", new Vector2(1, 16), 0, delegate() { classType = "capitalist"; SendClass(); ActivateItem(3, 0); }); AddMenuItem("Apothecary", new Vector2(1, 17), 0, delegate() { classType = "apothecary"; SendClass(); ActivateItem(4, 0); }); AddMenuItem("Mystic", new Vector2(1, 18), 0, delegate() { classType = "mystic"; SendClass(); ActivateItem(5, 0); }); AddFlavorItem("Team", new Vector2(7, 11)); AddFlavorItem("_________", new Vector2(7, 12)); AddMenuItem("Blue", new Vector2(7, 13), 1, delegate() { team = 0; SendTeam(); ActivateItem(0, 1); }); AddMenuItem("Red", new Vector2(7, 14), 1, delegate() { team = 1; SendTeam(); ActivateItem(1, 1); }); AddMenuItem("OK", new Vector2(15, 12), 2, delegate() { SendReady(); }); AddFlavorItem("____________________________________________________________________", new Vector2(0, 9.5f)); }
public FirstBossSprite(Game1 game, Texture2D textureImage, Vector2 position, Point frameSize, int collisionOffset, Point currentFrame, Point sheetSize, Vector2 speed, bool animate, int life, int millisecondsPerFrame) : base(game, textureImage, position, frameSize, collisionOffset, currentFrame, sheetSize, speed, animate, life * (int)InGameScreen.difficulty, millisecondsPerFrame) { alive = true; scoreAmount = 60; warningTexture = new Texture2D(game.GraphicsDevice, 1, 1); warningTexture.SetData<Color>(colorData); laserStruckTarget = false; //Creates the left hitbox. hitBox.X = 37 + (int)position.X; hitBox.Y = 156 + (int)position.Y; hitBox.Width = 30; hitBox.Height = 47; //Creates the right hitbox. nonMoveableBossHitbox.X = 121 + (int)position.X; nonMoveableBossHitbox.Y = 147 + (int)position.Y; nonMoveableBossHitbox.Width = 30; nonMoveableBossHitbox.Height = 47; }
public MovingGameObject(Game1 game) : base(game) { velocity = new InterpolatedVector2GameObjectMember(this, new Vector2(0)); angularSpeed = new FloatGameObjectMember(this, 0); targetAngle = new FloatGameObjectMember(this, 0); }
public BeamBit(Game1 game, BeamPool pool) : base(game) { Pool = pool; AssetName = "shipBullet"; AddAnimation("shot", FrameSequence(0, 1), TimingSequence(5, 1), true); }
public ArrowInputSystem(Game1 game, int playerNum) : base(game) { this._componentDependencies.Add(ComponentType.Player); this._componentDependencies.Add(ComponentType.Arrow); this.playerNumber = playerNum; }
public PauseMenu(IGameState prevGameState, Game1 game) { this.game = game; this.prevGameState = prevGameState; currentSelection = Selections.Resume; font = MenuSpriteFactory.CreateHUDFont(); }
/// <summary> /// Конструктор класса /// </summary> /// <param name="Rect">прямоугольник объекта</param> /// <param name="texture">текстура объекта</param> /// <param name="game">ссылка на игру</param> /// <param name="camera">ссылка на камеру</param> public BaseObject(Rectangle Rect, Texture2D texture, Game1 game, Camera camera) { this.Rect = Rect; this.texture = texture; this.game = game; this.camera = camera; }
public StaticObjectManager(Game1 game) : base(game) { objects = new List<GameObject>(); spriteBatch = new SpriteBatch(Game.GraphicsDevice); contentManager = game.ContentManager; }
public Card(Game1 game, int x, int y) { this.game = game; this.x = x; this.y = y; LoadImage(); }
public PlayerInputSystem(Game1 game, int playerNumber) : base(game) { this._componentDependencies.Add(ComponentType.Transform2D); this._componentDependencies.Add(ComponentType.Player); this.PlayerNumber = playerNumber; }
public GameState(Game1 game, GameStateManager manager) : base(game) { StateManager = manager; childComponents = new List<GameComponent>(); tag = this; }
public LevelThree(Game1 game) : base(game) { _questions["*"].Add("3,2"); _questions["*"].Add("4,5"); _questions["*"].Add("2,4"); _questions["*"].Add("1,2"); _questions["*"].Add("3,1"); _questions["*"].Add("6,2"); _questions["*"].Add("4,1"); _questions["*"].Add("1,1"); _questions["*"].Add("2,5"); _questions["*"].Add("4,3"); _questions["*"].Add("3,3"); _questions["*"].Add("4,4"); _questions["/"].Add("16,4"); _questions["/"].Add("20,5"); _questions["/"].Add("10,2"); _questions["/"].Add("15,3"); _questions["/"].Add("8,4"); _questions["/"].Add("4,4"); _questions["/"].Add("12,2"); _questions["/"].Add("2,1"); _questions["/"].Add("18,9"); _questions["/"].Add("9,3"); _questions["/"].Add("24,3"); _questions["/"].Add("28,4"); _mountain.Texture = AssetManager.Textures[Assets.GAME_MOUNTAIN_3]; _mountain.Location.Y += 75; GenerateQuestion(); }
public BaseGameState(Game game, GameStateManager manager) : base(game, manager) { GameRef = (Game1)game; playerIndexInControl = PlayerIndex.One; }
public ColonyShip(Game1 game, World world, float ratio, string texturePath, Player player) : base(game, world, texturePath) { _texture = Content.Load<Texture2D>(texturePath); _ratio = ratio; this.player = player; }
public DoublePipe(IGameState gameState, Game1 game) { myGame = game; pipeSprite = TileSpriteFactory.CreateDoublePipeSprite(); isWarpPipe = true; this.gameState = gameState; }
public HandRenderer1(Game1 game) : base(game) { this._componentDependencies.Add(ComponentType.Hand); this._componentDependencies.Add(ComponentType.Player); this._game = game; }
public void Draw(SpriteBatch sb, Game1 game) { float Lenght = (float)Math.Sqrt((p1.X - p2.X) * (p1.X - p2.X) + (p1.Y - p2.Y) * (p1.Y - p2.Y)); float Angle = (float)Math.Atan2(p1.Y - p2.Y, p1.X - p2.X) - (float)Math.PI; Rectangle sourceRectangle = new Rectangle(0, 0, 1, 1); Vector2 origin = new Vector2(0f, 0.5f); Color color = Color; //if (color == game.ColorToChange) // color = game.NewColor; if (Owner != null && (game.WinningTeam == Owner.Team && game.ShouldFlash && !Owner.Dead)) color = new Color(Color.R / 2, Color.G / 2, Color.B / 2); if (Owner == null || Owner.Dead) { color.R >>= 2; color.G >>= 2; color.B >>= 2; color.A >>= 2; } if (game.Paused) { color.R >>= 2; color.G >>= 2; color.B >>= 2; color.A >>= 2; } sb.Draw(Texture, new Rectangle((int)p1.X, (int)p1.Y, (int)Lenght, 2), null, color, Angle, origin, SpriteEffects.None, 1); }
public DoublePipe(Vector2 marioWarpCoordinates, Game1 game) { myGame = game; pipeSprite = TileSpriteFactory.CreateDoublePipeSprite(); isWarpPipe = true; warpLocation = marioWarpCoordinates; }
protected ParticleSystem(Game1 game, int howManyEffects, string textureFileName) : base(game) { this.game = game; this.howManyEffects = howManyEffects; this.textureFilename = textureFileName; }
public BootstrapLoad(Game1 game, IScreen nextScreen, IScreen errorScreen, Action<Action, Action<String>> load) { Next = nextScreen; this.game = game; loadingThread = new Thread(a => load(() => complete = true, s => strings.Push(s))); }
public AABBCollisionRenderSystem(Game1 game) : base(game) { this._componentDependencies.Add(ComponentType.Position); this._componentDependencies.Add(ComponentType.AABBCollision); this._componentDependencies.Add(ComponentType.Color); }
public override void performHoverAction(int x, int y) { hoverText = ""; if (movingAnimal) { Vector2 clickTile = new Vector2((x + Game1.viewport.X) / 64, (y + Game1.viewport.Y) / 64); Farm f = Game1.getLocationFromName("Farm") as Farm; foreach (Building building in f.buildings) { building.color.Value = Color.White; } Building selection = f.getBuildingAt(clickTile); if (selection != null) { if (selection.buildingType.Value.Contains(animal.buildingTypeILiveIn.Value) && !(selection.indoors.Value as AnimalHouse).isFull() && !selection.Equals(animal.home)) { selection.color.Value = Color.LightGreen * 0.8f; } else { selection.color.Value = Color.Red * 0.8f; } } } if (okButton != null) { if (okButton.containsPoint(x, y)) { okButton.scale = Math.Min(1.1f, okButton.scale + 0.05f); } else { okButton.scale = Math.Max(1f, okButton.scale - 0.05f); } } if (sellButton != null) { if (sellButton.containsPoint(x, y)) { sellButton.scale = Math.Min(4.1f, sellButton.scale + 0.05f); hoverText = Game1.content.LoadString("Strings\\UI:AnimalQuery_Sell", animal.getSellPrice()); } else { sellButton.scale = Math.Max(4f, sellButton.scale - 0.05f); } } if (moveHomeButton != null) { if (moveHomeButton.containsPoint(x, y)) { moveHomeButton.scale = Math.Min(4.1f, moveHomeButton.scale + 0.05f); hoverText = Game1.content.LoadString("Strings\\UI:AnimalQuery_Move"); } else { moveHomeButton.scale = Math.Max(4f, moveHomeButton.scale - 0.05f); } } if (allowReproductionButton != null) { if (allowReproductionButton.containsPoint(x, y)) { allowReproductionButton.scale = Math.Min(4.1f, allowReproductionButton.scale + 0.05f); hoverText = Game1.content.LoadString("Strings\\UI:AnimalQuery_AllowReproduction"); } else { allowReproductionButton.scale = Math.Max(4f, allowReproductionButton.scale - 0.05f); } } if (yesButton != null) { if (yesButton.containsPoint(x, y)) { yesButton.scale = Math.Min(1.1f, yesButton.scale + 0.05f); } else { yesButton.scale = Math.Max(1f, yesButton.scale - 0.05f); } } if (noButton != null) { if (noButton.containsPoint(x, y)) { noButton.scale = Math.Min(1.1f, noButton.scale + 0.05f); } else { noButton.scale = Math.Max(1f, noButton.scale - 0.05f); } } }
internal void HouseUpgradeAccept(Building cab) { Game1.activeClickableMenu = null; Game1.player.canMove = true; if (cab == null) { Game1.playSound("smallSelect"); return; } if (_config.InstantBuild) { FinalUpgrade(cab); Game1.getCharacterFromName("Robin").setNewDialogue(Game1.content.LoadString("Data\\ExtraDialogue:Robin_HouseUpgrade_Accepted")); Game1.drawDialogue(Game1.getCharacterFromName("Robin")); return; } var cabin = ((Cabin)cab.indoors.Value); switch (cabin.upgradeLevel) { case 0: if (Game1.player.Money >= 10000 && Game1.player.hasItemInInventory(388, 450)) { cab.daysUntilUpgrade.Value = 3; Game1.player.Money -= 10000; Game1.player.removeItemsFromInventory(388, 450); Game1.getCharacterFromName("Robin").setNewDialogue(Game1.content.LoadString("Data\\ExtraDialogue:Robin_HouseUpgrade_Accepted")); Game1.drawDialogue(Game1.getCharacterFromName("Robin")); break; } if (Game1.player.Money < 10000) { Game1.drawObjectDialogue(Game1.content.LoadString("Strings\\UI:NotEnoughMoney3")); break; } Game1.drawObjectDialogue(Game1.content.LoadString("Strings\\Locations:ScienceHouse_Carpenter_NotEnoughWood1")); break; case 1: if (Game1.player.Money >= 50000 && Game1.player.hasItemInInventory(709, 150)) { cab.daysUntilUpgrade.Value = 3; Game1.player.Money -= 50000; Game1.player.removeItemsFromInventory(709, 150); Game1.getCharacterFromName("Robin").setNewDialogue(Game1.content.LoadString("Data\\ExtraDialogue:Robin_HouseUpgrade_Accepted")); Game1.drawDialogue(Game1.getCharacterFromName("Robin")); break; } if (Game1.player.Money < 50000) { Game1.drawObjectDialogue(Game1.content.LoadString("Strings\\UI:NotEnoughMoney3")); break; } Game1.drawObjectDialogue(Game1.content.LoadString("Strings\\Locations:ScienceHouse_Carpenter_NotEnoughWood2")); break; case 2: if (Game1.player.Money >= 100000) { cab.daysUntilUpgrade.Value = 3; Game1.player.Money -= 100000; Game1.getCharacterFromName("Robin").setNewDialogue(Game1.content.LoadString("Data\\ExtraDialogue:Robin_HouseUpgrade_Accepted")); Game1.drawDialogue(Game1.getCharacterFromName("Robin")); break; } if (Game1.player.Money >= 100000) { break; } Game1.drawObjectDialogue(Game1.content.LoadString("Strings\\UI:NotEnoughMoney3")); break; } }
public static void PlayKeyPressSound() { Game1.playSound("bigDeSelect"); }
public static void PlayCountdownSound() { Game1.playSound("throwDownITem"); }
public static void PlayPointWonSound(bool playerWon) { Game1.playSound(playerWon ? "achievement" : "trashcan"); }
public static void PlayBallPaddleSound() { Game1.playSound("smallSelect"); }
/// <summary> /// Draws this item on screen. /// </summary> /// <param name="b">The sprite batch to use</param> /// <param name="slotX">X position of where to draw the item</param> /// <param name="slotY">Y position of where to draw the item</param> public override void draw(SpriteBatch b, int slotX, int slotY) { base.draw(b, slotX, slotY); float scaleSize = 1.5f; for (int i = this.breakableGeodes.Length - 1; i > -1; i--) { int numItems = this.breakableGeodes[i].Item2; int xPos = slotX + this.bounds.X + SPRITE_SIZE * 2 + (int)(SPRITE_SIZE * 1.5 * (i + (4 - this.breakableGeodes.Length))) + 300; int yPos = slotY + this.bounds.Y; b.Draw(Game1.objectSpriteSheet, new Rectangle(xPos, yPos, SPRITE_SIZE, SPRITE_SIZE), new Microsoft.Xna.Framework.Rectangle?(Game1.getSourceRectForStandardTileSheet(Game1.objectSpriteSheet, this.breakableGeodes[i].Item1, 16, 16)), Color.White); } for (int i = 0; i < this.breakableGeodes.Length; i++) { int numItems = this.breakableGeodes[i].Item2; int xPos = slotX + this.bounds.X + SPRITE_SIZE * 2 + (int)(SPRITE_SIZE * 1.5 * (i + (4 - this.breakableGeodes.Length))) + 300; int yPos = slotY + this.bounds.Y; Utility.drawTinyDigits(numItems, b, new Vector2((float)(xPos + Game1.tileSize - Utility.getWidthOfTinyDigitString(numItems, 3f * scaleSize)) + 3f * scaleSize, (float)(yPos + (double)Game1.tileSize - 18.0 * (double)scaleSize + 2.0)), 3f * scaleSize, 1f, Color.White); } }
public override void shedChunks(int number) { Game1.createRadialDebris(Game1.currentLocation, this.sprite.Texture, new Rectangle(0, 128, 16, 16), 8, this.GetBoundingBox().Center.X, this.GetBoundingBox().Center.Y, number, (int)base.getTileLocation().Y, Color.White, (float)Game1.pixelZoom); }
public override void receiveRightClick(int x, int y, bool playSound = true) { Game1.playSound("bigDeSelect"); base.exitThisMenu(true); }
public Billboard(bool dailyQuest = false) : base(0, 0, 0, 0, true) { if (!Game1.player.hasOrWillReceiveMail("checkedBulletinOnce")) { Game1.player.mailReceived.Add("checkedBulletinOnce"); (Game1.getLocationFromName("Town") as Town).checkedBoard(); } this.dailyQuestBoard = dailyQuest; this.billboardTexture = Game1.temporaryContent.Load <Texture2D>("LooseSprites\\Billboard"); this.width = (dailyQuest ? 338 : 301) * Game1.pixelZoom; this.height = 198 * Game1.pixelZoom; Vector2 topLeftPositionForCenteringOnScreen = Utility.getTopLeftPositionForCenteringOnScreen(this.width, this.height, 0, 0); this.xPositionOnScreen = (int)topLeftPositionForCenteringOnScreen.X; this.yPositionOnScreen = (int)topLeftPositionForCenteringOnScreen.Y; this.acceptQuestButton = new ClickableComponent(new Rectangle(this.xPositionOnScreen + this.width / 2 - Game1.tileSize * 2, this.yPositionOnScreen + this.height - Game1.tileSize * 2, (int)Game1.dialogueFont.MeasureString(Game1.content.LoadString("Strings\\UI:AcceptQuest", new object[0])).X + Game1.pixelZoom * 6, (int)Game1.dialogueFont.MeasureString(Game1.content.LoadString("Strings\\UI:AcceptQuest", new object[0])).Y + Game1.pixelZoom * 6), "") { myID = 0 }; this.upperRightCloseButton = new ClickableTextureComponent(new Rectangle(this.xPositionOnScreen + this.width - 5 * Game1.pixelZoom, this.yPositionOnScreen, 12 * Game1.pixelZoom, 12 * Game1.pixelZoom), Game1.mouseCursors, new Rectangle(337, 494, 12, 12), (float)Game1.pixelZoom, false); Game1.playSound("bigSelect"); if (!dailyQuest) { this.calendarDays = new List <ClickableTextureComponent>(); Dictionary <int, NPC> dictionary = new Dictionary <int, NPC>(); foreach (NPC current in Utility.getAllCharacters()) { if (current.birthday_Season != null && current.birthday_Season.Equals(Game1.currentSeason) && !dictionary.ContainsKey(current.birthday_Day) && (Game1.player.friendships.ContainsKey(current.name) || (!current.name.Equals("Dwarf") && !current.name.Equals("Sandy") && !current.name.Equals("Krobus")))) { dictionary.Add(current.birthday_Day, current); } } for (int i = 1; i <= 28; i++) { string text = ""; string text2 = ""; NPC nPC = dictionary.ContainsKey(i) ? dictionary[i] : null; if (Utility.isFestivalDay(i, Game1.currentSeason)) { text = Game1.temporaryContent.Load <Dictionary <string, string> >("Data\\Festivals\\" + Game1.currentSeason + i)["name"]; } else if (nPC != null) { if (nPC.name.Last <char>() == 's' || (LocalizedContentManager.CurrentLanguageCode == LocalizedContentManager.LanguageCode.de && (nPC.name.Last <char>() == 'x' || nPC.name.Last <char>() == 'ß' || nPC.name.Last <char>() == 'z'))) { text2 = Game1.content.LoadString("Strings\\UI:Billboard_SBirthday", new object[] { nPC.displayName }); } else { text2 = Game1.content.LoadString("Strings\\UI:Billboard_Birthday", new object[] { nPC.displayName }); } } this.calendarDays.Add(new ClickableTextureComponent(text, new Rectangle(this.xPositionOnScreen + 38 * Game1.pixelZoom + (i - 1) % 7 * 32 * Game1.pixelZoom, this.yPositionOnScreen + 50 * Game1.pixelZoom + (i - 1) / 7 * 32 * Game1.pixelZoom, 31 * Game1.pixelZoom, 31 * Game1.pixelZoom), text, text2, (nPC != null) ? nPC.sprite.Texture : null, (nPC != null) ? new Rectangle(0, 0, 16, 24) : Rectangle.Empty, 1f, false) { myID = i, rightNeighborID = ((i % 7 != 0) ? (i + 1) : -1), leftNeighborID = ((i % 7 != 1) ? (i - 1) : -1), downNeighborID = i + 7, upNeighborID = ((i > 7) ? (i - 7) : -1) }); } } if (Game1.options.SnappyMenus) { base.populateClickableComponentList(); this.snapToDefaultClickableComponent(); } }
public AnimalQueryMenu(FarmAnimal animal) : base(Game1.viewport.Width / 2 - width / 2, Game1.viewport.Height / 2 - height / 2, width, height) { Game1.player.Halt(); Game1.player.faceGeneralDirection(animal.Position); width = 384; height = 512; this.animal = animal; textBox = new TextBox(null, null, Game1.dialogueFont, Game1.textColor); textBox.X = Game1.viewport.Width / 2 - 128 - 12; textBox.Y = yPositionOnScreen - 4 + 128; textBox.Width = 256; textBox.Height = 192; textBoxCC = new ClickableComponent(new Microsoft.Xna.Framework.Rectangle(textBox.X, textBox.Y, textBox.Width, 64), "") { myID = 110, downNeighborID = 104 }; textBox.Text = animal.displayName; Game1.keyboardDispatcher.Subscriber = textBox; textBox.Selected = false; if ((long)animal.parentId != -1) { FarmAnimal parent = Utility.getAnimal(animal.parentId); if (parent != null) { parentName = parent.displayName; } } if (animal.sound.Value != null && Game1.soundBank != null) { ICue cue = Game1.soundBank.GetCue(animal.sound.Value); cue.SetVariable("Pitch", 1200 + Game1.random.Next(-200, 201)); cue.Play(); } okButton = new ClickableTextureComponent(new Microsoft.Xna.Framework.Rectangle(xPositionOnScreen + width + 4, yPositionOnScreen + height - 64 - IClickableMenu.borderWidth, 64, 64), Game1.mouseCursors, Game1.getSourceRectForStandardTileSheet(Game1.mouseCursors, 46), 1f) { myID = 101, upNeighborID = -99998 }; sellButton = new ClickableTextureComponent(new Microsoft.Xna.Framework.Rectangle(xPositionOnScreen + width + 4, yPositionOnScreen + height - 192 - IClickableMenu.borderWidth, 64, 64), Game1.mouseCursors, new Microsoft.Xna.Framework.Rectangle(0, 384, 16, 16), 4f) { myID = 103, downNeighborID = -99998, upNeighborID = 104 }; moveHomeButton = new ClickableTextureComponent(new Microsoft.Xna.Framework.Rectangle(xPositionOnScreen + width + 4, yPositionOnScreen + height - 256 - IClickableMenu.borderWidth, 64, 64), Game1.mouseCursors, new Microsoft.Xna.Framework.Rectangle(16, 384, 16, 16), 4f) { myID = 104, downNeighborID = 103, upNeighborID = 110 }; if (!animal.isBaby() && !animal.isCoopDweller()) { allowReproductionButton = new ClickableTextureComponent(new Microsoft.Xna.Framework.Rectangle(xPositionOnScreen + width + 16, yPositionOnScreen + height - 128 - IClickableMenu.borderWidth + 8, 36, 36), Game1.mouseCursors, new Microsoft.Xna.Framework.Rectangle(animal.allowReproduction ? 128 : 137, 393, 9, 9), 4f) { myID = 106, downNeighborID = 101, upNeighborID = 103 }; } love = new ClickableTextureComponent(Math.Round((double)(int)animal.friendshipTowardFarmer, 0) / 10.0 + "<", new Microsoft.Xna.Framework.Rectangle(xPositionOnScreen + IClickableMenu.spaceToClearSideBorder + 32 + 16, yPositionOnScreen - 32 + IClickableMenu.spaceToClearTopBorder + 256 - 32, width - 128, 64), null, "Friendship", Game1.mouseCursors, new Microsoft.Xna.Framework.Rectangle(172, 512, 16, 16), 4f) { myID = 102 }; loveHover = new ClickableComponent(new Microsoft.Xna.Framework.Rectangle(xPositionOnScreen + IClickableMenu.spaceToClearSideBorder, yPositionOnScreen + IClickableMenu.spaceToClearTopBorder + 192 - 32, width, 64), "Friendship") { myID = 109 }; fullnessLevel = (float)(int)(byte)animal.fullness / 255f; if (animal.home != null && animal.home.indoors.Value != null) { int piecesHay = animal.home.indoors.Value.numberOfObjectsWithName("Hay"); if (piecesHay > 0) { int numAnimals = (animal.home.indoors.Value as AnimalHouse).animalsThatLiveHere.Count; fullnessLevel = Math.Min(1.0, fullnessLevel + (double)piecesHay / (double)numAnimals); } } else { Utility.fixAllAnimals(); } happinessLevel = (float)(int)(byte)animal.happiness / 255f; loveLevel = (float)(int)animal.friendshipTowardFarmer / 1000f; if (Game1.options.SnappyMenus) { populateClickableComponentList(); snapToDefaultClickableComponent(); } }
public static Farmer GetPlayer() { return(Game1.getFarmer(0)); }
public static void Postfix(StardewValley.Characters.JunimoHarvester __instance, GameTime time, GameLocation location) { Task backgroundTask = Utils.Reflection.GetField<Task>(__instance, "backgroundTask").GetValue(); if ((backgroundTask != null && !backgroundTask.IsCompleted) || !Game1.IsMasterGame) return; if (!Game1.IsMasterGame) return; int harvestTimer = Utils.GetJunimoHarvesterHarvestTimer(__instance).GetValue(); harvestTimer += time.ElapsedGameTime.Milliseconds; if (harvestTimer <= 0) return; int newTimer = harvestTimer - time.ElapsedGameTime.Milliseconds; if (newTimer > 1000) return; if (!(harvestTimer >= 1000 && newTimer < 1000)) return; IReflectedField<Item> flastItemHarvested = Utils.Reflection.GetField<Item>(__instance, "lastItemHarvested"); if (__instance.currentLocation != null && !Utils.Reflection.GetProperty<StardewValley.Buildings.JunimoHut>(__instance, "home").GetValue().noHarvest.Value && Utils.IsAdjacentReadyToHarvestFruitTree(__instance.getTileLocation(), __instance.currentLocation) && (flastItemHarvested.GetValue() == null || flastItemHarvested.GetValue() == lastHarvestedItem)) { Utils.Reflection.GetField<NetEvent1Field<int, NetInt>>(__instance, "netAnimationEvent").GetValue().Fire(5); Utils.TryToActuallyHarvestFruitTree(__instance); Item lastItemHarvested = flastItemHarvested.GetValue(); if (lastItemHarvested != null && __instance.currentLocation.farmers.Any()) { Multiplayer multiplayer = Utils.Reflection.GetField<Multiplayer>(typeof(Game1), "multiplayer").GetValue(); multiplayer.broadcastSprites(__instance.currentLocation, new TemporaryAnimatedSprite( "Maps\\springobjects", Game1.getSourceRectForStandardTileSheet(Game1.objectSpriteSheet, lastItemHarvested.ParentSheetIndex, 16, 16), 1000f, 1, 0, __instance.position + new Vector2(0.0f, -40f), false, false, (float)(__instance.getStandingY() / 10000.0 + 0.00999999977648258), 0.02f, Color.White, 4f, -0.01f, 0.0f, 0.0f, false) { motion = new Vector2(0.08f, -0.25f) }); if (lastItemHarvested is ColoredObject coloredHarvested) multiplayer.broadcastSprites(__instance.currentLocation, new TemporaryAnimatedSprite( "Maps\\springobjects", Game1.getSourceRectForStandardTileSheet(Game1.objectSpriteSheet, lastItemHarvested.ParentSheetIndex + 1, 16, 16), 1000f, 1, 0, __instance.position + new Vector2(0.0f, -40f), false, false, (float)(__instance.getStandingY() / 10000.0 + 0.0149999996647239), 0.02f, coloredHarvested.color.Value, 4f, -0.01f, 0.0f, 0.0f, false) { motion = new Vector2(0.08f, -0.25f) }); } } }
public override void draw(SpriteBatch b) { if (!movingAnimal && !Game1.globalFade) { b.Draw(Game1.fadeToBlackRect, Game1.graphics.GraphicsDevice.Viewport.Bounds, Color.Black * 0.75f); Game1.drawDialogueBox(xPositionOnScreen, yPositionOnScreen + 128, width, height - 128, speaker: false, drawOnlyBox: true); if ((byte)animal.harvestType != 2) { textBox.Draw(b); } int age = ((int)animal.age + 1) / 28 + 1; string ageText = (age <= 1) ? Game1.content.LoadString("Strings\\UI:AnimalQuery_Age1") : Game1.content.LoadString("Strings\\UI:AnimalQuery_AgeN", age); if ((int)animal.age < (byte)animal.ageWhenMature) { ageText += Game1.content.LoadString("Strings\\UI:AnimalQuery_AgeBaby"); } Utility.drawTextWithShadow(b, ageText, Game1.smallFont, new Vector2(xPositionOnScreen + IClickableMenu.spaceToClearSideBorder + 32, yPositionOnScreen + IClickableMenu.spaceToClearTopBorder + 16 + 128), Game1.textColor); int yOffset = 0; if (parentName != null) { yOffset = 21; Utility.drawTextWithShadow(b, Game1.content.LoadString("Strings\\UI:AnimalQuery_Parent", parentName), Game1.smallFont, new Vector2(xPositionOnScreen + IClickableMenu.spaceToClearSideBorder + 32, 32 + yPositionOnScreen + IClickableMenu.spaceToClearTopBorder + 16 + 128), Game1.textColor); } int halfHeart = (int)((loveLevel * 1000.0 % 200.0 >= 100.0) ? (loveLevel * 1000.0 / 200.0) : (-100.0)); for (int i = 0; i < 5; i++) { b.Draw(Game1.mouseCursors, new Vector2(xPositionOnScreen + 96 + 32 * i, yOffset + yPositionOnScreen - 32 + 320), new Microsoft.Xna.Framework.Rectangle(211 + ((loveLevel * 1000.0 <= (double)((i + 1) * 195)) ? 7 : 0), 428, 7, 6), Color.White, 0f, Vector2.Zero, 4f, SpriteEffects.None, 0.89f); if (halfHeart == i) { b.Draw(Game1.mouseCursors, new Vector2(xPositionOnScreen + 96 + 32 * i, yOffset + yPositionOnScreen - 32 + 320), new Microsoft.Xna.Framework.Rectangle(211, 428, 4, 6), Color.White, 0f, Vector2.Zero, 4f, SpriteEffects.None, 0.891f); } } Utility.drawTextWithShadow(b, Game1.parseText(animal.getMoodMessage(), Game1.smallFont, width - IClickableMenu.spaceToClearSideBorder * 2 - 64), Game1.smallFont, new Vector2(xPositionOnScreen + IClickableMenu.spaceToClearSideBorder + 32, yOffset + yPositionOnScreen + 384 - 64 + 4), Game1.textColor); okButton.draw(b); sellButton.draw(b); moveHomeButton.draw(b); if (allowReproductionButton != null) { allowReproductionButton.draw(b); } if (confirmingSell) { b.Draw(Game1.fadeToBlackRect, Game1.graphics.GraphicsDevice.Viewport.Bounds, Color.Black * 0.75f); Game1.drawDialogueBox(Game1.viewport.Width / 2 - 160, Game1.viewport.Height / 2 - 192, 320, 256, speaker: false, drawOnlyBox: true); string confirmText = Game1.content.LoadString("Strings\\UI:AnimalQuery_ConfirmSell"); b.DrawString(Game1.dialogueFont, confirmText, new Vector2((float)(Game1.viewport.Width / 2) - Game1.dialogueFont.MeasureString(confirmText).X / 2f, Game1.viewport.Height / 2 - 96 + 8), Game1.textColor); yesButton.draw(b); noButton.draw(b); } else if (hoverText != null && hoverText.Length > 0) { IClickableMenu.drawHoverText(b, hoverText, Game1.smallFont); } } else if (!Game1.globalFade) { string s = Game1.content.LoadString("Strings\\UI:AnimalQuery_ChooseBuilding", animal.displayHouse, animal.displayType); Game1.drawDialogueBox(32, -64, (int)Game1.dialogueFont.MeasureString(s).X + IClickableMenu.borderWidth * 2 + 16, 128 + IClickableMenu.borderWidth * 2, speaker: false, drawOnlyBox: true); b.DrawString(Game1.dialogueFont, s, new Vector2(32 + IClickableMenu.spaceToClearSideBorder * 2 + 8, 44f), Game1.textColor); okButton.draw(b); } drawMouse(b); }
public MillenniumFalcon(Game1 game) : base(game) { scale = 1 / 1f; vel_max = 100f; acc_max = 10f; }
public RoverMovementCommand(Game1 game) { this.game = game; pressed = false; }
public TextEntryMenu(TextBox target) : base((int)Utility.getTopLeftPositionForCenteringOnScreen(672, 352).X, (int)Utility.getTopLeftPositionForCenteringOnScreen(672, 352).Y, 672, 352) { _target = target; _lettersPerRow = letterMaps[0][0].Length; for (int i = 0; i < letterMaps[0].Length; i++) { for (int j = 0; j < _lettersPerRow; j++) { ClickableTextureComponent key_component = new ClickableTextureComponent(new Rectangle(0, 0, 1024, 1024), Game1.mouseCursors2, new Rectangle(32, 176, 16, 16), 4f) { myID = i * _lettersPerRow + j, leftNeighborID = -99998, rightNeighborID = -99998, upNeighborID = -99998, downNeighborID = -99998 }; if (i == letterMaps[0].Length - 1) { if (j >= 2 && j <= _lettersPerRow - 4) { key_component.downNeighborID = 99991; key_component.downNeighborImmutable = true; } if (j >= _lettersPerRow - 3 && j <= _lettersPerRow - 2) { key_component.downNeighborID = 99990; key_component.downNeighborImmutable = true; } } keys.Add(key_component); } } backspaceButton = new ClickableTextureComponent(new Rectangle(0, 0, 128, 64), Game1.mouseCursors2, new Rectangle(32, 144, 32, 16), 4f) { myID = 99990, leftNeighborID = -99998, rightNeighborID = -99998, upNeighborID = -99998, downNeighborID = -99998 }; spaceButton = new ClickableTextureComponent(new Rectangle(0, 0, 320, 64), Game1.mouseCursors2, new Rectangle(0, 160, 80, 16), 4f) { myID = 99991, leftNeighborID = -99998, rightNeighborID = -99998, upNeighborID = -99998, downNeighborID = -99998 }; okButton = new ClickableTextureComponent(new Rectangle(0, 0, 64, 64), Game1.mouseCursors2, new Rectangle(64, 144, 16, 16), 4f) { myID = 99992, leftNeighborID = -99998, rightNeighborID = -99998, upNeighborID = -99998, downNeighborID = -99998 }; upperCaseButton = new ClickableTextureComponent(new Rectangle(0, 0, 64, 64), Game1.mouseCursors2, new Rectangle(0, 144, 16, 16), 4f) { myID = 99993, leftNeighborID = -99998, rightNeighborID = -99998, upNeighborID = -99998, downNeighborID = -99998 }; symbolsButton = new ClickableTextureComponent(new Rectangle(0, 0, 64, 64), Game1.mouseCursors2, new Rectangle(16, 144, 16, 16), 4f) { myID = 99994, leftNeighborID = -99998, rightNeighborID = -99998, upNeighborID = -99998, downNeighborID = -99998 }; ShowKeyboard(0, play_sound: false); RepositionElements(); populateClickableComponentList(); if (Game1.options.SnappyMenus) { snapToDefaultClickableComponent(); } Game1.playSound("bigSelect"); }
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((x + Game1.viewport.X) / 64, (y + Game1.viewport.Y) / 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; 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.viewport.Width / 2 - 64 - 4, Game1.viewport.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.viewport.Width / 2 + 4, Game1.viewport.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(); }
public void checkFarmhandRequest(string userID, string connectionID, NetFarmerRoot farmer, Action <OutgoingMessage> sendMessage, Action approve) { if (farmer.Value == null) { rejectFarmhandRequest(userID, farmer, sendMessage); return; } long id = farmer.Value.UniqueMultiplayerID; Action check = delegate { if (_pendingFarmhandSelections.ContainsKey(connectionID)) { _pendingFarmhandSelections.Remove(connectionID); } Farmer farmer2 = findOriginalFarmhand(farmer.Value); if (!isConnectionActive(connectionID)) { Console.WriteLine("Rejected request for connection ID " + connectionID + ": Connection not active."); } else if (farmer2 == null) { Console.WriteLine("Rejected request for farmhand " + id + ": doesn't exist"); rejectFarmhandRequest(userID, farmer, sendMessage); } else if (!authCheck(userID, farmer2)) { Console.WriteLine("Rejected request for farmhand " + id + ": authorization failure"); rejectFarmhandRequest(userID, farmer, sendMessage); } else if ((Game1.otherFarmers.ContainsKey(id) && !Game1.multiplayer.isDisconnecting(id)) || Game1.serverHost.Value.UniqueMultiplayerID == id) { Console.WriteLine("Rejected request for farmhand " + id + ": already in use"); rejectFarmhandRequest(userID, farmer, sendMessage); } else if (findCabin(farmer.Value).isInventoryOpen()) { Console.WriteLine("Rejected request for farmhand " + id + ": inventory in use"); rejectFarmhandRequest(userID, farmer, sendMessage); } else { Console.WriteLine("Approved request for farmhand " + id); approve(); Game1.updateCellarAssignments(); Game1.multiplayer.addPlayer(farmer); Game1.multiplayer.broadcastPlayerIntroduction(farmer); sendLocation(id, Game1.getFarm()); sendLocation(id, Game1.getLocationFromName("FarmHouse")); sendLocation(id, Game1.getLocationFromName("Greenhouse")); if (farmer.Value.lastSleepLocation != null) { GameLocation locationFromName = Game1.getLocationFromName(farmer.Value.lastSleepLocation); if (locationFromName != null && Game1.isLocationAccessible(locationFromName.Name) && !Game1.multiplayer.isAlwaysActiveLocation(locationFromName)) { sendLocation(id, locationFromName, force_current: true); } } sendServerIntroduction(id); updateLobbyData(); } }; if (!whenGameAvailable(check)) { _pendingFarmhandSelections[connectionID] = check; Console.WriteLine("Postponing request for farmhand " + id + " from connection: " + connectionID); sendMessage(new OutgoingMessage(11, Game1.player, "Strings\\UI:Client_WaitForHostAvailability")); } }
public void ProcessFileForCleanUp(string path, List <Item> thingsToAddBackIn) { string[] ehh = File.ReadAllLines(path); string data = ehh[0]; Item cObj; string a; string[] b; string s = ""; // Log.AsyncC(path); // Log.AsyncC(data); try { dynamic obj = JObject.Parse(data); // Log.AsyncC(obj.thisType); a = obj.serializationName; b = a.Split(','); s = b.ElementAt(0); // Log.AsyncC(s); } catch (Exception e) { //USE XML STYLE DESERIALIZING foreach (KeyValuePair <string, SerializerDataNode> pair in acceptedTypes) { var word = ParseXMLType(path); if (pair.Key == word.ToString()) { cObj = pair.Value.parse.Invoke(path); (cObj as CoreObject).thisLocation = Game1.getLocationFromName((cObj as CoreObject).locationsName); (cObj as CoreObject).resetTexture(); if ((cObj as CoreObject).thisLocation == null) { Game1.player.addItemToInventory(cObj); return; } else { (cObj as CoreObject).thisLocation.objects.Add((cObj as CoreObject).tileLocation, (StardewValley.Object)cObj); thingsToAddBackIn.Add(cObj); //Util.placementAction(cObj, cObj.thisLocation,(int)cObj.tileLocation.X,(int) cObj.tileLocation.Y,null,false); } } } // Log.AsyncG("attempting to parse from path and value of s is " + s); } // var cObj = parseBagOfHolding(path); //pair.Value.parse.Invoke(path); // cObj.TextureSheet = Game1.content.Load<Texture2D>(Path.Combine("Revitalize", "CropsNSeeds", "Graphics", "seeds")); /* * cObj.thisLocation = Game1.getLocationFromName(cObj.locationsName); * if (cObj.thisLocation == null) * { * Game1.player.addItemToInventory(cObj); * return; * } * else * { * cObj.thisLocation.objects.Add(cObj.tileLocation, cObj); * Lists.trackedObjectList.Add(cObj); * //Util.placementAction(cObj, cObj.thisLocation,(int)cObj.tileLocation.X,(int) cObj.tileLocation.Y,null,false); * } */ //USE JSON STYLE DESERIALIZNG if (acceptedTypes.ContainsKey(s)) { // Log.AsyncC("FUUUUU"); foreach (KeyValuePair <string, SerializerDataNode> pair in acceptedTypes) { if (pair.Key == s) { try { //parse from Json Style cObj = (CoreObject)pair.Value.parse.Invoke(data); (cObj as CoreObject).thisLocation = Game1.getLocationFromName((cObj as CoreObject).locationsName); if ((cObj as CoreObject).thisLocation == null) { Game1.player.addItemToInventory(cObj); return; } else { (cObj as CoreObject).thisLocation.objects.Add((cObj as CoreObject).tileLocation, (StardewValley.Object)cObj); thingsToAddBackIn.Add(cObj); //Util.placementAction(cObj, cObj.thisLocation,(int)cObj.tileLocation.X,(int) cObj.tileLocation.Y,null,false); } } catch (Exception e) { } } } } }
public override void receiveKeyPress(Keys key) { base.receiveKeyPress(key); if (Game1.isAnyGamePadButtonBeingPressed() && Game1.options.doesInputListContain(Game1.options.menuButton, key) && this.heldItem != null) { Game1.setMousePosition(this.trashCan.bounds.Center); } if (key.Equals(Keys.Delete) && this.heldItem != null && this.heldItem.canBeTrashed()) { if (this.heldItem is StardewValley.Object && Game1.player.specialItems.Contains((this.heldItem as StardewValley.Object).parentSheetIndex)) { Game1.player.specialItems.Remove((this.heldItem as StardewValley.Object).parentSheetIndex); } this.heldItem = null; Game1.playSound("trashcan"); } if (Game1.options.doesInputListContain(Game1.options.inventorySlot1, key)) { Game1.player.CurrentToolIndex = 0; Game1.playSound("toolSwap"); return; } if (Game1.options.doesInputListContain(Game1.options.inventorySlot2, key)) { Game1.player.CurrentToolIndex = 1; Game1.playSound("toolSwap"); return; } if (Game1.options.doesInputListContain(Game1.options.inventorySlot3, key)) { Game1.player.CurrentToolIndex = 2; Game1.playSound("toolSwap"); return; } if (Game1.options.doesInputListContain(Game1.options.inventorySlot4, key)) { Game1.player.CurrentToolIndex = 3; Game1.playSound("toolSwap"); return; } if (Game1.options.doesInputListContain(Game1.options.inventorySlot5, key)) { Game1.player.CurrentToolIndex = 4; Game1.playSound("toolSwap"); return; } if (Game1.options.doesInputListContain(Game1.options.inventorySlot6, key)) { Game1.player.CurrentToolIndex = 5; Game1.playSound("toolSwap"); return; } if (Game1.options.doesInputListContain(Game1.options.inventorySlot7, key)) { Game1.player.CurrentToolIndex = 6; Game1.playSound("toolSwap"); return; } if (Game1.options.doesInputListContain(Game1.options.inventorySlot8, key)) { Game1.player.CurrentToolIndex = 7; Game1.playSound("toolSwap"); return; } if (Game1.options.doesInputListContain(Game1.options.inventorySlot9, key)) { Game1.player.CurrentToolIndex = 8; Game1.playSound("toolSwap"); return; } if (Game1.options.doesInputListContain(Game1.options.inventorySlot10, key)) { Game1.player.CurrentToolIndex = 9; Game1.playSound("toolSwap"); return; } if (Game1.options.doesInputListContain(Game1.options.inventorySlot11, key)) { Game1.player.CurrentToolIndex = 10; Game1.playSound("toolSwap"); return; } if (Game1.options.doesInputListContain(Game1.options.inventorySlot12, key)) { Game1.player.CurrentToolIndex = 11; Game1.playSound("toolSwap"); } }
public void Close() { Game1.playSound("bigDeSelect"); Game1.closeTextEntry(); }
public override void performHoverAction(int x, int y) { this.descriptionText = ""; this.descriptionTitle = ""; this.hoveredItem = this.inventory.hover(x, y, this.heldItem); this.hoverText = this.inventory.hoverText; this.hoverTitle = this.inventory.hoverTitle; foreach (ClickableComponent current in this.equipmentIcons) { if (current.containsPoint(x, y)) { string name = current.name; if (!(name == "Hat")) { if (!(name == "Right Ring")) { if (!(name == "Left Ring")) { if (name == "Boots") { if (Game1.player.boots != null) { this.hoveredItem = Game1.player.boots; this.hoverText = Game1.player.boots.getDescription(); this.hoverTitle = Game1.player.boots.name; } } } else if (Game1.player.leftRing != null) { this.hoveredItem = Game1.player.leftRing; this.hoverText = Game1.player.leftRing.getDescription(); this.hoverTitle = Game1.player.leftRing.name; } } else if (Game1.player.rightRing != null) { this.hoveredItem = Game1.player.rightRing; this.hoverText = Game1.player.rightRing.getDescription(); this.hoverTitle = Game1.player.rightRing.name; } } else if (Game1.player.hat != null) { this.hoveredItem = Game1.player.hat; this.hoverText = Game1.player.hat.getDescription(); this.hoverTitle = Game1.player.hat.name; } current.scale = Math.Min(current.scale + 0.05f, 1.1f); } current.scale = Math.Max(1f, current.scale - 0.025f); } if (this.portrait.containsPoint(x, y)) { this.portrait.scale += 0.2f; this.hoverText = Game1.content.LoadString("Strings\\UI:Inventory_PortraitHover_Level", new object[] { Game1.player.Level }) + Environment.NewLine + Game1.player.getTitle(); } else { this.portrait.scale = 0f; } if (this.trashCan.containsPoint(x, y)) { if (this.trashCanLidRotation <= 0f) { Game1.playSound("trashcanlid"); } this.trashCanLidRotation = Math.Min(this.trashCanLidRotation + 0.06544985f, 1.57079637f); } else if (this.trashCanLidRotation != 0f) { this.trashCanLidRotation = Math.Max(this.trashCanLidRotation - 0.1308997f, 0f); if (this.trashCanLidRotation == 0f) { Game1.playSound("thudStep"); } } if (this.organizeButton != null) { this.organizeButton.tryHover(x, y, 0.1f); if (this.organizeButton.containsPoint(x, y)) { this.hoverText = this.organizeButton.hoverText; } } }
public FrameRateCounter(Game game) : base(game) { GameRef = (Game1)game; DrawOrder = int.MaxValue; //always on top }
public new void moveCursorInDirection(int direction) { int num = 0; base.moveCursorInDirection(direction); return; if (this.currentRegion == 0) { //int num = this.inventory.moveCursorInDirection(direction); if (num == 0) { return; } if (num == 2) { this.currentRegion = 1; this.equipmentIcons[0].snapMouseCursor(); } } else if (this.currentRegion == 1) { if (direction == 0) { this.currentRegion = 0; ClickableComponent lastClickableComponentInThisListThatContainsThisXCoord = base.getLastClickableComponentInThisListThatContainsThisXCoord(this.inventory.inventory, Game1.getMousePosition().X); if (lastClickableComponentInThisListThatContainsThisXCoord != null) { lastClickableComponentInThisListThatContainsThisXCoord.snapMouseCursor(); } } else if (direction == 2) { this.currentRegion = 2; this.equipmentIcons[1].snapMouseCursor(); } } else if (this.currentRegion == 2) { if (direction == 0) { this.currentRegion = 1; this.equipmentIcons[0].snapMouseCursor(); } else if (direction == 2) { this.currentRegion = 3; this.equipmentIcons[2].snapMouseCursor(); } } else if (this.currentRegion == 3) { if (direction == 0) { this.currentRegion = 2; this.equipmentIcons[1].snapMouseCursor(); } else if (direction == 2) { this.currentRegion = 4; this.equipmentIcons[3].snapMouseCursor(); } } else if (this.currentRegion == 4 && direction == 0) { this.currentRegion = 3; this.equipmentIcons[2].snapMouseCursor(); } return; }
public override void draw(SpriteBatch b) { base.drawHorizontalPartition(b, this.yPositionOnScreen + IClickableMenu.borderWidth + IClickableMenu.spaceToClearTopBorder + 3 * Game1.tileSize, false); this.inventory.draw(b); foreach (ClickableComponent current in this.equipmentIcons) { string name = current.name; if (!(name == "Hat")) { if (!(name == "Right Ring")) { if (!(name == "Left Ring")) { if (name == "Boots") { if (Game1.player.boots != null) { b.Draw(Game1.menuTexture, current.bounds, new Rectangle?(Game1.getSourceRectForStandardTileSheet(Game1.menuTexture, 10, -1, -1)), Color.White); Game1.player.boots.drawInMenu(b, new Vector2((float)current.bounds.X, (float)current.bounds.Y), current.scale); } else { b.Draw(Game1.menuTexture, current.bounds, new Rectangle?(Game1.getSourceRectForStandardTileSheet(Game1.menuTexture, 40, -1, -1)), Color.White); } } } else if (Game1.player.leftRing != null) { b.Draw(Game1.menuTexture, current.bounds, new Rectangle?(Game1.getSourceRectForStandardTileSheet(Game1.menuTexture, 10, -1, -1)), Color.White); Game1.player.leftRing.drawInMenu(b, new Vector2((float)current.bounds.X, (float)current.bounds.Y), current.scale); } else { b.Draw(Game1.menuTexture, current.bounds, new Rectangle?(Game1.getSourceRectForStandardTileSheet(Game1.menuTexture, 41, -1, -1)), Color.White); } } else if (Game1.player.rightRing != null) { b.Draw(Game1.menuTexture, current.bounds, new Rectangle?(Game1.getSourceRectForStandardTileSheet(Game1.menuTexture, 10, -1, -1)), Color.White); Game1.player.rightRing.drawInMenu(b, new Vector2((float)current.bounds.X, (float)current.bounds.Y), current.scale); } else { b.Draw(Game1.menuTexture, current.bounds, new Rectangle?(Game1.getSourceRectForStandardTileSheet(Game1.menuTexture, 41, -1, -1)), Color.White); } } else if (Game1.player.hat != null) { b.Draw(Game1.menuTexture, current.bounds, new Rectangle?(Game1.getSourceRectForStandardTileSheet(Game1.menuTexture, 10, -1, -1)), Color.White); Game1.player.hat.drawInMenu(b, new Vector2((float)current.bounds.X, (float)current.bounds.Y), current.scale, 1f, 0.866f, false); } else { b.Draw(Game1.menuTexture, current.bounds, new Rectangle?(Game1.getSourceRectForStandardTileSheet(Game1.menuTexture, 42, -1, -1)), Color.White); } } b.Draw((Game1.timeOfDay >= 1900) ? Game1.nightbg : Game1.daybg, new Vector2((float)(this.xPositionOnScreen + Game1.tileSize * 3 - Game1.tileSize), (float)(this.yPositionOnScreen + IClickableMenu.borderWidth + IClickableMenu.spaceToClearTopBorder + 4 * Game1.tileSize - 8)), Color.White); Game1.player.FarmerRenderer.draw(b, new FarmerSprite.AnimationFrame(0, Game1.player.bathingClothes ? 108 : 0, false, false, null, false), Game1.player.bathingClothes ? 108 : 0, new Rectangle(0, Game1.player.bathingClothes ? 576 : 0, 16, 32), new Vector2((float)(this.xPositionOnScreen + Game1.tileSize * 3 - Game1.tileSize / 2), (float)(this.yPositionOnScreen + IClickableMenu.borderWidth + IClickableMenu.spaceToClearTopBorder + 5 * Game1.tileSize - Game1.tileSize / 2)), Vector2.Zero, 0.8f, 2, Color.White, 0f, 1f, Game1.player); if (Game1.timeOfDay >= 1900) { Game1.player.FarmerRenderer.draw(b, new FarmerSprite.AnimationFrame(0, 0, false, false, null, false), 0, new Rectangle(0, 0, 16, 32), new Vector2((float)(this.xPositionOnScreen + Game1.tileSize * 3 - Game1.tileSize / 2), (float)(this.yPositionOnScreen + IClickableMenu.borderWidth + IClickableMenu.spaceToClearTopBorder + 5 * Game1.tileSize - Game1.tileSize / 2)), Vector2.Zero, 0.8f, 2, Color.DarkBlue * 0.3f, 0f, 1f, Game1.player); } Utility.drawTextWithShadow(b, Game1.player.name, Game1.dialogueFont, new Vector2((float)(this.xPositionOnScreen + Game1.tileSize * 3) - Math.Min((float)Game1.tileSize, Game1.dialogueFont.MeasureString(Game1.player.name).X / 2f), (float)(this.yPositionOnScreen + IClickableMenu.borderWidth + IClickableMenu.spaceToClearTopBorder + 7 * Game1.tileSize + Game1.pixelZoom * 2)), Game1.textColor, 1f, -1f, -1, -1, 1f, 3); string text = Game1.content.LoadString("Strings\\UI:Inventory_FarmName", new object[] { Game1.player.farmName }); Utility.drawTextWithShadow(b, text, Game1.dialogueFont, new Vector2((float)(this.xPositionOnScreen + Game1.tileSize * 8 + Game1.tileSize / 2) - Game1.dialogueFont.MeasureString(text).X / 2f, (float)(this.yPositionOnScreen + IClickableMenu.borderWidth + IClickableMenu.spaceToClearTopBorder + 4 * Game1.tileSize + Game1.pixelZoom)), Game1.textColor, 1f, -1f, -1, -1, 1f, 3); string text2 = Game1.content.LoadString("Strings\\UI:Inventory_CurrentFunds", new object[] { Utility.getNumberWithCommas(Game1.player.Money) }); Utility.drawTextWithShadow(b, text2, Game1.dialogueFont, new Vector2((float)(this.xPositionOnScreen + Game1.tileSize * 8 + Game1.tileSize / 2) - Game1.dialogueFont.MeasureString(text2).X / 2f, (float)(this.yPositionOnScreen + IClickableMenu.borderWidth + IClickableMenu.spaceToClearTopBorder + 5 * Game1.tileSize)), Game1.textColor, 1f, -1f, -1, -1, 1f, 3); string text3 = Game1.content.LoadString("Strings\\UI:Inventory_TotalEarnings", new object[] { Utility.getNumberWithCommas((int)Game1.player.totalMoneyEarned) }); Utility.drawTextWithShadow(b, text3, Game1.dialogueFont, new Vector2((float)(this.xPositionOnScreen + Game1.tileSize * 8 + Game1.tileSize / 2) - Game1.dialogueFont.MeasureString(text3).X / 2f, (float)(this.yPositionOnScreen + IClickableMenu.borderWidth + IClickableMenu.spaceToClearTopBorder + 6 * Game1.tileSize - Game1.pixelZoom)), Game1.textColor, 1f, -1f, -1, -1, 1f, 3); if (Game1.player != null) { if (Game1.player.hasPet()) { string petName = Game1.player.getPetName(); Utility.drawTextWithShadow(b, petName, Game1.dialogueFont, new Vector2((float)(this.xPositionOnScreen + Game1.tileSize * 5) + Math.Max((float)Game1.tileSize, Game1.dialogueFont.MeasureString(Game1.player.name).X / 2f), (float)(this.yPositionOnScreen + IClickableMenu.borderWidth + IClickableMenu.spaceToClearTopBorder + 7 * Game1.tileSize + Game1.pixelZoom * 2)), Game1.textColor, 1f, -1f, -1, -1, 1f, 3); Utility.drawWithShadow(b, Game1.mouseCursors, new Vector2((float)(this.xPositionOnScreen + Game1.tileSize * 4) + Math.Max((float)Game1.tileSize, Game1.dialogueFont.MeasureString(Game1.player.name).X / 2f), (float)(this.yPositionOnScreen + IClickableMenu.borderWidth + IClickableMenu.spaceToClearTopBorder + 7 * Game1.tileSize - Game1.pixelZoom)), new Rectangle(160 + (Game1.player.catPerson ? 0 : 16), 192, 16, 16), Color.White, 0f, Vector2.Zero, (float)Game1.pixelZoom, false, -1f, -1, -1, 0.35f); } } if (this.horseName.Length > 0) { Utility.drawTextWithShadow(b, this.horseName, Game1.dialogueFont, new Vector2((float)(this.xPositionOnScreen + Game1.tileSize * 6) + Math.Max((float)Game1.tileSize, Game1.dialogueFont.MeasureString(Game1.player.name).X / 2f) + ((Game1.player.getPetName() != null) ? Math.Max((float)Game1.tileSize, Game1.dialogueFont.MeasureString(Game1.player.getPetName()).X) : 0f), (float)(this.yPositionOnScreen + IClickableMenu.borderWidth + IClickableMenu.spaceToClearTopBorder + 7 * Game1.tileSize + Game1.pixelZoom * 2)), Game1.textColor, 1f, -1f, -1, -1, 1f, 3); Utility.drawWithShadow(b, Game1.mouseCursors, new Vector2((float)(this.xPositionOnScreen + Game1.tileSize * 5 + Game1.pixelZoom * 2) + Math.Max((float)Game1.tileSize, Game1.dialogueFont.MeasureString(Game1.player.name).X / 2f) + ((Game1.player.getPetName() != null) ? Math.Max((float)Game1.tileSize, Game1.dialogueFont.MeasureString(Game1.player.getPetName()).X) : 0f), (float)(this.yPositionOnScreen + IClickableMenu.borderWidth + IClickableMenu.spaceToClearTopBorder + 7 * Game1.tileSize - Game1.pixelZoom)), new Rectangle(193, 192, 16, 16), Color.White, 0f, Vector2.Zero, (float)Game1.pixelZoom, false, -1f, -1, -1, 0.35f); } int arg_A52_0 = this.xPositionOnScreen; int arg_A5B_0 = this.width / 3; int arg_A61_0 = Game1.tileSize; int arg_A67_0 = Game1.tileSize; if (this.organizeButton != null) { this.organizeButton.draw(b); } this.trashCan.draw(b); b.Draw(Game1.mouseCursors, new Vector2((float)(this.trashCan.bounds.X + 60), (float)(this.trashCan.bounds.Y + 40)), new Rectangle?(new Rectangle(686, 256, 18, 10)), Color.White, this.trashCanLidRotation, new Vector2(16f, 10f), (float)Game1.pixelZoom, SpriteEffects.None, 0.86f); if (this.heldItem != null) { this.heldItem.drawInMenu(b, new Vector2((float)(Game1.getOldMouseX() + 16), (float)(Game1.getOldMouseY() + 16)), 1f); } if (this.hoverText != null && !this.hoverText.Equals("")) { IClickableMenu.drawToolTip(b, this.hoverText, this.hoverTitle, this.hoveredItem, this.heldItem != null, -1, 0, -1, -1, null, -1); } }
public Spaceship(Game1 game) : base(game) { bullets = new BulletManager(game, this); }
public override void receiveLeftClick(int x, int y, bool playSound = true) { foreach (ClickableComponent current in this.equipmentIcons) { if (current.containsPoint(x, y)) { bool flag = this.heldItem == null; string name = current.name; if (!(name == "Hat")) { if (!(name == "Left Ring")) { if (!(name == "Right Ring")) { if (name == "Boots") { if (this.heldItem == null || this.heldItem is Boots) { Boots boots = (Boots)this.heldItem; this.heldItem = Game1.player.boots; Game1.player.boots = boots; if (this.heldItem != null) { (this.heldItem as Boots).onUnequip(); } if (Game1.player.boots != null) { Game1.player.boots.onEquip(); } if (this.heldItem == null) { Game1.playSound("sandyStep"); DelayedAction.playSoundAfterDelay("sandyStep", 150); } else { Game1.playSound("dwop"); } } } } else if (this.heldItem == null || this.heldItem is Ring) { Ring rightRing = (Ring)this.heldItem; this.heldItem = Game1.player.rightRing; Game1.player.rightRing = rightRing; if (this.heldItem != null) { (this.heldItem as Ring).onUnequip(Game1.player); } if (Game1.player.rightRing != null) { Game1.player.rightRing.onEquip(Game1.player); } if (this.heldItem == null) { Game1.playSound("crit"); } else { Game1.playSound("dwop"); } } } else if (this.heldItem == null || this.heldItem is Ring) { Ring leftRing = (Ring)this.heldItem; this.heldItem = Game1.player.leftRing; Game1.player.leftRing = leftRing; if (this.heldItem != null) { (this.heldItem as Ring).onUnequip(Game1.player); } if (Game1.player.leftRing != null) { Game1.player.leftRing.onEquip(Game1.player); } if (this.heldItem == null) { Game1.playSound("crit"); } else { Game1.playSound("dwop"); } } } else if (this.heldItem == null || this.heldItem is Hat) { Hat hat = (Hat)this.heldItem; this.heldItem = Game1.player.hat; Game1.player.hat = hat; if (this.heldItem == null) { Game1.playSound("grassyStep"); } else { Game1.playSound("dwop"); } } if (flag && this.heldItem != null && Game1.oldKBState.IsKeyDown(Keys.LeftShift)) { for (int i = 0; i < Game1.player.items.Count; i++) { if (Game1.player.items[i] == null || Game1.player.items[i].canStackWith(this.heldItem)) { if (Game1.player.CurrentToolIndex == i && this.heldItem != null) { this.heldItem.actionWhenBeingHeld(Game1.player); } this.heldItem = Utility.addItemToInventory(this.heldItem, i, this.inventory.actualInventory, null); if (Game1.player.CurrentToolIndex == i && this.heldItem != null) { this.heldItem.actionWhenStopBeingHeld(Game1.player); } Game1.playSound("stoneStep"); return; } } } } } this.heldItem = this.inventory.leftClick(x, y, this.heldItem, !Game1.oldKBState.IsKeyDown(Keys.LeftShift)); if (this.heldItem != null && this.heldItem is StardewValley.Object && (this.heldItem as StardewValley.Object).ParentSheetIndex == 434) { Game1.playSound("smallSelect"); Game1.playerEatObject(this.heldItem as StardewValley.Object, true); this.heldItem = null; Game1.exitActiveMenu(); } else if (this.heldItem != null && Game1.oldKBState.IsKeyDown(Keys.LeftShift)) { if (this.heldItem is Ring) { if (Game1.player.leftRing == null) { Game1.player.leftRing = (this.heldItem as Ring); (this.heldItem as Ring).onEquip(Game1.player); this.heldItem = null; Game1.playSound("crit"); return; } if (Game1.player.rightRing == null) { Game1.player.rightRing = (this.heldItem as Ring); (this.heldItem as Ring).onEquip(Game1.player); this.heldItem = null; Game1.playSound("crit"); return; } } else if (this.heldItem is Hat) { if (Game1.player.hat == null) { Game1.player.hat = (this.heldItem as Hat); Game1.playSound("grassyStep"); this.heldItem = null; return; } } else if (this.heldItem is Boots && Game1.player.boots == null) { Game1.player.boots = (this.heldItem as Boots); (this.heldItem as Boots).onEquip(); Game1.playSound("sandyStep"); DelayedAction.playSoundAfterDelay("sandyStep", 150); this.heldItem = null; return; } if (this.inventory.getInventoryPositionOfClick(x, y) >= 12) { for (int j = 0; j < 12; j++) { if (Game1.player.items[j] == null || Game1.player.items[j].canStackWith(this.heldItem)) { if (Game1.player.CurrentToolIndex == j && this.heldItem != null) { this.heldItem.actionWhenBeingHeld(Game1.player); } this.heldItem = Utility.addItemToInventory(this.heldItem, j, this.inventory.actualInventory, null); if (this.heldItem != null) { this.heldItem.actionWhenStopBeingHeld(Game1.player); } Game1.playSound("stoneStep"); return; } } } } if (this.portrait.containsPoint(x, y)) { this.portrait.name = (this.portrait.name.Equals("32") ? "8" : "32"); } if (this.heldItem != null && this.trashCan.containsPoint(x, y) && this.heldItem.canBeTrashed()) { if (this.heldItem is StardewValley.Object && Game1.player.specialItems.Contains((this.heldItem as StardewValley.Object).parentSheetIndex)) { Game1.player.specialItems.Remove((this.heldItem as StardewValley.Object).parentSheetIndex); } this.heldItem = null; Game1.playSound("trashcan"); } else if (this.heldItem != null && !this.isWithinBounds(x, y) && this.heldItem.canBeTrashed()) { Game1.playSound("throwDownITem"); Game1.createItemDebris(this.heldItem, Game1.player.getStandingPosition(), Game1.player.FacingDirection); this.heldItem = null; } if (this.organizeButton != null && this.organizeButton.containsPoint(x, y)) { ItemGrabMenu.organizeItemsInList(Game1.player.items); Game1.playSound("Ship"); } }
public static void OpenTravelingCatalogue() { if (Config.LimitTravelingCatalogToInTown && Game1.getLocationFromName("Forest") != null && !(Game1.getLocationFromName("Forest") as Forest).travelingMerchantDay) { Game1.activeClickableMenu = new DialogueBox(Helper.Translation.Get("traveling-merchant-not-here")); return; } var dict = Utility.getTravelingMerchantStock((int)(Game1.uniqueIDForThisGame + (ulong)Game1.stats.DaysPlayed)); AdjustPrices(ref dict, Config.FreeTravelingCatalogue); Monitor.Log("Opening traveling catalogue"); DelayedOpen(new ShopMenu(dict, 0, "Traveler", new Func <ISalable, Farmer, int, bool>(Utility.onTravelingMerchantShopPurchase), null, null)); }
public XWing(Game1 game) : base(game) { scale = 1 / 1f; vel_max = 100f; acc_max = 10f; }