Example #1
0
        /// <summary>
        /// Adds in a junimo actor at the current location. Allows for multiple.
        /// </summary>
        /// <param name="EventManager"></param>
        /// <param name="EventData"></param>
        public static void AddInJumimoActorForEvent(EventManager EventManager, string EventData)
        {
            string[] splits = EventData.Split(' ');
            string   name   = splits[0];

            string actorName = splits[1];
            int    xPos      = Convert.ToInt32(splits[2]);
            int    yPos      = Convert.ToInt32(splits[3]);
            Color  color     = new Color(Convert.ToInt32(splits[4]), Convert.ToInt32(splits[5]), Convert.ToInt32(splits[6]));
            bool   flipped   = Convert.ToBoolean(splits[7]);

            List <NPC> actors = Game1.CurrentEvent.actors;
            Junimo     junimo = new Junimo(new Vector2(xPos * 64, yPos * 64), -1, false);

            junimo.Name       = actorName;
            junimo.EventActor = true;
            junimo.flip       = flipped;

            IReflectedField <NetColor> colorF = StardustCore.ModCore.ModHelper.Reflection.GetField <NetColor>(junimo, "color", true);
            NetColor c = colorF.GetValue();

            c.R = color.R;
            c.G = color.G;
            c.B = color.B;
            colorF.SetValue(c);

            actors.Add((NPC)junimo);
            ++Game1.CurrentEvent.CurrentCommand; //I've been told ++<int> is more efficient than <int>++;
        }
Example #2
0
        public void SpawnJunimos(int maxJunimosToSpawn = -1)
        {
            if (!harvestedToday || harvestedTiles.Count == 0)
            {
                return;
            }

            if (maxJunimosToSpawn == -1)
            {
                maxJunimosToSpawn = harvestedTiles.Count / 2;
            }

            int junimosToSpawnUpper = System.Math.Min(harvestedTiles.Count, maxJunimosToSpawn);

            for (int x = 0; x < Game1.random.Next(junimosToSpawnUpper / 4, junimosToSpawnUpper); x++)
            {
                Vector2 tile = location.getRandomTile();

                if (!location.isTileLocationTotallyClearAndPlaceable(tile) || !(location.doesTileHaveProperty((int)tile.X, (int)tile.Y, "Type", "Back") == "Wood" || location.doesTileHaveProperty((int)tile.X, (int)tile.Y, "Type", "Back") == "Stone"))
                {
                    continue;
                }

                Junimo j = new Junimo(tile * 64f, 6, false);
                if (!location.isCollidingPosition(j.GetBoundingBox(), Game1.viewport, j))
                {
                    location.characters.Add(j);
                }

                //monitor.Log($"Spawning some Junimos at {location.Name}: {tile.X}, {tile.Y}.", LogLevel.Debug);
            }
            Game1.playSound("tinyWhip");

            hasSpawnedJunimos = true;
        }
Example #3
0
        public static void Junimo_ctor_Postfix(
            Junimo __instance,
            Vector2 position,
            int whichArea)
        {
            if (whichArea >= Bundles.CustomAreaInitialIndex &&
                !Bundles.IsAbandonedJojaMartBundleAvailableOrComplete())
            {
                CustomCommunityCentre.Data.BundleMetadata bundleMetadata = Bundles.GetAllCustomBundleMetadataEntries()
                                                                           .First(bmd => Bundles.GetCustomAreaNumberFromName(bmd.AreaName) == whichArea);

                __instance.friendly.Value = Bundles.IsAreaComplete(cc: Bundles.CC, areaNumber: whichArea);

                int restoreAreaPhase = Reflection.GetField
                                       <int>
                                           (obj: Bundles.CC, name: "restoreAreaPhase")
                                       .GetValue();
                if (restoreAreaPhase != CommunityCenter.PHASE_junimoAppear)
                {
                    Reflection.GetField
                    <Netcode.NetColor>
                        (obj: __instance, name: "color")
                    .GetValue()
                    .Set(bundleMetadata.Colour);
                }
            }
        }
Example #4
0
 public override void drawAboveAlwaysFrontLayer(SpriteBatch b)
 {
     base.drawAboveAlwaysFrontLayer(b);
     if (this.messageAlpha > 0f)
     {
         Junimo junimoForArea = this.getJunimoForArea(0);
         if (junimoForArea != null)
         {
             b.Draw(junimoForArea.Sprite.Texture, new Vector2((float)(Game1.viewport.Width / 2 - Game1.tileSize / 2), (float)(Game1.viewport.Height * 2) / 3f - (float)Game1.tileSize), new Microsoft.Xna.Framework.Rectangle?(new Microsoft.Xna.Framework.Rectangle((int)(Game1.currentGameTime.TotalGameTime.TotalMilliseconds % 800.0) / 100 * 16, 0, 16, 16)), Color.Lime * this.messageAlpha, 0f, new Vector2((float)(junimoForArea.sprite.spriteWidth * Game1.pixelZoom / 2), (float)(junimoForArea.sprite.spriteHeight * Game1.pixelZoom) * 3f / 4f) / (float)Game1.pixelZoom, Math.Max(0.2f, 1f) * (float)Game1.pixelZoom, junimoForArea.flip ? SpriteEffects.FlipHorizontally : SpriteEffects.None, 1f);
         }
         b.DrawString(Game1.dialogueFont, "\"" + Game1.parseText(this.getMessageForAreaCompletion() + "\"", Game1.dialogueFont, Game1.tileSize * 10), new Vector2((float)(Game1.viewport.Width / 2 - Game1.tileSize * 5), (float)(Game1.viewport.Height * 2) / 3f), Game1.textColor * this.messageAlpha * 0.6f);
     }
 }
Example #5
0
        public Junimo getJunimoForArea(int whichArea)
        {
            foreach (Character character in this.characters)
            {
                if (character is Junimo && (character as Junimo).whichArea == whichArea)
                {
                    return(character as Junimo);
                }
            }
            Junimo junimo = new Junimo(Vector2.Zero, whichArea, false);

            this.addCharacter((NPC)junimo);
            return(junimo);
        }
Example #6
0
        public Junimo getJunimoForArea(int whichArea)
        {
            foreach (Character current in this.characters)
            {
                if (current is Junimo && (current as Junimo).whichArea == whichArea)
                {
                    return(current as Junimo);
                }
            }
            Junimo junimo = new Junimo(Vector2.Zero, whichArea, false);

            base.addCharacter(junimo);
            return(junimo);
        }
Example #7
0
        /****
        ** Get metadata
        ****/
        /// <summary>Get the subject type for an NPC.</summary>
        /// <param name="npc">The NPC instance.</param>
        public SubjectType GetSubjectType(NPC npc)
        {
            if (npc.isVillager())
            {
                return(SubjectType.Villager);
            }

            return(npc switch
            {
                Child _ => SubjectType.Villager,
                Horse _ => SubjectType.Horse,
                Junimo _ => SubjectType.Junimo,
                Pet _ => SubjectType.Pet,
                Monster _ => SubjectType.Monster,
                _ => SubjectType.Unknown
            });
        internal static void SpawnJunimo(StardewValley.GameLocation location, Vector2 tile)
        {
            if (!location.isTileLocationTotallyClearAndPlaceable(tile))
            {
                return;
            }

            Junimo j = new Junimo(tile * 64f, 6, false);

            if (!location.isCollidingPosition(j.GetBoundingBox(), Game1.viewport, j))
            {
                location.characters.Add(j);
            }

            Game1.playSound("junimoMeep1");
        }
Example #9
0
        public static void UpdateTick()
        {
            if (!Context.CanPlayerMove || Game1.CurrentEvent != null || Game1.isFestival() || Game1.weddingToday)
            {
                return;
            }

            // Spawns Up to three per tick
            for (int i = 0; i < 3; i++)
            {
                if (SpawnList_AroundPlayer.Count > 0 && canSpawn())
                {
                    bool flag = false;
                    NPC  npc  = SpawnList_AroundPlayer.Keys.ElementAt(0);
                    if (npc is Monster)
                    {
                        Monster m = (Monster)npc;
                        flag = tryToSpawnNPC(npc, SpawnList_AroundPlayer.Values.ElementAt(0), getRangeFromPlayer(10, 4));
                    }
                    else if (npc is Junimo)
                    {
                        Junimo j = (Junimo)npc;
                        j.stayPut.Value = false;
                        flag            = tryToSpawnNPC(j, SpawnList_AroundPlayer.Values.ElementAt(0), getRangeFromPlayer(8));
                    }

                    if (flag)
                    {
                        SpawnList_AroundPlayer.Remove(SpawnList_AroundPlayer.Keys.ElementAt(0));
                    }
                }
                else
                {
                    break;
                }
            }
        }
Example #10
0
        public override void UpdateWhenCurrentLocation(GameTime time)
        {
            base.UpdateWhenCurrentLocation(time);
            if (this.restoreAreaTimer > 0)
            {
                int restoreAreaTimer = this.restoreAreaTimer;
                this.restoreAreaTimer = this.restoreAreaTimer - time.ElapsedGameTime.Milliseconds;
                switch (this.restoreAreaPhase)
                {
                case 0:
                    if (this.restoreAreaTimer > 0)
                    {
                        break;
                    }
                    this.restoreAreaTimer = 3000;
                    this.restoreAreaPhase = 1;
                    Game1.player.faceDirection(2);
                    Game1.player.jump();
                    Game1.player.jitterStrength = 1f;
                    Game1.player.showFrame(94, false);
                    break;

                case 1:
                    if (Game1.random.NextDouble() < 0.4)
                    {
                        Vector2 positionInThisRectangle = Utility.getRandomPositionInThisRectangle(this.getAreaBounds(this.restoreAreaIndex), Game1.random);
                        Junimo  junimo = new Junimo(positionInThisRectangle * (float)Game1.tileSize, this.restoreAreaIndex, true);
                        if (!this.isCollidingPosition(junimo.GetBoundingBox(), Game1.viewport, (Character)junimo))
                        {
                            this.characters.Add((NPC)junimo);
                            this.temporarySprites.Add(new TemporaryAnimatedSprite(Game1.random.NextDouble() < 0.5 ? 5 : 46, positionInThisRectangle * (float)Game1.tileSize + new Vector2((float)(Game1.tileSize / 4), (float)(Game1.tileSize / 4)), Color.White, 8, false, 100f, 0, -1, -1f, -1, 0)
                            {
                                layerDepth = 1f
                            });
                            Game1.playSound("tinyWhip");
                        }
                    }
                    if (this.restoreAreaTimer <= 0)
                    {
                        this.restoreAreaTimer = 999999;
                        this.restoreAreaPhase = 2;
                        Game1.screenGlowOnce(Color.White, true, 0.005f, 1f);
                        if (Game1.soundBank != null)
                        {
                            this.buildUpSound = Game1.soundBank.GetCue("wind");
                            this.buildUpSound.SetVariable("Volume", 0.0f);
                            this.buildUpSound.SetVariable("Frequency", 0.0f);
                            this.buildUpSound.Play();
                        }
                        Game1.player.jitterStrength = 2f;
                        Game1.player.stopShowingFrame();
                    }
                    Game1.drawLighting = false;
                    break;

                case 2:
                    if (this.buildUpSound != null)
                    {
                        this.buildUpSound.SetVariable("Volume", Game1.screenGlowAlpha * 150f);
                        this.buildUpSound.SetVariable("Frequency", Game1.screenGlowAlpha * 150f);
                    }
                    if ((double)Game1.screenGlowAlpha >= (double)Game1.screenGlowMax)
                    {
                        this.messageAlpha = this.messageAlpha + 0.008f;
                        this.messageAlpha = Math.Min(this.messageAlpha, 1f);
                    }
                    if ((double)Game1.screenGlowAlpha == (double)Game1.screenGlowMax && this.restoreAreaTimer > 5200)
                    {
                        this.restoreAreaTimer = 5200;
                    }
                    if (this.restoreAreaTimer < 5200 && Game1.random.NextDouble() < (double)(5200 - this.restoreAreaTimer) / 10000.0)
                    {
                        Game1.playSound(Game1.random.NextDouble() < 0.5 ? "dustMeep" : "junimoMeep1");
                    }
                    if (this.restoreAreaTimer > 0)
                    {
                        break;
                    }
                    this.restoreAreaTimer = 2000;
                    this.restoreAreaPhase = 3;
                    Game1.screenGlowHold  = false;
                    this.loadArea(this.restoreAreaIndex, true);
                    if (this.buildUpSound != null)
                    {
                        this.buildUpSound.Stop(AudioStopOptions.Immediate);
                    }
                    Game1.playSound("wand");
                    Game1.changeMusicTrack("junimoStarSong");
                    Game1.playSound("woodyHit");
                    this.messageAlpha = 0.0f;
                    Game1.flashAlpha  = 1f;
                    Game1.player.stopJittering();
                    for (int index = this.characters.Count - 1; index >= 0; --index)
                    {
                        if (this.characters[index] is Junimo && (this.characters[index] as Junimo).temporaryJunimo)
                        {
                            this.characters.RemoveAt(index);
                        }
                    }
                    Game1.drawLighting = true;
                    break;

                case 3:
                    if (restoreAreaTimer > 1000 && this.restoreAreaTimer <= 1000)
                    {
                        Junimo junimoForArea = this.getJunimoForArea(this.restoreAreaIndex);
                        if (junimoForArea != null)
                        {
                            junimoForArea.position = Utility.getRandomAdjacentOpenTile(Game1.player.getTileLocation()) * (float)Game1.tileSize;
                            int num;
                            for (num = 0; this.isCollidingPosition(junimoForArea.GetBoundingBox(), Game1.viewport, (Character)junimoForArea) && num < 20; ++num)
                            {
                                junimoForArea.position = Utility.getRandomPositionInThisRectangle(this.getAreaBounds(this.restoreAreaIndex), Game1.random);
                            }
                            if (num < 20)
                            {
                                junimoForArea.fadeBack();
                                junimoForArea.returnToJunimoHutToFetchStar((GameLocation)this);
                            }
                        }
                    }
                    if (this.restoreAreaTimer > 0)
                    {
                        break;
                    }
                    Game1.freezeControls = false;
                    break;
                }
            }
            else
            {
                if (Game1.activeClickableMenu != null || this.junimoNotesViewportTargets == null || (this.junimoNotesViewportTargets.Count <= 0 || Game1.isViewportOnCustomPath()))
                {
                    return;
                }
                this.setViewportToNextJunimoNoteTarget();
            }
        }
        public static bool UpdateWhenCurrentLocation_Prefix(CommunityCenter __instance, GameTime time)
        {
            try
            {
                var index      = ModEntry.Instance.Helper.Reflection.GetField <int>(__instance, "restoreAreaIndex").GetValue();
                var timerField = ModEntry.Instance.Helper.Reflection.GetField <int>(__instance, "restoreAreaTimer");
                var timer      = timerField.GetValue();
                var phaseField = ModEntry.Instance.Helper.Reflection.GetField <int>(__instance, "restoreAreaPhase");
                var phase      = phaseField.GetValue();

                if (timer == 0 || !Bundles.IsCommunityCentreKitchenEnabledByHost())
                {
                    return(true);
                }

                if (index != Bundles.CommunityCentreAreaNumber)
                {
                    // Reload the incomplete custom bundle area if the Pantry was just completed, as it overrides the area
                    if (phase == 3 && timer == 2000 && Game1.IsMasterGame && Game1.currentLocation is CommunityCenter &&
                        index == 0 &&
                        __instance.areasComplete.Count > Bundles.CommunityCentreAreaNumber &&
                        !__instance.areasComplete[Bundles.CommunityCentreAreaNumber])
                    {
                        Bundles.CheckAndTryToUnrenovateKitchen();
                    }
                    return(true);
                }

                var messageAlphaField          = ModEntry.Instance.Helper.Reflection.GetField <float>(__instance, "messageAlpha");
                var messageAlpha               = messageAlphaField.GetValue();
                var buildUpSound               = ModEntry.Instance.Helper.Reflection.GetField <ICue>(__instance, "buildUpSound").GetValue();
                var junimoNotesViewportTargets = ModEntry.Instance.Helper.Reflection.GetField <List <int> >(__instance, "junimoNotesViewportTargets").GetValue();

                __instance.missedRewardsChest.Value.updateWhenCurrentLocation(time, __instance);

                if (timer > 0)
                {
                    var old = timer;
                    timer -= time.ElapsedGameTime.Milliseconds;
                    switch (phase)
                    {
                    case 0:
                        if (timer <= 0)
                        {
                            timer = 3000;
                            phase = 1;
                            if (Game1.player.currentLocation == __instance)
                            {
                                Game1.player.faceDirection(2);
                                Game1.player.jump();
                                Game1.player.jitterStrength = 1f;
                                Game1.player.showFrame(94);

                                // THIS IS AN IMPORTANT BIT:
                                // Add some mail to flag this bundle as having been completed
                                Log.D($"Sending mail for Cooking bundle completion ({ModEntry.MailKitchenCompleted})",
                                      ModEntry.Instance.Config.DebugMode);
                                Game1.player.mailForTomorrow.Add(ModEntry.MailKitchenCompleted + "%&NL&%");
                            }
                        }
                        break;

                    case 1:
                        if (Game1.IsMasterGame && Game1.random.NextDouble() < 0.4)
                        {
                            var area = new Rectangle(Bundles.CommunityCentreArea.X, Bundles.CommunityCentreArea.Y,
                                                     Bundles.CommunityCentreArea.Width + 12, Bundles.CommunityCentreArea.Height + 6);
                            var v = Utility.getRandomPositionInThisRectangle(area, Game1.random);
                            var i = new Junimo(v * 64f, index, temporary: true);
                            if (!__instance.isCollidingPosition(i.GetBoundingBox(), Game1.viewport, i))
                            {
                                __instance.characters.Add(i);
                                ModEntry.Instance.Helper.Reflection.GetField <Multiplayer>(
                                    typeof(Game1), "multiplayer").GetValue().broadcastSprites(__instance,
                                                                                              new TemporaryAnimatedSprite((Game1.random.NextDouble() < 0.5) ? 5 : 46,
                                                                                                                          v * 64f + new Vector2(16f, 16f), Color.White)
                                {
                                    layerDepth = 1f
                                });
                                __instance.localSound("tinyWhip");
                            }
                        }
                        if (timer <= 0)
                        {
                            timer = 999999;
                            phase = 2;
                            if (Game1.player.currentLocation != __instance)
                            {
                                break;
                            }
                            Game1.screenGlowOnce(Color.White, hold: true, 0.005f, 1f);
                            if (Game1.soundBank != null)
                            {
                                buildUpSound = Game1.soundBank.GetCue("wind");
                                buildUpSound.SetVariable("Volume", 0f);
                                buildUpSound.SetVariable("Frequency", 0f);
                                buildUpSound.Play();
                            }
                            Game1.player.jitterStrength = 2f;
                            Game1.player.stopShowingFrame();
                        }
                        Game1.drawLighting = false;
                        break;

                    case 2:
                        if (buildUpSound != null)
                        {
                            buildUpSound.SetVariable("Volume", Game1.screenGlowAlpha * 150f);
                            buildUpSound.SetVariable("Frequency", Game1.screenGlowAlpha * 150f);
                        }
                        if (Game1.screenGlowAlpha >= Game1.screenGlowMax)
                        {
                            messageAlpha += 0.008f;
                            messageAlpha  = Math.Min(messageAlpha, 1f);
                        }
                        if ((Game1.screenGlowAlpha == Game1.screenGlowMax ||
                             Game1.currentLocation != __instance) && timer > 5200)
                        {
                            timer = 5200;
                        }
                        if (timer < 5200 && Game1.random.NextDouble() < (5200 - timer) / 10000f)
                        {
                            __instance.localSound((Game1.random.NextDouble() < 0.5) ? "dustMeep" : "junimoMeep1");
                        }
                        if (timer > 0)
                        {
                            break;
                        }
                        timer        = 2000;
                        messageAlpha = 0f;
                        phase        = 3;
                        if (Game1.IsMasterGame)
                        {
                            for (var j = __instance.characters.Count - 1; j >= 0; j--)
                            {
                                if (__instance.characters[j] is Junimo &&
                                    (__instance.characters[j] as Junimo).temporaryJunimo.Value)
                                {
                                    __instance.characters.RemoveAt(j);
                                }
                            }
                        }
                        if (Game1.player.currentLocation == __instance)
                        {
                            Game1.screenGlowHold = false;
                            __instance.loadArea(index);
                            if (buildUpSound != null)
                            {
                                buildUpSound.Stop(AudioStopOptions.Immediate);
                            }
                            __instance.localSound("wand");
                            Game1.changeMusicTrack("junimoStarSong");
                            __instance.localSound("woodyHit");
                            Game1.flashAlpha = 1f;
                            Game1.player.stopJittering();
                            Game1.drawLighting = true;
                        }
                        break;

                    case 3:
                        if (old > 1000 && timer <= 1000)
                        {
                            var junimo = __instance.getJunimoForArea(index);
                            if (junimo != null && Game1.IsMasterGame)
                            {
                                if (!junimo.holdingBundle.Value)
                                {
                                    junimo.Position = Utility.getRandomAdjacentOpenTile(Utility.PointToVector2(Bundles.CommunityCentreNotePosition), __instance) * 64f;
                                    var iter = 0;
                                    while (__instance.isCollidingPosition(junimo.GetBoundingBox(), Game1.viewport, junimo) && iter < 20)
                                    {
                                        junimo.Position = Utility.getRandomPositionInThisRectangle(Bundles.CommunityCentreArea, Game1.random) * 64f;
                                        iter++;
                                    }
                                    if (iter < 20)
                                    {
                                        junimo.fadeBack();
                                    }
                                }
                                junimo.returnToJunimoHutToFetchStar(__instance);
                            }
                        }
                        if (timer <= 0 && !ModEntry.Instance.Helper.Reflection.GetField <bool>(
                                __instance, "_isWatchingJunimoGoodbye").GetValue())
                        {
                            Game1.freezeControls = false;
                        }
                        break;
                    }
                }
                else if (Game1.activeClickableMenu == null && junimoNotesViewportTargets != null &&
                         junimoNotesViewportTargets.Count > 0 && !Game1.isViewportOnCustomPath())
                {
                    ModEntry.Instance.Helper.Reflection.GetMethod(__instance, "setViewportToNextJunimoNoteTarget").Invoke();
                }

                timerField.SetValue(timer);
                phaseField.SetValue(phase);
                messageAlphaField.SetValue(messageAlpha);

                return(false);
            }
            catch (Exception e)
            {
                Log.E($"Error in {nameof(UpdateWhenCurrentLocation_Prefix)}:\n{e}");
            }
            return(true);
        }
Example #12
0
        // Token: 0x060010CA RID: 4298 RVA: 0x00157770 File Offset: 0x00155970
        public override void UpdateWhenCurrentLocation(GameTime time)
        {
            base.UpdateWhenCurrentLocation(time);
            if (this.restoreAreaTimer > 0)
            {
                int old = this.restoreAreaTimer;
                this.restoreAreaTimer -= time.ElapsedGameTime.Milliseconds;
                switch (this.restoreAreaPhase)
                {
                case 0:
                    if (this.restoreAreaTimer <= 0)
                    {
                        this.restoreAreaTimer = 3000;
                        this.restoreAreaPhase = 1;
                        Game1.player.faceDirection(2);
                        Game1.player.jump();
                        Game1.player.jitterStrength = 1f;
                        Game1.player.showFrame(94, false);
                        return;
                    }
                    break;

                case 1:
                    if (Game1.random.NextDouble() < 0.4)
                    {
                        Vector2 v = Utility.getRandomPositionInThisRectangle(this.getAreaBounds(this.restoreAreaIndex), Game1.random);
                        Junimo  i = new Junimo(v * (float)Game1.tileSize, this.restoreAreaIndex, true);
                        if (!base.isCollidingPosition(i.GetBoundingBox(), Game1.viewport, i))
                        {
                            this.characters.Add(i);
                            this.temporarySprites.Add(new TemporaryAnimatedSprite((Game1.random.NextDouble() < 0.5) ? 5 : 46, v * (float)Game1.tileSize + new Vector2((float)(Game1.tileSize / 4), (float)(Game1.tileSize / 4)), Color.White, 8, false, 100f, 0, -1, -1f, -1, 0)
                            {
                                layerDepth = 1f
                            });
                            Game1.playSound("tinyWhip");
                        }
                    }
                    if (this.restoreAreaTimer <= 0)
                    {
                        this.restoreAreaTimer = 999999;
                        this.restoreAreaPhase = 2;
                        Game1.screenGlowOnce(Color.White, true, 0.005f, 1f);
                        if (Game1.soundBank != null)
                        {
                            this.buildUpSound = Game1.soundBank.GetCue("wind");
                            this.buildUpSound.SetVariable("Volume", 0f);
                            this.buildUpSound.SetVariable("Frequency", 0f);
                            this.buildUpSound.Play();
                        }
                        Game1.player.jitterStrength = 2f;
                        Game1.player.stopShowingFrame();
                    }
                    Game1.drawLighting = false;
                    return;

                case 2:
                    if (this.buildUpSound != null)
                    {
                        this.buildUpSound.SetVariable("Volume", Game1.screenGlowAlpha * 150f);
                        this.buildUpSound.SetVariable("Frequency", Game1.screenGlowAlpha * 150f);
                    }
                    if (Game1.screenGlowAlpha >= Game1.screenGlowMax)
                    {
                        this.messageAlpha += 0.008f;
                        this.messageAlpha  = Math.Min(this.messageAlpha, 1f);
                    }
                    if (Game1.screenGlowAlpha == Game1.screenGlowMax && this.restoreAreaTimer > 5200)
                    {
                        this.restoreAreaTimer = 5200;
                    }
                    if (this.restoreAreaTimer < 5200 && Game1.random.NextDouble() < (double)((float)(5200 - this.restoreAreaTimer) / 10000f))
                    {
                        Game1.playSound((Game1.random.NextDouble() < 0.5) ? "dustMeep" : "junimoMeep1");
                    }
                    if (this.restoreAreaTimer <= 0)
                    {
                        this.restoreAreaTimer = 2000;
                        this.restoreAreaPhase = 3;
                        Game1.screenGlowHold  = false;
                        this.loadArea(this.restoreAreaIndex, true);
                        if (this.buildUpSound != null)
                        {
                            this.buildUpSound.Stop(AudioStopOptions.Immediate);
                        }
                        Game1.playSound("wand");
                        Game1.changeMusicTrack("junimoStarSong");
                        Game1.playSound("woodyHit");
                        this.messageAlpha = 0f;
                        Game1.flashAlpha  = 1f;
                        Game1.player.stopJittering();
                        for (int j = this.characters.Count - 1; j >= 0; j--)
                        {
                            if (this.characters[j] is Junimo && (this.characters[j] as Junimo).temporaryJunimo)
                            {
                                this.characters.RemoveAt(j);
                            }
                        }
                        Game1.drawLighting = true;
                        return;
                    }
                    break;

                case 3:
                    if (old > 1000 && this.restoreAreaTimer <= 1000)
                    {
                        Junimo k = this.getJunimoForArea(this.restoreAreaIndex);
                        if (k != null)
                        {
                            k.position = Utility.getRandomAdjacentOpenTile(Game1.player.getTileLocation()) * (float)Game1.tileSize;
                            int iter = 0;
                            while (base.isCollidingPosition(k.GetBoundingBox(), Game1.viewport, k) && iter < 20)
                            {
                                k.position = Utility.getRandomPositionInThisRectangle(this.getAreaBounds(this.restoreAreaIndex), Game1.random);
                                iter++;
                            }
                            if (iter < 20)
                            {
                                k.fadeBack();
                                k.returnToJunimoHutToFetchStar(this);
                            }
                        }
                    }
                    if (this.restoreAreaTimer <= 0)
                    {
                        Game1.freezeControls = false;
                        return;
                    }
                    break;

                default:
                    return;
                }
            }
            else if (Game1.activeClickableMenu == null && this.junimoNotesViewportTargets != null && this.junimoNotesViewportTargets.Count > 0 && !Game1.isViewportOnCustomPath())
            {
                this.setViewportToNextJunimoNoteTarget();
            }
        }
Example #13
0
        public void update()
        {
            if (Game1.CurrentEvent == null)
            {
                return;
            }
            else
            {
                if (this.finished)
                {
                    return;
                }
                Junimo junimo = (Junimo)Game1.CurrentEvent.actors.Find(i => i.Name.Equals(this.junimoActorID));
                if (junimo == null)
                {
                    return;
                }
                Point nextPoint = this.getNextPoint();
                if (this.finished)
                {
                    return;
                }

                if (nextPoint.X > this.getCurrentPoint().X)
                {
                    junimo.flip = false;

                    //junimo.Sprite.Animate(Game1.currentGameTime, 0, 8, 50f);
                    if (junimo.Sprite.CurrentAnimation == null)
                    {
                        junimo.Sprite.Animate(Game1.currentGameTime, 16, 8, 50f);
                    }
                }
                if (nextPoint.X < this.getCurrentPoint().X)
                {
                    junimo.flip = true;

                    //junimo.Sprite.Animate(Game1.currentGameTime, 0, 8, 50f);
                    if (junimo.Sprite.CurrentAnimation == null)
                    {
                        junimo.Sprite.Animate(Game1.currentGameTime, 16, 8, 50f);
                    }
                }
                if (nextPoint.Y < this.getCurrentPoint().Y)
                {
                    junimo.flip = false;

                    //junimo.Sprite.Animate(Game1.currentGameTime, 0, 8, 50f);
                    if (junimo.Sprite.CurrentAnimation == null)
                    {
                        junimo.Sprite.Animate(Game1.currentGameTime, 32, 8, 50f);
                    }
                }
                if (nextPoint.Y > this.getCurrentPoint().Y)
                {
                    junimo.flip = false;

                    if (junimo.Sprite.CurrentAnimation == null)
                    {
                        junimo.Sprite.Animate(Game1.currentGameTime, 0, 8, 50f);
                    }
                }



                junimo.Position = Vector2.Lerp(new Vector2(this.getCurrentPoint().X, this.getCurrentPoint().Y), new Vector2(nextPoint.X, nextPoint.Y), (float)((float)this.currentFrameAmount / (float)this.maxFrames));

                ++this.currentFrameAmount;

                if (this.currentFrameAmount >= this.maxFrames)
                {
                    this.currentFrameAmount = 0;
                    this.currentIndex++;
                    junimo.Sprite.StopAnimation();
                    if (this.currentIndex >= this.points.Count)
                    {
                        if (this.loop == false)
                        {
                            this.finished = true;
                        }
                        else
                        {
                            this.currentIndex = 0;
                        }
                    }
                }
            }
        }