Esempio n. 1
0
        public virtual void OnCurrencyChange(NetIntDelta field, int old_value, int new_value)
        {
            if (Game1.gameMode != 3)
            {
                return;
            }
            string currency_key = null;

            foreach (string key in registeredCurrencyDisplays.Keys)
            {
                if (registeredCurrencyDisplays[key].netIntDelta == field)
                {
                    currency_key = key;
                    break;
                }
            }
            if (currency_key == null)
            {
                return;
            }
            SetDisplayedCurrency(currency_key);
            if (_currentDisplayedCurrency != null)
            {
                _moneyDial.currentValue = old_value;
                if (_moneyDial.onPlaySound != null)
                {
                    _moneyDial.onPlaySound(new_value - old_value);
                }
            }
            timeToLive = 5f;
        }
Esempio n. 2
0
        static bool Prefix(SpriteBatch b, Vector2 position, int target, MoneyDial __instance, bool ___playSounds)
        {
            if (__instance.previousTargetValue != target)
            {
                speed = (target - __instance.currentValue) / 100;
                __instance.previousTargetValue = target;
                soundTimer = Math.Max(6, 100 / (Math.Abs(speed) + 1));
            }
            if (moneyShineTimer > 0 && __instance.currentValue == target)
            {
                moneyShineTimer -= Game1.currentGameTime.ElapsedGameTime.Milliseconds;
            }
            if (moneyMadeAccumulator > 0)
            {
                moneyMadeAccumulator -= (Math.Abs(speed / 2) + 1) * (__instance.animations.Count <= 0 ? 100 : 1);
                if (moneyMadeAccumulator <= 0)
                {
                    moneyShineTimer = __instance.numDigits * 60;
                }
            }
            if (moneyMadeAccumulator > 2000)
            {
                Game1.dayTimeMoneyBox.moneyShakeTimer = 100;
            }
            if (__instance.currentValue != target)
            {
                __instance.currentValue += speed + (__instance.currentValue < target ? 1 : -1);
                if (__instance.currentValue < target)
                {
                    moneyMadeAccumulator += Math.Abs(speed);
                }
                --soundTimer;
                if (Math.Abs(target - __instance.currentValue) <= speed + 1 || speed != 0 && Math.Sign(target - __instance.currentValue) != Math.Sign(speed))
                {
                    __instance.currentValue = target;
                }
                if (soundTimer <= 0)
                {
                    if (___playSounds && __instance.onPlaySound != null)
                    {
                        __instance.onPlaySound(Math.Sign(target - __instance.currentValue));
                    }
                    soundTimer = Math.Max(6, 100 / (Math.Abs(speed) + 1));
                    if (Game1.random.NextDouble() < 0.4)
                    {
                        if (target > __instance.currentValue)
                        {
                            __instance.animations.Add(new TemporaryAnimatedSprite(Game1.random.Next(10, 12), position + new Vector2((float)Game1.random.Next(30, 190), (float)Game1.random.Next(-32, 48)), Color.Gold));
                        }
                        else if (target < __instance.currentValue)
                        {
                            __instance.animations.Add(new TemporaryAnimatedSprite("LooseSprites\\Cursors", new Rectangle(356, 449, 1, 1), 999999f, 1, 44, position + new Vector2((float)Game1.random.Next(160), (float)Game1.random.Next(-32, 32)), false, false, 1f, 0.01f, Color.White, (float)(Game1.random.Next(1, 3) * 4), -1f / 1000f, 0.0f, 0.0f)
                            {
                                motion       = new Vector2((float)Game1.random.Next(-30, 40) / 10f, (float)Game1.random.Next(-30, -5) / 10f),
                                acceleration = new Vector2(0.0f, 0.25f)
                            });
                        }
                    }
                }
            }
            for (int index = __instance.animations.Count - 1; index >= 0; --index)
            {
                if (__instance.animations[index].update(Game1.currentGameTime))
                {
                    __instance.animations.RemoveAt(index);
                }
                else
                {
                    __instance.animations[index].draw(b, true);
                }
            }
            int  num1 = 0;
            int  num2 = (int)Math.Pow(10.0, (double)(__instance.numDigits - 1));
            bool flag = false;

            for (int index = 0; index < __instance.numDigits; ++index)
            {
                int num3 = __instance.currentValue / num2 % 10;
                if (num3 > 0 || index == __instance.numDigits - 1)
                {
                    flag = true;
                }
                if (flag)
                {
                    b.Draw(Game1.mouseCursors, position + new Vector2((float)num1, Game1.activeClickableMenu == null || !(Game1.activeClickableMenu is ShippingMenu) || __instance.currentValue < 1000000 ? 0.0f : (float)Math.Sin(Game1.currentGameTime.TotalGameTime.TotalMilliseconds / 100.530967712402 + (double)index) * (float)(__instance.currentValue / 1000000)), new Rectangle?(new Rectangle(286, 502 - num3 * 8, 5, 8)), Color.White, 0.0f, Vector2.Zero, (float)(4.0 + (moneyShineTimer / 60 == __instance.numDigits - index ? 0.300000011920929 : 0.0)), SpriteEffects.None, 1f);
                }
                num1 += 24;
                num2 /= 10;
            }
            return(false);
        }
Esempio n. 3
0
            private static void DrawMoneyDial(MoneyDial moneyDial, SpriteBatch b, Vector2 position, long target)
            {
                int numDigits = currentValue.ToString().Length;

                if (previousTargetValue != target)
                {
                    speed = (int)(target - currentValue) / 100;
                    previousTargetValue = target;
                    soundTimer          = Math.Max(6, 100 / (Math.Abs(speed) + 1));
                }
                if (AccessTools.FieldRefAccess <MoneyDial, int>(moneyDial, "moneyShineTimer") > 0 && currentValue == target)
                {
                    AccessTools.FieldRefAccess <MoneyDial, int>(moneyDial, "moneyShineTimer") -= Game1.currentGameTime.ElapsedGameTime.Milliseconds;
                }
                if (AccessTools.FieldRefAccess <MoneyDial, int>(moneyDial, "moneyMadeAccumulator") > 0)
                {
                    AccessTools.FieldRefAccess <MoneyDial, int>(moneyDial, "moneyMadeAccumulator") -= (int)(Math.Abs(speed / 2) + 1) * ((moneyDial.animations.Count <= 0) ? 100 : 1);
                    if (AccessTools.FieldRefAccess <MoneyDial, int>(moneyDial, "moneyMadeAccumulator") <= 0)
                    {
                        AccessTools.FieldRefAccess <MoneyDial, int>(moneyDial, "moneyShineTimer") = numDigits * 60;
                    }
                }
                if (AccessTools.FieldRefAccess <MoneyDial, int>(moneyDial, "moneyMadeAccumulator") > 2000)
                {
                    Game1.dayTimeMoneyBox.moneyShakeTimer = 100;
                }
                if (currentValue != target)
                {
                    currentValue += speed + ((currentValue < target) ? 1 : -1);
                    if (currentValue < target)
                    {
                        AccessTools.FieldRefAccess <MoneyDial, int>(moneyDial, "moneyMadeAccumulator") += (int)Math.Abs(speed);
                    }
                    soundTimer--;
                    if (Math.Abs(target - currentValue) <= speed + 1 || (speed != 0 && Math.Sign(target - currentValue) != Math.Sign(speed)))
                    {
                        currentValue = target;
                    }
                    if (soundTimer <= 0)
                    {
                        if (moneyDial.onPlaySound != null)
                        {
                            moneyDial.onPlaySound(Math.Sign(target - currentValue));
                        }
                        soundTimer = Math.Max(6, 100 / (Math.Abs(speed) + 1));
                        if (Game1.random.NextDouble() < 0.4)
                        {
                            if (target > currentValue)
                            {
                                moneyDial.animations.Add(new TemporaryAnimatedSprite(Game1.random.Next(10, 12), position + new Vector2((float)Game1.random.Next(30, 190), (float)Game1.random.Next(-32, 48)), Color.Gold, 8, false, 100f, 0, -1, -1f, -1, 0));
                            }
                            else if (target < currentValue)
                            {
                                moneyDial.animations.Add(new TemporaryAnimatedSprite("LooseSprites\\Cursors", new Rectangle(356, 449, 1, 1), 999999f, 1, 44, position + new Vector2((float)Game1.random.Next(160), (float)Game1.random.Next(-32, 32)), false, false, 1f, 0.01f, Color.White, (float)(Game1.random.Next(1, 3) * 4), -0.001f, 0f, 0f, false)
                                {
                                    motion       = new Vector2((float)Game1.random.Next(-30, 40) / 10f, (float)Game1.random.Next(-30, -5) / 10f),
                                    acceleration = new Vector2(0f, 0.25f)
                                });
                            }
                        }
                    }
                }
                for (int i = moneyDial.animations.Count - 1; i >= 0; i--)
                {
                    if (moneyDial.animations[i].update(Game1.currentGameTime))
                    {
                        moneyDial.animations.RemoveAt(i);
                    }
                    else
                    {
                        moneyDial.animations[i].draw(b, true, 0, 0, 1f);
                    }
                }
                int xPosition = 0;

                if (numDigits > 8)
                {
                    xPosition -= (numDigits - 8) * 24;
                }
                else
                {
                    xPosition += (8 - numDigits) * 24;
                }
                bool significant = false;

                numDigits = currentValue.ToString().Length;
                for (int j = 0; j < numDigits; j++)
                {
                    int currentDigit = int.Parse(currentValue.ToString()[j].ToString());
                    if (currentDigit > 0 || j == numDigits - 1)
                    {
                        significant = true;
                    }
                    if (significant)
                    {
                        b.Draw(Game1.mouseCursors, position + new Vector2(xPosition, 0f), new Rectangle?(new Rectangle(286, 502 - (currentDigit) * 8, 5, 8)), Color.Maroon, 0f, Vector2.Zero, 4f + ((AccessTools.FieldRefAccess <MoneyDial, int>(moneyDial, "moneyShineTimer") / 60 == numDigits - j) ? 0.3f : 0f), SpriteEffects.None, 1f);
                    }
                    xPosition += 24;
                }
            }