Пример #1
0
        public void ProcessAndRender()
        {
            var        farmers = SGame.getAllFarmers();
            Friendship friendship;
            int        counter = 0;

            ToGoWidth  = 0;
            NameWidth  = 0;
            NameLength = 0;
            MaxName    = "";
            for (int i = 0; i < 6; i++)
            {
                Stats[i] = null;
            }

            foreach (NPC npc in GetDatables(Config.datableType))
            {
                foreach (SFarmer farmer in farmers)
                {
                    if (!farmer.friendshipData.ContainsKey(npc.getName()))
                    {
                        continue;
                    }

                    friendship     = farmer.friendshipData[npc.getName()];
                    Stats[counter] = new FriendshipStats(farmer, npc, friendship, Config.datableType);
                    if (SGame.smallFont.MeasureString(Stats[counter].Level.ToString()).X > ToGoWidth)
                    {
                        ToGoWidth = (int)SGame.smallFont.MeasureString(Stats[counter].Level.ToString()).X;
                    }
                    if ((int)SGame.smallFont.MeasureString(Stats[counter].Name).X > NameWidth)
                    {
                        NameWidth = (int)SGame.smallFont.MeasureString(Stats[counter].Name).X;
                    }
                    if (Stats[counter].Name.Length > NameLength)
                    {
                        NameLength = Stats[counter].Name.Length;
                        MaxName    = Stats[counter].Name;
                    }
                    counter++;
                }
            }

            GraphicsEvents.OnPostRenderHudEvent += this.GraphicsEvents_OnPostRenderHudEvent;
        }
Пример #2
0
 // Allow torches to be removed from scarecrows and sprinklers with them in
 public static bool pressUseToolButton_Prefix(StardewValley.Game1 __instance, ref bool __result)
 {
     if (Game1.player.CurrentTool == null && Game1.player.ActiveObject != null && Game1.player.ActiveObject.Name == "Torch")
     {
         Vector2 c = Game1.player.GetToolLocation() / 64f;
         c.X = (int)c.X;
         c.Y = (int)c.Y;
         if (Game1.currentLocation.Objects.ContainsKey(c))
         {
             StardewValley.Object o = Game1.currentLocation.Objects[c];
             if (o.lightSource == null && (o.Name.Contains("arecrow") || o.IsSprinkler()))
             {
                 // If config options are disabled then skip
                 if (o.Name.Contains("arecrow") && !ModEntry.config_.place_torches_in_scarecrows)
                 {
                     Monitor.Log($"Skipping adding light to {Game1.currentLocation.Name}: {c.X}, {c.Y} as it's a scarecrow and the config option 'place_torches_in_scarecrows' is disabled", LogLevel.Trace);
                     return(true);
                 }
                 else if (o.IsSprinkler() && !ModEntry.config_.place_torches_in_sprinklers)
                 {
                     Monitor.Log($"Skipping adding light to {Game1.currentLocation.Name}: {c.X}, {c.Y} as it's a sprinkler and the config option 'place_torches_in_sprinklers' is disabled", LogLevel.Trace);
                     return(true);
                 }
                 else
                 {
                     // Add light to map data
                     ModEntry.mapDict.enableLightOnObject(Game1.currentLocation.Name, c);
                     // Take torch from inventory
                     Game1.player.reduceActiveItemByOne();
                     // Make light source in game
                     Game1.currentLocation.Objects[c].lightSource = (new Torch(c, 1)).lightSource;
                     return(false);
                 }
             }
         }
     }
     return(true);
 }
Пример #3
0
        private void InputEvents_ButtonPressed(object sender, EventArgsInput e)
        {
            int arrowScaleOffset = 30;

            e.Button.TryGetKeyboard(out Keys keyPressed);
            e.Button.TryGetStardewInput(out InputButton button);

            if (button.mouseLeft)
            {
                if (toggle)
                {
                    ICursorPosition cursonPosition = Helper.Input.GetCursorPosition();
                    if (LeftArrowButton != null && Config.datableType == DatableType.Bachelor)
                    {
                        if (new Rectangle(LeftArrowButton.bounds.X, LeftArrowButton.bounds.Y,
                                          LeftArrowButton.bounds.Right + arrowScaleOffset,
                                          LeftArrowButton.bounds.Bottom + arrowScaleOffset)
                            .Contains((int)cursonPosition.ScreenPixels.X, (int)cursonPosition.ScreenPixels.Y))
                        {
                            Helper.Input.Suppress(SButton.MouseLeft);
                            if (Validate(DatableType.Bachelorette) != Validation.NoBachelorettes)
                            {
                                SGame.playSound("smallSelect");
                                Config.datableType = DatableType.Bachelorette;
                                GraphicsEvents.OnPostRenderHudEvent -= this.GraphicsEvents_OnPostRenderHudEvent;
                                ProcessAndRender();
                            }
                            else
                            {
                                SGame.showRedMessage("You don't know any Bachelorettes!");
                            }
                        }
                    }

                    if (RightArrowButton != null && Config.datableType == DatableType.Bachelorette)
                    {
                        if (new Rectangle(RightArrowButton.bounds.X, RightArrowButton.bounds.Y,
                                          RightArrowButton.bounds.Right + arrowScaleOffset,
                                          RightArrowButton.bounds.Bottom + arrowScaleOffset)
                            .Contains((int)cursonPosition.ScreenPixels.X, (int)cursonPosition.ScreenPixels.Y))
                        {
                            Helper.Input.Suppress(SButton.MouseLeft);
                            if (Validate(DatableType.Bachelor) != Validation.NoBachelors)
                            {
                                SGame.playSound("smallSelect");
                                Config.datableType = DatableType.Bachelor;
                                GraphicsEvents.OnPostRenderHudEvent -= this.GraphicsEvents_OnPostRenderHudEvent;
                                ProcessAndRender();
                            }
                            else
                            {
                                SGame.showRedMessage("You don't know any Bachelors!");
                            }
                        }
                    }
                }
            }

            if (keyPressed.Equals(Config.activateKey))
            {
                if (!toggle)
                {
                    //Monitor.Log(i18n.Get("template.key"), LogLevel.Info);
                    if (Validate(Config.datableType, true) == Validation.NoValid)
                    {
                        SGame.showRedMessage("You don't know any eligible villagers");
                    }
                    else if (Config.datableType == DatableType.Bachelorette && Validate(DatableType.Bachelorette) == Validation.NoBachelorettes)
                    {
                        Config.datableType = DatableType.Bachelor;
                        if (Validate(Config.datableType) != Validation.NoBachelors)
                        {
                            toggle = !toggle;
                            ProcessAndRender();
                        }
                    }
                    else if (Config.datableType == DatableType.Bachelor && Validate(DatableType.Bachelor) == Validation.NoBachelors)
                    {
                        Config.datableType = DatableType.Bachelorette;
                        if (Validate(Config.datableType) != Validation.NoBachelorettes)
                        {
                            toggle = !toggle;
                            ProcessAndRender();
                        }
                    }
                    else
                    {
                        toggle = !toggle;
                        ProcessAndRender();
                    }
                    //}
                }
                else
                {
                    toggle           = !toggle;
                    LeftArrowButton  = null;
                    RightArrowButton = null;
                    GraphicsEvents.OnPostRenderHudEvent -= this.GraphicsEvents_OnPostRenderHudEvent;
                }
            }
        }
Пример #4
0
        //public void GetStats()
        //{
        //    var farmers = SGame.getAllFarmers();
        //    Friendship friendship;
        //    int i = 0;
        //    fToGoWidth = 0; // need separate M/F values
        //    mToGoWidth = 0;
        //    NameWidth = 0; // need separate M/F values
        //    NameLength = 0; // need separate M/F values
        //    MaxName = ""; // need separate M/F values

        //    Bachelors = GetDatables(DatableType.Bachelor);
        //    Bachelorettes = GetDatables(DatableType.Bachelorette);
        //    foreach (NPC npc in Bachelors)
        //    {
        //        foreach (SFarmer farmer in farmers)
        //        {
        //            if (!farmer.friendshipData.ContainsKey(npc.getName()))
        //                continue;

        //            friendship = farmer.friendshipData[npc.getName()];
        //            BachelorStats.Add(new FriendshipStats(farmer, npc, friendship, DatableType.Bachelor));
        //            if ((int)SGame.smallFont.MeasureString(BachelorStats[i].Level.ToString()).X > mToGoWidth)
        //                mToGoWidth = (int)SGame.smallFont.MeasureString(BachelorStats[i].Level.ToString()).X;
        //            if (SGame.smallFont.MeasureString(BachelorStats[i].Name.ToString()).X > NameWidth)
        //                NameWidth = (int)SGame.smallFont.MeasureString(BachelorStats[i].Level.ToString()).X;
        //            if (BachelorStats[i].Name.Length > NameLength)
        //            {
        //                NameLength = BachelorStats[i].Name.Length;
        //                MaxName = BachelorStats[i].Name;
        //            }
        //        }
        //    }

        //}

        private Validation Validate(DatableType datableType, bool checkAll = false, [System.Runtime.CompilerServices.CallerLineNumber] int lineNumber = 0)
        {
            Validation validation     = Validation.AllValid;
            var        farmers        = SGame.getAllFarmers();
            int        i              = 0;
            int        invalidCounter = 0;

            if (datableType == DatableType.Bachelor || checkAll == true)
            {
                foreach (NPC npc in GetDatables(DatableType.Bachelor))
                {
                    foreach (SFarmer farmer in farmers)
                    {
                        if (!farmer.friendshipData.ContainsKey(npc.getName()))
                        {
                            continue;
                        }

                        i++;
                    }
                }
                if (i == 0)
                {
                    validation = Validation.NoBachelors;
                    if (checkAll)
                    {
                        invalidCounter++;
                    }
                    else
                    {
                        return(validation);
                    }
                }
            }
            i = 0;
            if (datableType == DatableType.Bachelorette || checkAll == true)
            {
                foreach (NPC npc in GetDatables(DatableType.Bachelorette))
                {
                    foreach (SFarmer farmer in farmers)
                    {
                        if (!farmer.friendshipData.ContainsKey(npc.getName()))
                        {
                            continue;
                        }

                        i++;
                    }
                }
                if (i == 0)
                {
                    validation = Validation.NoBachelorettes;
                    if (checkAll)
                    {
                        invalidCounter++;
                    }
                    else
                    {
                        return(validation);
                    }
                }
            }
            if (checkAll == true)
            {
                if (invalidCounter == 2)
                {
                    validation = Validation.NoValid;
                }
            }
            return(validation);
        }
Пример #5
0
        public void drawDescription(SpriteBatch b, int x, int y, int width)
        {
            b.DrawString(Game1.smallFont, this.name, new Vector2((float)x, (float)y), Game1.textColor);
            string text = Game1.parseText(this.description, Game1.smallFont, width);

            b.DrawString(Game1.smallFont, text, new Vector2((float)x, (float)y + Game1.smallFont.MeasureString(this.name).Y), Game1.textColor * 0.75f);
            int num = (int)((float)y + Game1.smallFont.MeasureString(this.name).Y + Game1.smallFont.MeasureString(text).Y);

            foreach (KeyValuePair <int, int> current in this.itemsRequired)
            {
                b.Draw(Game1.objectSpriteSheet, new Vector2((float)(x + Game1.tileSize / 8), (float)num), new Rectangle?(Game1.getSourceRectForStandardTileSheet(Game1.objectSpriteSheet, current.Key, 16, 16)), Color.White, 0f, new Vector2(6f, 3f), (float)Game1.pixelZoom * 0.5f, SpriteEffects.None, 0.999f);
                Color color = Game1.player.hasItemInInventory(current.Key, current.Value, 0) ? Color.DarkGreen : Color.DarkRed;
                Utility.drawTinyDigits(current.Value, b, new Vector2((float)(x + Game1.tileSize / 2) - Game1.tinyFont.MeasureString(string.Concat(current.Value)).X, (float)(num + Game1.tileSize / 2) - Game1.tinyFont.MeasureString(string.Concat(current.Value)).Y), 1f, 0.9f, Color.AntiqueWhite);
                b.DrawString(Game1.smallFont, Game1.objectInformation[current.Key].Split(new char[]
                {
                    '/'
                })[4], new Vector2((float)(x + Game1.tileSize / 2 + Game1.tileSize / 4), (float)num), color);
                num += (int)Game1.smallFont.MeasureString("P").Y;
            }
            if (this.moneyRequired > 0)
            {
                b.Draw(Game1.debrisSpriteSheet, new Vector2((float)x, (float)num), new Rectangle?(Game1.getSourceRectForStandardTileSheet(Game1.debrisSpriteSheet, 8, -1, -1)), Color.White, 0f, new Vector2((float)(Game1.tileSize / 2 - Game1.tileSize / 8), (float)(Game1.tileSize / 2 - Game1.tileSize / 3)), 0.5f, SpriteEffects.None, 0.999f);
                Color color2 = (Game1.player.money >= this.moneyRequired) ? Color.DarkGreen : Color.DarkRed;
                b.DrawString(Game1.smallFont, Game1.content.LoadString("Strings\\StringsFromCSFiles:LoadGameMenu.cs.11020", new object[]
                {
                    this.moneyRequired
                }), new Vector2((float)(x + Game1.tileSize / 4 + Game1.tileSize / 8), (float)num), color2);
                num += (int)Game1.smallFont.MeasureString(string.Concat(this.moneyRequired)).Y;
            }
        }
Пример #6
0
        public virtual Vector2 GetToolLocation(bool ignoreClick = false)
        {
            if (!Game1.wasMouseVisibleThisFrame || Game1.isAnyGamePadButtonBeingHeld())
            {
                ignoreClick = true;
            }
            if ((Game1.player.CurrentTool == null || !(Game1.player.CurrentTool is WateringCan)) && (int)(this.lastClick.X / (float)Game1.tileSize) == Game1.player.getTileX() && (int)(this.lastClick.Y / (float)Game1.tileSize) == Game1.player.getTileY())
            {
                Microsoft.Xna.Framework.Rectangle boundingBox = this.GetBoundingBox();
                switch (this.facingDirection)
                {
                case 0:
                    return(new Vector2((float)(boundingBox.X + boundingBox.Width / 2), (float)(boundingBox.Y - Game1.tileSize)));

                case 1:
                    return(new Vector2((float)(boundingBox.X + boundingBox.Width + Game1.tileSize), (float)(boundingBox.Y + boundingBox.Height / 2)));

                case 2:
                    return(new Vector2((float)(boundingBox.X + boundingBox.Width / 2), (float)(boundingBox.Y + boundingBox.Height + Game1.tileSize)));

                case 3:
                    return(new Vector2((float)(boundingBox.X - Game1.tileSize), (float)(boundingBox.Y + boundingBox.Height / 2)));
                }
            }
            if (!ignoreClick && !this.lastClick.Equals(Vector2.Zero) && this.name.Equals(Game1.player.name) && ((int)(this.lastClick.X / (float)Game1.tileSize) != Game1.player.getTileX() || (int)(this.lastClick.Y / (float)Game1.tileSize) != Game1.player.getTileY() || (Game1.player.CurrentTool != null && Game1.player.CurrentTool is WateringCan)) && Utility.distance(this.lastClick.X, (float)Game1.player.getStandingX(), this.lastClick.Y, (float)Game1.player.getStandingY()) <= (float)(Game1.tileSize * 2))
            {
                return(this.lastClick);
            }
            Microsoft.Xna.Framework.Rectangle boundingBox2 = this.GetBoundingBox();
            if (Game1.player.CurrentTool != null && Game1.player.CurrentTool.Name.Equals("Fishing Rod"))
            {
                switch (this.facingDirection)
                {
                case 0:
                    return(new Vector2((float)(boundingBox2.X - Game1.tileSize / 4), (float)(boundingBox2.Y - Game1.tileSize * 8 / 5)));

                case 1:
                    return(new Vector2((float)(boundingBox2.X + boundingBox2.Width + Game1.tileSize), (float)boundingBox2.Y));

                case 2:
                    return(new Vector2((float)(boundingBox2.X - Game1.tileSize / 4), (float)(boundingBox2.Y + boundingBox2.Height + Game1.tileSize)));

                case 3:
                    return(new Vector2((float)(boundingBox2.X - Game1.tileSize * 7 / 4), (float)boundingBox2.Y));
                }
            }
            else
            {
                switch (this.facingDirection)
                {
                case 0:
                    return(new Vector2((float)(boundingBox2.X + boundingBox2.Width / 2), (float)(boundingBox2.Y - Game1.tileSize * 3 / 4)));

                case 1:
                    return(new Vector2((float)(boundingBox2.X + boundingBox2.Width + Game1.tileSize * 3 / 4), (float)(boundingBox2.Y + boundingBox2.Height / 2)));

                case 2:
                    return(new Vector2((float)(boundingBox2.X + boundingBox2.Width / 2), (float)(boundingBox2.Y + boundingBox2.Height + Game1.tileSize * 3 / 4)));

                case 3:
                    return(new Vector2((float)(boundingBox2.X - Game1.tileSize * 3 / 4), (float)(boundingBox2.Y + boundingBox2.Height / 2)));
                }
            }
            return(new Vector2((float)this.getStandingX(), (float)this.getStandingY()));
        }
Пример #7
0
 public virtual void update(GameTime time, GameLocation location, long id, bool move)
 {
     if (this.yJumpOffset != 0)
     {
         this.yJumpVelocity -= 0.5f;
         this.yJumpOffset   -= (int)this.yJumpVelocity;
         if (this.yJumpOffset >= 0)
         {
             this.yJumpOffset   = 0;
             this.yJumpVelocity = 0f;
             if (!this.IsMonster && (location == null || location.Equals(Game1.currentLocation)))
             {
                 FarmerSprite.checkForFootstep(this);
             }
         }
     }
     if (this.faceTowardFarmerTimer > 0)
     {
         this.faceTowardFarmerTimer -= time.ElapsedGameTime.Milliseconds;
         if (!this.faceTowardFarmer && this.faceTowardFarmerTimer > 0 && Utility.tileWithinRadiusOfPlayer((int)this.getTileLocation().X, (int)this.getTileLocation().Y, this.faceTowardFarmerRadius, this.whoToFace))
         {
             this.faceTowardFarmer = true;
         }
         else if (!Utility.tileWithinRadiusOfPlayer((int)this.getTileLocation().X, (int)this.getTileLocation().Y, this.faceTowardFarmerRadius, this.whoToFace) || this.faceTowardFarmerTimer <= 0)
         {
             this.faceDirection(this.facingDirectionBeforeSpeakingToPlayer);
             if (this.faceTowardFarmerTimer <= 0)
             {
                 this.facingDirectionBeforeSpeakingToPlayer = -1;
                 this.faceTowardFarmer      = false;
                 this.faceAwayFromFarmer    = false;
                 this.faceTowardFarmerTimer = 0;
             }
         }
     }
     if (this.forceUpdateTimer > 0)
     {
         this.forceUpdateTimer -= time.ElapsedGameTime.Milliseconds;
     }
     this.updateGlow();
     this.updateEmote(time);
     if (!Game1.IsMultiplayer || Game1.IsServer || this.ignoreMultiplayerUpdates)
     {
         if (this.faceTowardFarmer && this.whoToFace != null)
         {
             this.faceGeneralDirection(this.whoToFace.getStandingPosition(), 0);
             if (this.faceAwayFromFarmer)
             {
                 this.faceDirection((this.facingDirection + 2) % 4);
             }
         }
         if ((this.controller == null & move) && !this.freezeMotion)
         {
             this.updateMovement(location, time);
         }
         if (this.controller != null && !this.freezeMotion && this.controller.update(time))
         {
             this.controller = null;
         }
         if (Game1.IsServer && !Game1.isFestival() && Game1.random.NextDouble() < 0.2)
         {
             MultiplayerUtility.broadcastNPCMove((int)this.position.X, (int)this.position.Y, id, location);
             return;
         }
     }
     else if (!Game1.eventUp)
     {
         this.lerpPosition(this.positionToLerpTo);
         if (this.distanceFromLastServerPosition() >= 8f)
         {
             this.animateInFacingDirection(time);
         }
     }
 }
Пример #8
0
 public virtual void jump(float jumpVelocity)
 {
     this.yJumpVelocity = jumpVelocity;
     this.yJumpOffset   = -1;
     Game1.playSound("dwop");
 }
Пример #9
0
 public virtual void jump()
 {
     this.yJumpVelocity = 8f;
     this.yJumpOffset   = -1;
     Game1.playSound("dwop");
 }
Пример #10
0
        public void addNewHatchedAnimal(string name)
        {
            if (this.getBuilding() is Coop)
            {
                foreach (Object @object in this.objects.Values)
                {
                    if (@object.bigCraftable && @object.Name.Contains("Incubator") && (@object.heldObject != null && @object.minutesUntilReady <= 0) && !this.isFull())
                    {
                        string type = "??";
                        if (@object.heldObject == null)
                        {
                            type = "White Chicken";
                        }
                        else
                        {
                            switch (@object.heldObject.ParentSheetIndex)
                            {
                            case 305:
                                type = "Void Chicken";
                                break;

                            case 442:
                                type = "Duck";
                                break;

                            case 180:
                            case 182:
                                type = "Brown Chicken";
                                break;

                            case 107:
                                type = "Dinosaur";
                                break;

                            case 174:
                            case 176:
                                type = "White Chicken";
                                break;
                            }
                        }
                        FarmAnimal farmAnimal = new FarmAnimal(type, MultiplayerUtility.getNewID(), Game1.player.uniqueMultiplayerID);
                        farmAnimal.name        = name;
                        farmAnimal.displayName = name;
                        Building building = this.getBuilding();
                        farmAnimal.home         = building;
                        farmAnimal.homeLocation = new Vector2((float)building.tileX, (float)building.tileY);
                        farmAnimal.setRandomPosition(farmAnimal.home.indoors);
                        (building.indoors as AnimalHouse).animals.Add(farmAnimal.myID, farmAnimal);
                        (building.indoors as AnimalHouse).animalsThatLiveHere.Add(farmAnimal.myID);
                        @object.heldObject       = (Object)null;
                        @object.ParentSheetIndex = 101;
                        break;
                    }
                }
            }
            else if (Game1.farmEvent != null && Game1.farmEvent is QuestionEvent)
            {
                FarmAnimal farmAnimal = new FarmAnimal((Game1.farmEvent as QuestionEvent).animal.type, MultiplayerUtility.getNewID(), Game1.player.uniqueMultiplayerID);
                farmAnimal.name        = name;
                farmAnimal.displayName = name;
                farmAnimal.parentId    = (Game1.farmEvent as QuestionEvent).animal.myID;
                Building building = this.getBuilding();
                farmAnimal.home         = building;
                farmAnimal.homeLocation = new Vector2((float)building.tileX, (float)building.tileY);
                (Game1.farmEvent as QuestionEvent).forceProceed = true;
                farmAnimal.setRandomPosition(farmAnimal.home.indoors);
                (building.indoors as AnimalHouse).animals.Add(farmAnimal.myID, farmAnimal);
                (building.indoors as AnimalHouse).animalsThatLiveHere.Add(farmAnimal.myID);
            }
            if (Game1.currentLocation.currentEvent != null)
            {
                ++Game1.currentLocation.currentEvent.CurrentCommand;
            }
            Game1.exitActiveMenu();
        }
Пример #11
0
        public void draw(GameTime gametime)
        {
            if (this.day)
            {
                Game1.graphics.GraphicsDevice.Clear(Utility.getSkyColorForSeason(Game1.currentSeason));
            }
            Game1.drawTitleScreenBackground(gametime, this.day ? "_day" : "_night", Utility.weatherDebrisOffsetForSeason(Game1.currentSeason));
            Viewport viewport = Game1.graphics.GraphicsDevice.Viewport;
            int      height   = viewport.TitleSafeArea.Height - Game1.tileSize * 2;

            viewport = Game1.graphics.GraphicsDevice.Viewport;
            int x1 = viewport.TitleSafeArea.X;

            viewport = Game1.graphics.GraphicsDevice.Viewport;
            int num1 = viewport.Width / 2;
            int x2   = x1 + num1 - (int)((double)((this.shippingItems.Count / (height / Game1.tileSize - 4) + 1) * Game1.tileSize) * 3.0);

            viewport = Game1.graphics.GraphicsDevice.Viewport;
            int y1    = viewport.TitleSafeArea.Y + Game1.tileSize;
            int width = (int)((double)((this.shippingItems.Count / (height / Game1.tileSize - 4) + 1) * Game1.tileSize) * 6.0);

            Game1.drawDialogueBox(x2, y1, width, height, false, true, (string)null, false);
            int   num2  = height - Game1.tileSize * 3;
            Point point = new Point(x2 + Game1.tileSize, y1 + Game1.tileSize);

            for (int index = 0; index < this.currentItemIndex; ++index)
            {
                SpriteBatch spriteBatch1      = Game1.spriteBatch;
                Texture2D   objectSpriteSheet = Game1.objectSpriteSheet;
                double      num3 = (double)(point.X + index * Game1.tileSize / (num2 - Game1.tileSize * 2) * Game1.tileSize * 4 + Game1.tileSize / 2);
                int         num4 = index * Game1.tileSize % (num2 - Game1.tileSize * 2) - index * Game1.tileSize % (num2 - Game1.tileSize * 2) % Game1.tileSize;
                viewport = Game1.graphics.GraphicsDevice.Viewport;
                int       y2              = viewport.TitleSafeArea.Y;
                double    num5            = (double)(num4 + y2 + Game1.tileSize * 3 + Game1.tileSize / 2);
                Vector2   position1       = new Vector2((float)num3, (float)num5);
                Rectangle?sourceRectangle = new Rectangle?(Game1.getSourceRectForStandardTileSheet(Game1.objectSpriteSheet, this.shippingItems.Keys.ElementAt <ShippedItem>(index).index, -1, -1));
                Color     white           = Color.White;
                double    num6            = 0.0;
                Vector2   origin          = new Vector2((float)(Game1.tileSize / 2), (float)(Game1.tileSize / 2));
                double    num7            = this.shippingItems.Keys.ElementAt <ShippedItem>(index).name.Contains("=") ? (double)this.starScale : 1.0;
                int       num8            = 0;
                double    num9            = 0.999998986721039;
                spriteBatch1.Draw(objectSpriteSheet, position1, sourceRectangle, white, (float)num6, origin, (float)num7, (SpriteEffects)num8, (float)num9);
                SpriteBatch spriteBatch2 = Game1.spriteBatch;
                SpriteFont  dialogueFont = Game1.dialogueFont;
                string      text         = "x" + (object)this.shippingItems[this.shippingItems.Keys.ElementAt <ShippedItem>(index)] + " : " + (object)(this.shippingItems.Keys.ElementAt <ShippedItem>(index).price *this.shippingItems[this.shippingItems.Keys.ElementAt <ShippedItem>(index)]) + "g";
                double      num10        = (double)(point.X + index * Game1.tileSize / (num2 - Game1.tileSize * 2) * Game1.tileSize * 4 + Game1.tileSize);
                double      num11        = (double)(index * Game1.tileSize % (num2 - Game1.tileSize * 2) - index * Game1.tileSize % (num2 - Game1.tileSize * 2) % Game1.tileSize + Game1.tileSize / 2) - (double)Game1.dialogueFont.MeasureString("9").Y / 2.0;
                viewport = Game1.graphics.GraphicsDevice.Viewport;
                double  y3        = (double)viewport.TitleSafeArea.Y;
                double  num12     = num11 + y3 + (double)(Game1.tileSize * 3);
                Vector2 position2 = new Vector2((float)num10, (float)num12);
                Color   textColor = Game1.textColor;
                spriteBatch2.DrawString(dialogueFont, text, position2, textColor);
            }
            if (!this.complete)
            {
                return;
            }
            SpriteBatch spriteBatch   = Game1.spriteBatch;
            SpriteFont  dialogueFont1 = Game1.dialogueFont;
            string      text1         = Game1.content.LoadString("Strings\\StringsFromCSFiles:MoneyMadeScreen.cs.3854", (object)this.total);
            double      num13         = (double)(x2 + width - Game1.tileSize) - (double)Game1.dialogueFont.MeasureString("Total: " + (object)this.total).X;

            viewport = Game1.graphics.GraphicsDevice.Viewport;
            double  num14      = (double)(viewport.TitleSafeArea.Bottom - Game1.tileSize * 5 / 2);
            Vector2 position   = new Vector2((float)num13, (float)num14);
            Color   textColor1 = Game1.textColor;

            spriteBatch.DrawString(dialogueFont1, text1, position, textColor1);
        }
Пример #12
0
 public override void draw(SpriteBatch spriteBatch, bool localPosition = false, int xOffset = 0, int yOffset = 0, float extraAlpha = 1f)
 {
     spriteBatch.Draw(texture, Game1.GlobalToLocal(Game1.viewport, position), sourceRect, color, rotation, new Vector2(8f, 8f), 4f, SpriteEffects.None, (float)(groundYLevel + 1) / 10000f);
 }
Пример #13
0
        public void draw(SpriteBatch b, int i)
        {
            if (this.noIcon)
            {
                IClickableMenu.drawHoverText(b, this.message, Game1.dialogueFont, 0, 0, -1, null, -1, null, null, 0, -1, -1, Game1.tileSize / 4, ((Game1.viewport.Width < 1400) ? (-Game1.tileSize) : 0) + Game1.graphics.GraphicsDevice.Viewport.Height - (i + 1) * Game1.tileSize * 7 / 4 - Game1.tileSize / 3 - (int)Game1.dialogueFont.MeasureString(this.message).Y, this.transparency, null);
                return;
            }
            Vector2 vector = new Vector2((float)(Game1.tileSize / 4), (float)(Game1.graphics.GraphicsDevice.Viewport.TitleSafeArea.Bottom - (i + 1) * Game1.tileSize * 7 / 4 - Game1.tileSize));

            if (Game1.isOutdoorMapSmallerThanViewport())
            {
                vector.X = (float)Math.Max(Game1.tileSize / 4, -Game1.viewport.X + Game1.tileSize / 4);
            }
            if (Game1.viewport.Width < 1400)
            {
                vector.Y -= (float)(Game1.tileSize * 3 / 4);
            }
            b.Draw(Game1.mouseCursors, vector, new Rectangle?((this.messageSubject != null && this.messageSubject is Object && (this.messageSubject as Object).sellToStorePrice() > 500) ? new Rectangle(163, 399, 26, 24) : new Rectangle(293, 360, 26, 24)), Color.White * this.transparency, 0f, Vector2.Zero, (float)Game1.pixelZoom, SpriteEffects.None, 1f);
            float x = Game1.smallFont.MeasureString((this.messageSubject == null || this.messageSubject.DisplayName == null) ? ((this.message == null) ? "" : this.message) : this.messageSubject.DisplayName).X;

            b.Draw(Game1.mouseCursors, new Vector2(vector.X + (float)(26 * Game1.pixelZoom), vector.Y), new Rectangle?(new Rectangle(319, 360, 1, 24)), Color.White * this.transparency, 0f, Vector2.Zero, new Vector2(x, (float)Game1.pixelZoom), SpriteEffects.None, 1f);
            b.Draw(Game1.mouseCursors, new Vector2(vector.X + (float)(26 * Game1.pixelZoom) + x, vector.Y), new Rectangle?(new Rectangle(323, 360, 6, 24)), Color.White * this.transparency, 0f, Vector2.Zero, (float)Game1.pixelZoom, SpriteEffects.None, 1f);
            vector.X += (float)(Game1.pixelZoom * 4);
            vector.Y += (float)(Game1.pixelZoom * 4);
            if (this.messageSubject == null)
            {
                switch (this.whatType)
                {
                case 1:
                    b.Draw(Game1.mouseCursors, vector + new Vector2(8f, 8f) * (float)Game1.pixelZoom, new Rectangle?(new Rectangle(294, 392, 16, 16)), Color.White * this.transparency, 0f, new Vector2(8f, 8f), (float)Game1.pixelZoom + Math.Max(0f, (this.timeLeft - 3000f) / 900f), SpriteEffects.None, 1f);
                    break;

                case 2:
                    b.Draw(Game1.mouseCursors, vector + new Vector2(8f, 8f) * (float)Game1.pixelZoom, new Rectangle?(new Rectangle(403, 496, 5, 14)), Color.White * this.transparency, 0f, new Vector2(3f, 7f), (float)Game1.pixelZoom + Math.Max(0f, (this.timeLeft - 3000f) / 900f), SpriteEffects.None, 1f);
                    break;

                case 3:
                    b.Draw(Game1.mouseCursors, vector + new Vector2(8f, 8f) * (float)Game1.pixelZoom, new Rectangle?(new Rectangle(268, 470, 16, 16)), Color.White * this.transparency, 0f, new Vector2(8f, 8f), (float)Game1.pixelZoom + Math.Max(0f, (this.timeLeft - 3000f) / 900f), SpriteEffects.None, 1f);
                    break;

                case 4:
                    b.Draw(Game1.mouseCursors, vector + new Vector2(8f, 8f) * (float)Game1.pixelZoom, new Rectangle?(new Rectangle(0, 411, 16, 16)), Color.White * this.transparency, 0f, new Vector2(8f, 8f), (float)Game1.pixelZoom + Math.Max(0f, (this.timeLeft - 3000f) / 900f), SpriteEffects.None, 1f);
                    break;

                case 5:
                    b.Draw(Game1.mouseCursors, vector + new Vector2(8f, 8f) * (float)Game1.pixelZoom, new Rectangle?(new Rectangle(16, 411, 16, 16)), Color.White * this.transparency, 0f, new Vector2(8f, 8f), (float)Game1.pixelZoom + Math.Max(0f, (this.timeLeft - 3000f) / 900f), SpriteEffects.None, 1f);
                    break;
                }
            }
            else
            {
                this.messageSubject.drawInMenu(b, vector, 1f + Math.Max(0f, (this.timeLeft - 3000f) / 900f), this.transparency, 1f, false);
            }
            vector.X += (float)(Game1.tileSize * 4 / 5);
            vector.Y += (float)(Game1.tileSize * 4 / 5);
            if (this.number > 1)
            {
                Utility.drawTinyDigits(this.number, b, vector, 3f, 1f, Color.White * this.transparency);
            }
            vector.X += (float)(Game1.tileSize / 2);
            vector.Y -= (float)(Game1.tileSize * 2 / 5 + Game1.pixelZoom * 2);
            Utility.drawTextWithShadow(b, (this.messageSubject == null) ? this.message : this.messageSubject.DisplayName, Game1.smallFont, vector, Game1.textColor * this.transparency, 1f, 1f, -1, -1, this.transparency, 3);
        }
Пример #14
0
        public bool harvest(int xTile, int yTile, HoeDirt soil, JunimoHarvester junimoHarvester = null)
        {
            if ((bool)dead)
            {
                if (junimoHarvester != null)
                {
                    return(true);
                }
                return(false);
            }
            bool success = false;

            if ((bool)forageCrop)
            {
                Object o           = null;
                int    experience2 = 3;
                Random r2          = new Random((int)Game1.stats.DaysPlayed + (int)Game1.uniqueIDForThisGame / 2 + xTile * 1000 + yTile * 2000);
                int    num         = whichForageCrop;
                if (num == 1)
                {
                    o = new Object(399, 1);
                }
                if (Game1.player.professions.Contains(16))
                {
                    o.Quality = 4;
                }
                else if (r2.NextDouble() < (double)((float)Game1.player.ForagingLevel / 30f))
                {
                    o.Quality = 2;
                }
                else if (r2.NextDouble() < (double)((float)Game1.player.ForagingLevel / 15f))
                {
                    o.Quality = 1;
                }
                Game1.stats.ItemsForaged += (uint)o.Stack;
                if (junimoHarvester != null)
                {
                    junimoHarvester.tryToAddItemToHut(o);
                    return(true);
                }
                if (Game1.player.addItemToInventoryBool(o))
                {
                    Vector2 initialTile2 = new Vector2(xTile, yTile);
                    Game1.player.animateOnce(279 + Game1.player.FacingDirection);
                    Game1.player.canMove = false;
                    Game1.player.currentLocation.playSound("harvest");
                    DelayedAction.playSoundAfterDelay("coin", 260);
                    if ((int)regrowAfterHarvest == -1)
                    {
                        Game1.multiplayer.broadcastSprites(Game1.currentLocation, new TemporaryAnimatedSprite(17, new Vector2(initialTile2.X * 64f, initialTile2.Y * 64f), Color.White, 7, r2.NextDouble() < 0.5, 125f));
                        Game1.multiplayer.broadcastSprites(Game1.currentLocation, new TemporaryAnimatedSprite(14, new Vector2(initialTile2.X * 64f, initialTile2.Y * 64f), Color.White, 7, r2.NextDouble() < 0.5, 50f));
                    }
                    Game1.player.gainExperience(2, experience2);
                    return(true);
                }
                Game1.showRedMessage(Game1.content.LoadString("Strings\\StringsFromCSFiles:Crop.cs.588"));
            }
            else if ((int)currentPhase >= phaseDays.Count - 1 && (!fullyGrown || (int)dayOfCurrentPhase <= 0))
            {
                int numToHarvest           = 1;
                int cropQuality            = 0;
                int fertilizerQualityLevel = 0;
                if ((int)indexOfHarvest == 0)
                {
                    return(true);
                }
                Random r = new Random(xTile * 7 + yTile * 11 + (int)Game1.stats.DaysPlayed + (int)Game1.uniqueIDForThisGame);
                switch ((int)soil.fertilizer)
                {
                case 368:
                    fertilizerQualityLevel = 1;
                    break;

                case 369:
                    fertilizerQualityLevel = 2;
                    break;
                }
                double chanceForGoldQuality   = 0.2 * ((double)Game1.player.FarmingLevel / 10.0) + 0.2 * (double)fertilizerQualityLevel * (((double)Game1.player.FarmingLevel + 2.0) / 12.0) + 0.01;
                double chanceForSilverQuality = Math.Min(0.75, chanceForGoldQuality * 2.0);
                if (r.NextDouble() < chanceForGoldQuality)
                {
                    cropQuality = 2;
                }
                else if (r.NextDouble() < chanceForSilverQuality)
                {
                    cropQuality = 1;
                }
                if ((int)minHarvest > 1 || (int)maxHarvest > 1)
                {
                    int max_harvest_increase = 0;
                    if (maxHarvestIncreasePerFarmingLevel.Value > 0)
                    {
                        max_harvest_increase = Game1.player.FarmingLevel / (int)maxHarvestIncreasePerFarmingLevel;
                    }
                    numToHarvest = r.Next(minHarvest, Math.Max((int)minHarvest + 1, (int)maxHarvest + 1 + max_harvest_increase));
                }
                if ((double)chanceForExtraCrops > 0.0)
                {
                    while (r.NextDouble() < Math.Min(0.9, chanceForExtraCrops))
                    {
                        numToHarvest++;
                    }
                }
                Object harvestedItem2 = programColored ? new ColoredObject(indexOfHarvest, 1, tintColor)
                {
                    Quality = cropQuality
                } : new Object(indexOfHarvest, 1, isRecipe: false, -1, cropQuality);
                if ((int)harvestMethod == 1)
                {
                    if (junimoHarvester != null)
                    {
                        DelayedAction.playSoundAfterDelay("daggerswipe", 150, junimoHarvester.currentLocation);
                    }
                    if (junimoHarvester != null && Utility.isOnScreen(junimoHarvester.getTileLocationPoint(), 64, junimoHarvester.currentLocation))
                    {
                        junimoHarvester.currentLocation.playSound("harvest");
                    }
                    if (junimoHarvester != null && Utility.isOnScreen(junimoHarvester.getTileLocationPoint(), 64, junimoHarvester.currentLocation))
                    {
                        DelayedAction.playSoundAfterDelay("coin", 260, junimoHarvester.currentLocation);
                    }
                    if (junimoHarvester != null)
                    {
                        junimoHarvester.tryToAddItemToHut(harvestedItem2.getOne());
                    }
                    else
                    {
                        Game1.createItemDebris(harvestedItem2.getOne(), new Vector2(xTile * 64 + 32, yTile * 64 + 32), -1);
                    }
                    success = true;
                }
                else if (junimoHarvester != null || Game1.player.addItemToInventoryBool(harvestedItem2.getOne()))
                {
                    Vector2 initialTile = new Vector2(xTile, yTile);
                    if (junimoHarvester == null)
                    {
                        Game1.player.animateOnce(279 + Game1.player.FacingDirection);
                        Game1.player.canMove = false;
                    }
                    else
                    {
                        junimoHarvester.tryToAddItemToHut(harvestedItem2.getOne());
                    }
                    if (r.NextDouble() < Game1.player.team.AverageLuckLevel() / 1500.0 + Game1.player.team.AverageDailyLuck() / 1200.0 + 9.9999997473787516E-05)
                    {
                        numToHarvest *= 2;
                        if (junimoHarvester == null)
                        {
                            Game1.player.currentLocation.playSound("dwoop");
                        }
                        else if (Utility.isOnScreen(junimoHarvester.getTileLocationPoint(), 64, junimoHarvester.currentLocation))
                        {
                            junimoHarvester.currentLocation.playSound("dwoop");
                        }
                    }
                    else if ((int)harvestMethod == 0)
                    {
                        if (junimoHarvester == null)
                        {
                            Game1.player.currentLocation.playSound("harvest");
                        }
                        else if (Utility.isOnScreen(junimoHarvester.getTileLocationPoint(), 64, junimoHarvester.currentLocation))
                        {
                            junimoHarvester.currentLocation.playSound("harvest");
                        }
                        if (junimoHarvester == null)
                        {
                            DelayedAction.playSoundAfterDelay("coin", 260, Game1.player.currentLocation);
                        }
                        else if (Utility.isOnScreen(junimoHarvester.getTileLocationPoint(), 64, junimoHarvester.currentLocation))
                        {
                            DelayedAction.playSoundAfterDelay("coin", 260, junimoHarvester.currentLocation);
                        }
                        if ((int)regrowAfterHarvest == -1 && (junimoHarvester == null || junimoHarvester.currentLocation.Equals(Game1.currentLocation)))
                        {
                            Game1.multiplayer.broadcastSprites(Game1.currentLocation, new TemporaryAnimatedSprite(17, new Vector2(initialTile.X * 64f, initialTile.Y * 64f), Color.White, 7, Game1.random.NextDouble() < 0.5, 125f));
                            Game1.multiplayer.broadcastSprites(Game1.currentLocation, new TemporaryAnimatedSprite(14, new Vector2(initialTile.X * 64f, initialTile.Y * 64f), Color.White, 7, Game1.random.NextDouble() < 0.5, 50f));
                        }
                    }
                    success = true;
                }
                else
                {
                    Game1.showRedMessage(Game1.content.LoadString("Strings\\StringsFromCSFiles:Crop.cs.588"));
                }
                if (success)
                {
                    if ((int)indexOfHarvest == 421)
                    {
                        indexOfHarvest.Value = 431;
                        numToHarvest         = r.Next(1, 4);
                    }
                    int price = Convert.ToInt32(Game1.objectInformation[indexOfHarvest].Split('/')[1]);
                    harvestedItem2 = (programColored ? new ColoredObject(indexOfHarvest, 1, tintColor) : new Object(indexOfHarvest, 1));
                    float experience = (float)(16.0 * Math.Log(0.018 * (double)price + 1.0, Math.E));
                    if (junimoHarvester == null)
                    {
                        Game1.player.gainExperience(0, (int)Math.Round(experience));
                    }
                    for (int i = 0; i < numToHarvest - 1; i++)
                    {
                        if (junimoHarvester == null)
                        {
                            Game1.createItemDebris(harvestedItem2.getOne(), new Vector2(xTile * 64 + 32, yTile * 64 + 32), -1);
                        }
                        else
                        {
                            junimoHarvester.tryToAddItemToHut(harvestedItem2.getOne());
                        }
                    }
                    if ((int)indexOfHarvest == 262 && r.NextDouble() < 0.4)
                    {
                        Object hay_item = new Object(178, 1);
                        if (junimoHarvester == null)
                        {
                            Game1.createItemDebris(hay_item.getOne(), new Vector2(xTile * 64 + 32, yTile * 64 + 32), -1);
                        }
                        else
                        {
                            junimoHarvester.tryToAddItemToHut(hay_item.getOne());
                        }
                    }
                    if ((int)regrowAfterHarvest == -1)
                    {
                        return(true);
                    }
                    fullyGrown.Value = true;
                    if (dayOfCurrentPhase.Value == (int)regrowAfterHarvest)
                    {
                        updateDrawMath(tilePosition);
                    }
                    dayOfCurrentPhase.Value = regrowAfterHarvest;
                }
            }
            return(false);
        }