示例#1
0
 /// <inheritdoc />
 public void SetFishTraits(int fish, IFishTraits traits)
 {
     if (traits == null)
     {
         this._fishTraitsOverrides.Remove(fish);
     }
     else
     {
         this._fishTraitsOverrides[fish] = traits;
     }
 }
        public CustomBobberBar(Farmer user, int whichFish, float fishSize, bool treasure, int bobber) : base(whichFish, fishSize, treasure, bobber)
        {
            this.User        = user;
            this._origStreak = ModFishing.Instance.Api.GetStreak(user);
            this._origFish   = whichFish;

            /* Private field hooks */
            this._treasure            = new ReflectedField <BobberBar, bool>(this, "treasure");
            this._treasure            = new ReflectedField <BobberBar, bool>(this, "treasure");
            this._treasureCaught      = new ReflectedField <BobberBar, bool>(this, "treasureCaught");
            this._treasurePosition    = new ReflectedField <BobberBar, float>(this, "treasurePosition");
            this._treasureAppearTimer = new ReflectedField <BobberBar, float>(this, "treasureAppearTimer");
            this._treasureScale       = new ReflectedField <BobberBar, float>(this, "treasureScale");

            this._distanceFromCatching = new ReflectedField <BobberBar, float>(this, "distanceFromCatching");
            this._treasureCatchLevel   = new ReflectedField <BobberBar, float>(this, "treasureCatchLevel");

            this._bobberBarPos    = new ReflectedField <BobberBar, float>(this, "bobberBarPos");
            this._bobberInBar     = new ReflectedField <BobberBar, bool>(this, "bobberInBar");
            this._difficulty      = new ReflectedField <BobberBar, float>(this, "difficulty");
            this._fishQuality     = new ReflectedField <BobberBar, int>(this, "fishQuality");
            this._perfect         = new ReflectedField <BobberBar, bool>(this, "perfect");
            this._scale           = new ReflectedField <BobberBar, float>(this, "scale");
            this._flipBubble      = new ReflectedField <BobberBar, bool>(this, "flipBubble");
            this._bobberBarHeight = new ReflectedField <BobberBar, int>(this, "bobberBarHeight");
            this._reelRotation    = new ReflectedField <BobberBar, float>(this, "reelRotation");
            this._bobberPosition  = new ReflectedField <BobberBar, float>(this, "bobberPosition");
            this._bossFish        = new ReflectedField <BobberBar, bool>(this, "bossFish");
            this._motionType      = new ReflectedField <BobberBar, int>(this, "motionType");
            this._fishSize        = new ReflectedField <BobberBar, int>(this, "fishSize");
            this._whichFish       = new ReflectedField <BobberBar, int>(this, "whichFish");

            this._barShake        = new ReflectedField <BobberBar, Vector2>(this, "barShake");
            this._fishShake       = new ReflectedField <BobberBar, Vector2>(this, "fishShake");
            this._treasureShake   = new ReflectedField <BobberBar, Vector2>(this, "treasureShake");
            this._everythingShake = new ReflectedField <BobberBar, Vector2>(this, "everythingShake");

            this._sparkleText = new ReflectedField <BobberBar, SparklingText>(this, "sparkleText");

            this._lastDistanceFromCatching = this._distanceFromCatching.Value;
            this._lastTreasureCatchLevel   = this._treasureCatchLevel.Value;

            /* Actual code */
            ConfigMain  config = ModFishing.Instance.MainConfig;
            IFishTraits traits = ModFishing.Instance.Api.GetFishTraits(whichFish);

            // Check if fish is unaware
            this.Unaware = Game1.random.NextDouble() < ModFishing.Instance.Api.GetUnawareChance(user, whichFish);

            // Applies difficulty modifier, including if fish is unaware
            float difficulty = traits?.Difficulty ?? this._difficulty.Value;

            difficulty *= config.DifficultySettings.BaseDifficultyMult;
            difficulty *= 1F + this._origStreak * config.DifficultySettings.DifficultyStreakEffect;
            if (this.Unaware)
            {
                difficulty *= config.UnawareSettings.UnawareMult;
                Game1.showGlobalMessage(ModFishing.Translate("text.unaware", ModFishing.Translate("text.percent", 1F - config.UnawareSettings.UnawareMult)));
            }
            this._difficulty.Value = difficulty;

            // Adjusts additional traits about the fish
            if (traits != null)
            {
                this._motionType.Value = (int)traits.MotionType;
                this._fishSize.Value   = traits.MinSize + (int)((traits.MaxSize - traits.MinSize) * fishSize) + 1;
            }

            // Adjusts quality to be increased by streak
            int fishQuality = this._fishQuality.Value;

            this._origQuality = fishQuality;
            int qualityBonus = (int)Math.Floor((double)this._origStreak / config.StreakSettings.StreakForIncreasedQuality);

            fishQuality = Math.Min(fishQuality + qualityBonus, 3);
            if (fishQuality == 3)
            {
                fishQuality++;                   // Iridium-quality fish. Only possible through your perfect streak
            }
            this._fishQuality.Value = fishQuality;

            // Increase the user's perfect streak (this will be dropped to 0 if they don't get a perfect catch)
            if (this._origStreak >= config.StreakSettings.StreakForIncreasedQuality)
            {
                this._sparkleText.Value = new SparklingText(Game1.dialogueFont, ModFishing.Translate("text.streak", this._origStreak), Color.Yellow, Color.White);
            }
        }