Exemplo n.º 1
0
        /*
         * public LevelUpMenu()
         *  : base(Game1.viewport.Width / 2 - 384, Game1.viewport.Height / 2 - 256, 768, 512, false)
         * {
         *  this.width = 768;
         *  this.height = 512;
         *  ClickableTextureComponent textureComponent = new ClickableTextureComponent(new Rectangle(this.xPositionOnScreen + this.width + 4, this.yPositionOnScreen + this.height - 64 - IClickableMenu.borderWidth, 64, 64), Game1.mouseCursors, Game1.getSourceRectForStandardTileSheet(Game1.mouseCursors, 46, -1, -1), 1f, false);
         *  textureComponent.myID = 101;
         *  this.okButton = textureComponent;
         *  if (!Game1.options.SnappyMenus)
         *      return;
         *  this.populateClickableComponentList();
         *  this.snapToDefaultClickableComponent();
         * }*/

        // Constructor changed: int skill -> string skillName
        public SkillLevelUpMenu(string skillName, int level)
            : base(Game1.viewport.Width / 2 - 384, Game1.viewport.Height / 2 - 256, 768, 512, false)
        {
            this.timerBeforeStart = 250;
            this.isActive         = true;
            this.width            = 960;
            this.height           = 512;
            ClickableTextureComponent textureComponent = new ClickableTextureComponent(new Rectangle(this.xPositionOnScreen + this.width + 4, this.yPositionOnScreen + this.height - 64 - IClickableMenu.borderWidth, 64, 64), Game1.mouseCursors, Game1.getSourceRectForStandardTileSheet(Game1.mouseCursors, 46, -1, -1), 1f, false);

            textureComponent.myID = 101;
            this.okButton         = textureComponent;
            this.newCraftingRecipes.Clear();
            this.extraInfoForLevel.Clear();
            Game1.player.completelyStopAnimatingOrDoingAction();
            this.informationUp       = true;
            this.isProfessionChooser = false;
            this.currentLevel        = level;
            this.currentSkill        = skillName;

            /*if (level == 10)
             * {
             *  Game1.getSteamAchievement("Achievement_SingularTalent");
             *  if ((int)((NetFieldBase<int, NetInt>)Game1.player.farmingLevel) == 10 && (int)((NetFieldBase<int, NetInt>)Game1.player.miningLevel) == 10 && ((int)((NetFieldBase<int, NetInt>)Game1.player.fishingLevel) == 10 && (int)((NetFieldBase<int, NetInt>)Game1.player.foragingLevel) == 10) && (int)((NetFieldBase<int, NetInt>)Game1.player.combatLevel) == 10)
             *      Game1.getSteamAchievement("Achievement_MasterOfTheFiveWays");
             *  if (skill == 0)
             *      Game1.addMailForTomorrow("marnieAutoGrabber", false, false);
             * }
             */
            this.title             = Game1.content.LoadString("Strings\\UI:LevelUp_Title", (object)this.currentLevel, (object)Skills.skills[currentSkill].GetName());
            this.extraInfoForLevel = this.getExtraInfoForLevel(this.currentSkill, this.currentLevel);

            /*
             * switch (this.currentSkill)
             * {
             *  case 0:
             *      this.sourceRectForLevelIcon = new Rectangle(0, 0, 16, 16);
             *      break;
             *  case 1:
             *      this.sourceRectForLevelIcon = new Rectangle(16, 0, 16, 16);
             *      break;
             *  case 2:
             *      this.sourceRectForLevelIcon = new Rectangle(80, 0, 16, 16);
             *      break;
             *  case 3:
             *      this.sourceRectForLevelIcon = new Rectangle(32, 0, 16, 16);
             *      break;
             *  case 4:
             *      this.sourceRectForLevelIcon = new Rectangle(128, 16, 16, 16);
             *      break;
             *  case 5:
             *      this.sourceRectForLevelIcon = new Rectangle(64, 0, 16, 16);
             *      break;
             * }
             */
            var skill = Skills.skills[skillName];

            profPair = null;
            foreach (var pair in skill.ProfessionsForLevels)
            {
                if (pair.Level == currentLevel && (pair.Requires == null || Game1.player.professions.Contains(pair.Requires.GetVanillaId())))
                {
                    profPair = pair;
                    break;
                }
            }
            if (profPair != null)
            {
                this.professionsToChoose.Clear();
                this.isProfessionChooser = true;
            }

            /*
             * if ((this.currentLevel == 5 || this.currentLevel == 10) && this.currentSkill != 5)
             * {
             *  this.professionsToChoose.Clear();
             *  this.isProfessionChooser = true;
             * }
             */
            /*
             * int num = 0;
             * foreach (KeyValuePair<string, string> craftingRecipe in CraftingRecipe.craftingRecipes)
             * {
             *  string str = craftingRecipe.Value.Split('/')[4];
             *  if (str.Contains(Farmer.getSkillNameFromIndex(this.currentSkill)) && str.Contains(string.Concat((object)this.currentLevel)))
             *  {
             *      this.newCraftingRecipes.Add(new CraftingRecipe(craftingRecipe.Key, false));
             *      if (!Game1.player.craftingRecipes.ContainsKey(craftingRecipe.Key))
             *          Game1.player.craftingRecipes.Add(craftingRecipe.Key, 0);
             *      num += this.newCraftingRecipes.Last<CraftingRecipe>().bigCraftable ? 128 : 64;
             *  }
             * }
             * foreach (KeyValuePair<string, string> cookingRecipe in CraftingRecipe.cookingRecipes)
             * {
             *  string str = cookingRecipe.Value.Split('/')[3];
             *  if (str.Contains(Farmer.getSkillNameFromIndex(this.currentSkill)) && str.Contains(string.Concat((object)this.currentLevel)))
             *  {
             *      this.newCraftingRecipes.Add(new CraftingRecipe(cookingRecipe.Key, true));
             *      if (!Game1.player.cookingRecipes.ContainsKey(cookingRecipe.Key))
             *      {
             *          Game1.player.cookingRecipes.Add(cookingRecipe.Key, 0);
             *          if (!Game1.player.hasOrWillReceiveMail("robinKitchenLetter"))
             *              Game1.mailbox.Add("robinKitchenLetter");
             *      }
             *      num += this.newCraftingRecipes.Last<CraftingRecipe>().bigCraftable ? 128 : 64;
             *  }
             * }
             * this.height = num + 256 + this.extraInfoForLevel.Count * 64 * 3 / 4;
             */
            Game1.player.freezePause = 100;
            this.gameWindowSizeChanged(Rectangle.Empty, Rectangle.Empty);
            if (this.isProfessionChooser)
            {
                this.leftProfession = new ClickableComponent(new Rectangle(this.xPositionOnScreen, this.yPositionOnScreen + 128, this.width / 2, this.height), "")
                {
                    myID            = 102,
                    rightNeighborID = 103
                };
                this.rightProfession = new ClickableComponent(new Rectangle(this.width / 2 + this.xPositionOnScreen, this.yPositionOnScreen + 128, this.width / 2, this.height), "")
                {
                    myID           = 103,
                    leftNeighborID = 102
                };
            }
            this.populateClickableComponentList();
            RepositionOkButton();
        }
Exemplo n.º 2
0
        public override void update(GameTime time)
        {
            var Game1input = Game1.input;

            if (!this.isActive)
            {
                this.exitThisMenu(true);
            }
            else
            {
                if (/*this.isProfessionChooser &&*/ !this.hasUpdatedProfessions)
                {
                    var skill = Skills.skills[currentSkill];
                    profPair = null;
                    foreach (var pair in skill.ProfessionsForLevels)
                    {
                        if (pair.Level == currentLevel && (pair.Requires == null || Game1.player.professions.Contains(pair.Requires.GetVanillaId())))
                        {
                            profPair = pair;
                            break;
                        }
                    }
                    if (profPair != null)
                    {
                        this.isProfessionChooser = true;
                        this.professionsToChoose.Add(profPair.First.GetVanillaId());
                        this.professionsToChoose.Add(profPair.Second.GetVanillaId());
                    }

                    /*
                     * if (this.currentLevel == 5)
                     * {
                     *  this.professionsToChoose.Add(this.currentSkill * 6);
                     *  this.professionsToChoose.Add(this.currentSkill * 6 + 1);
                     * }
                     * else if (Game1.player.professions.Contains(this.currentSkill * 6))
                     * {
                     *  this.professionsToChoose.Add(this.currentSkill * 6 + 2);
                     *  this.professionsToChoose.Add(this.currentSkill * 6 + 3);
                     * }
                     * else
                     * {
                     *  this.professionsToChoose.Add(this.currentSkill * 6 + 4);
                     *  this.professionsToChoose.Add(this.currentSkill * 6 + 5);
                     * }
                     */
                    if (profPair != null)
                    {
                        var la = new List <string>(new string[] { profPair.First.GetName() });
                        la.AddRange(profPair.First.GetDescription().Split('\n'));
                        var ra = new List <string>(new string[] { profPair.Second.GetName() });
                        ra.AddRange(profPair.Second.GetDescription().Split('\n'));
                        this.leftProfessionDescription  = la; // LevelUpMenu.getProfessionDescription(this.professionsToChoose[0]);
                        this.rightProfessionDescription = ra; //LevelUpMenu.getProfessionDescription(this.professionsToChoose[1]);
                    }
                    this.hasUpdatedProfessions = true;
                }
                for (int index = this.littleStars.Count - 1; index >= 0; --index)
                {
                    if (this.littleStars[index].update(time))
                    {
                        this.littleStars.RemoveAt(index);
                    }
                }
                if (Game1.random.NextDouble() < 0.03)
                {
                    Vector2 position = new Vector2(0.0f, (float)(Game1.random.Next(this.yPositionOnScreen - 128, this.yPositionOnScreen - 4) / 20 * 4 * 5 + 32));
                    position.X = Game1.random.NextDouble() >= 0.5 ? (float)Game1.random.Next(this.xPositionOnScreen + this.width / 2 + 116, this.xPositionOnScreen + this.width - 160) : (float)Game1.random.Next(this.xPositionOnScreen + this.width / 2 - 228, this.xPositionOnScreen + this.width / 2 - 132);
                    if ((double)position.Y < (double)(this.yPositionOnScreen - 64 - 8))
                    {
                        position.X = (float)Game1.random.Next(this.xPositionOnScreen + this.width / 2 - 116, this.xPositionOnScreen + this.width / 2 + 116);
                    }
                    position.X = (float)((double)position.X / 20.0 * 4.0 * 5.0);
                    this.littleStars.Add(new TemporaryAnimatedSprite("LooseSprites\\Cursors", new Rectangle(364, 79, 5, 5), 80f, 7, 1, position, false, false, 1f, 0.0f, Color.White, 4f, 0.0f, 0.0f, 0.0f, false)
                    {
                        local = true
                    });
                }
                if (this.timerBeforeStart > 0)
                {
                    this.timerBeforeStart -= time.ElapsedGameTime.Milliseconds;
                    if (this.timerBeforeStart > 0 || !Game1.options.SnappyMenus)
                    {
                        return;
                    }
                    this.populateClickableComponentList();
                    this.snapToDefaultClickableComponent();
                }
                else
                {
                    if (this.isActive && this.isProfessionChooser)
                    {
                        this.leftProfessionColor  = Game1.textColor;
                        this.rightProfessionColor = Game1.textColor;
                        Game1.player.completelyStopAnimatingOrDoingAction();
                        Game1.player.freezePause = 100;
                        if (Game1.getMouseY() > this.yPositionOnScreen + 192 && Game1.getMouseY() < this.yPositionOnScreen + this.height)
                        {
                            if (Game1.getMouseX() > this.xPositionOnScreen && Game1.getMouseX() < this.xPositionOnScreen + this.width / 2)
                            {
                                this.leftProfessionColor = Color.Green;
                                if ((Game1input.GetMouseState().LeftButton == ButtonState.Pressed && this.oldMouseState.LeftButton == ButtonState.Released || Game1.options.gamepadControls && (Game1input.GetGamePadState().IsButtonDown(Buttons.A) && !Game1.oldPadState.IsButtonDown(Buttons.A))) && this.readyToClose())
                                {
                                    Game1.player.professions.Add(this.professionsToChoose[0]);
                                    this.getImmediateProfessionPerk(this.professionsToChoose[0]);
                                    this.isActive            = false;
                                    this.informationUp       = false;
                                    this.isProfessionChooser = false;
                                }
                            }
                            else if (Game1.getMouseX() > this.xPositionOnScreen + this.width / 2 && Game1.getMouseX() < this.xPositionOnScreen + this.width)
                            {
                                this.rightProfessionColor = Color.Green;
                                if ((Game1input.GetMouseState().LeftButton == ButtonState.Pressed && this.oldMouseState.LeftButton == ButtonState.Released || Game1.options.gamepadControls && (Game1input.GetGamePadState().IsButtonDown(Buttons.A) && !Game1.oldPadState.IsButtonDown(Buttons.A))) && this.readyToClose())
                                {
                                    Game1.player.professions.Add(this.professionsToChoose[1]);
                                    this.getImmediateProfessionPerk(this.professionsToChoose[1]);
                                    this.isActive            = false;
                                    this.informationUp       = false;
                                    this.isProfessionChooser = false;
                                }
                            }
                        }
                        this.height = 512;
                    }
                    this.oldMouseState = Game1input.GetMouseState();
                    if (this.isActive && !this.informationUp && this.starIcon != null)
                    {
                        this.starIcon.sourceRect.X = !this.starIcon.containsPoint(Game1.getOldMouseX(), Game1.getOldMouseY()) ? 310 : 294;
                    }
                    if (this.isActive && this.starIcon != null && !this.informationUp && (this.oldMouseState.LeftButton == ButtonState.Pressed || Game1.options.gamepadControls && Game1.oldPadState.IsButtonDown(Buttons.A)) && this.starIcon.containsPoint(this.oldMouseState.X, this.oldMouseState.Y))
                    {
                        this.newCraftingRecipes.Clear();
                        this.extraInfoForLevel.Clear();
                        Game1.player.completelyStopAnimatingOrDoingAction();
                        Game1.playSound("bigSelect");
                        this.informationUp       = true;
                        this.isProfessionChooser = false;
                        this.currentLevel        = Skills.myNewLevels.First().Value;
                        this.currentSkill        = Skills.myNewLevels.First().Key;

                        /*
                         * this.currentLevel = Game1.player.newLevels.First<Point>().Y;
                         * this.currentSkill = Game1.player.newLevels.First<Point>().X;
                         */
                        this.title             = Game1.content.LoadString("Strings\\UI:LevelUp_Title", (object)this.currentLevel, (object)Skills.skills[currentSkill].GetName());
                        this.extraInfoForLevel = this.getExtraInfoForLevel(this.currentSkill, this.currentLevel);

                        /*switch (this.currentSkill)
                         * {
                         *  case 0:
                         *      this.sourceRectForLevelIcon = new Rectangle(0, 0, 16, 16);
                         *      break;
                         *  case 1:
                         *      this.sourceRectForLevelIcon = new Rectangle(16, 0, 16, 16);
                         *      break;
                         *  case 2:
                         *      this.sourceRectForLevelIcon = new Rectangle(80, 0, 16, 16);
                         *      break;
                         *  case 3:
                         *      this.sourceRectForLevelIcon = new Rectangle(32, 0, 16, 16);
                         *      break;
                         *  case 4:
                         *      this.sourceRectForLevelIcon = new Rectangle(128, 16, 16, 16);
                         *      break;
                         *  case 5:
                         *      this.sourceRectForLevelIcon = new Rectangle(64, 0, 16, 16);
                         *      break;
                         * }*/
                        var skill = Skills.skills[currentSkill];
                        profPair = null;
                        foreach (var pair in skill.ProfessionsForLevels)
                        {
                            if (pair.Level == currentLevel && Game1.player.professions.Contains(pair.Requires.GetVanillaId()))
                            {
                                profPair = pair;
                                break;
                            }
                        }
                        if (profPair != null)
                        {
                            this.professionsToChoose.Clear();
                            this.isProfessionChooser = true;
                            this.professionsToChoose.Add(profPair.First.GetVanillaId());
                            this.professionsToChoose.Add(profPair.Second.GetVanillaId());
                        }

                        /*
                         * if ((this.currentLevel == 5 || this.currentLevel == 10) && this.currentSkill != 5)
                         * {
                         *  this.professionsToChoose.Clear();
                         *  this.isProfessionChooser = true;
                         *  if (this.currentLevel == 5)
                         *  {
                         *      this.professionsToChoose.Add(this.currentSkill * 6);
                         *      this.professionsToChoose.Add(this.currentSkill * 6 + 1);
                         *  }
                         *  else if (Game1.player.professions.Contains(this.currentSkill * 6))
                         *  {
                         *      this.professionsToChoose.Add(this.currentSkill * 6 + 2);
                         *      this.professionsToChoose.Add(this.currentSkill * 6 + 3);
                         *  }
                         *  else
                         *  {
                         *      this.professionsToChoose.Add(this.currentSkill * 6 + 4);
                         *      this.professionsToChoose.Add(this.currentSkill * 6 + 5);
                         *  }
                         *  this.leftProfessionDescription = LevelUpMenu.getProfessionDescription(this.professionsToChoose[0]);
                         *  this.rightProfessionDescription = LevelUpMenu.getProfessionDescription(this.professionsToChoose[1]);
                         * }
                         */
                        /*
                         * int num = 0;
                         * foreach (KeyValuePair<string, string> craftingRecipe in CraftingRecipe.craftingRecipes)
                         * {
                         *  string str = craftingRecipe.Value.Split('/')[4];
                         *  if (str.Contains(Farmer.getSkillNameFromIndex(this.currentSkill)) && str.Contains(string.Concat((object)this.currentLevel)))
                         *  {
                         *      this.newCraftingRecipes.Add(new CraftingRecipe(craftingRecipe.Key, false));
                         *      if (!Game1.player.craftingRecipes.ContainsKey(craftingRecipe.Key))
                         *          Game1.player.craftingRecipes.Add(craftingRecipe.Key, 0);
                         *      num += this.newCraftingRecipes.Last<CraftingRecipe>().bigCraftable ? 128 : 64;
                         *  }
                         * }
                         * foreach (KeyValuePair<string, string> cookingRecipe in CraftingRecipe.cookingRecipes)
                         * {
                         *  string str = cookingRecipe.Value.Split('/')[3];
                         *  if (str.Contains(Farmer.getSkillNameFromIndex(this.currentSkill)) && str.Contains(string.Concat((object)this.currentLevel)))
                         *  {
                         *      this.newCraftingRecipes.Add(new CraftingRecipe(cookingRecipe.Key, true));
                         *      if (!Game1.player.cookingRecipes.ContainsKey(cookingRecipe.Key))
                         *          Game1.player.cookingRecipes.Add(cookingRecipe.Key, 0);
                         *      num += this.newCraftingRecipes.Last<CraftingRecipe>().bigCraftable ? 128 : 64;
                         *  }
                         * }
                         * this.height = num + 256 + this.extraInfoForLevel.Count * 64 * 3 / 4;
                         */
                        Game1.player.freezePause = 100;
                    }
                    if (!this.isActive || !this.informationUp)
                    {
                        return;
                    }
                    Game1.player.completelyStopAnimatingOrDoingAction();
                    if (this.okButton.containsPoint(Game1.getOldMouseX(), Game1.getOldMouseY()) && !this.isProfessionChooser)
                    {
                        this.okButton.scale = Math.Min(1.1f, this.okButton.scale + 0.05f);
                        if ((this.oldMouseState.LeftButton == ButtonState.Pressed || Game1.options.gamepadControls && Game1.oldPadState.IsButtonDown(Buttons.A)) && this.readyToClose())
                        {
                            this.okButtonClicked();
                        }
                    }
                    else
                    {
                        this.okButton.scale = Math.Max(1f, this.okButton.scale - 0.05f);
                    }
                    Game1.player.freezePause = 100;
                }
            }
        }