Ejemplo n.º 1
0
        public DwarfGate(VolcanoDungeon location, int gate_index, int x, int y, int seed)
            : this()
        {
            locationRef.Value = location;
            tilePosition.X    = x;
            tilePosition.Y    = y;
            gateIndex.Value   = gate_index;
            Random r = new Random(seed);

            if (location.possibleSwitchPositions.ContainsKey(gate_index))
            {
                int max_points = Math.Min(location.possibleSwitchPositions[gate_index].Count, 3);
                if (gate_index > 0)
                {
                    max_points = 1;
                }
                List <Point> points = new List <Point>(location.possibleSwitchPositions[gate_index]);
                Utility.Shuffle(r, points);
                int points_to_choose = r.Next(1, Math.Max(1, max_points));
                points_to_choose = Math.Min(points_to_choose, max_points);
                if (location.isMonsterLevel())
                {
                    points_to_choose = max_points;
                }
                for (int i = 0; i < points_to_choose; i++)
                {
                    switches[points[i]] = false;
                }
            }
            UpdateLocalStates();
            ApplyTiles();
        }
Ejemplo n.º 2
0
        public virtual void ApplyTiles()
        {
            int total_switches         = 0;
            int local_pressed_switches = 0;
            int pressed_switches       = 0;

            foreach (Point point in localSwitches.Keys)
            {
                total_switches++;
                if (switches[point])
                {
                    pressed_switches++;
                }
                if (localSwitches[point])
                {
                    local_pressed_switches++;
                    locationRef.Value.setMapTileIndex(point.X, point.Y, VolcanoDungeon.GetTileIndex(1, 31), "Back");
                    locationRef.Value.removeTileProperty(point.X, point.Y, "Back", "TouchAction");
                }
                else
                {
                    locationRef.Value.setMapTileIndex(point.X, point.Y, VolcanoDungeon.GetTileIndex(0, 31), "Back");
                    locationRef.Value.setTileProperty(point.X, point.Y, "Back", "TouchAction", "DwarfSwitch");
                }
            }
            switch (total_switches)
            {
            case 1:
                locationRef.Value.setMapTileIndex(tilePosition.X - 1, tilePosition.Y, VolcanoDungeon.GetTileIndex(10 + local_pressed_switches, 23), "Buildings");
                break;

            case 2:
                locationRef.Value.setMapTileIndex(tilePosition.X - 1, tilePosition.Y, VolcanoDungeon.GetTileIndex(12 + local_pressed_switches, 23), "Buildings");
                break;

            case 3:
                locationRef.Value.setMapTileIndex(tilePosition.X - 1, tilePosition.Y, VolcanoDungeon.GetTileIndex(10 + local_pressed_switches, 22), "Buildings");
                break;
            }
            if (!triggeredOpen && pressed_switches >= total_switches)
            {
                triggeredOpen = true;
                if (Game1.IsMasterGame)
                {
                    DelayedAction.functionAfterDelay(delegate
                    {
                        openEvent.Fire();
                    }, 500);
                }
            }
            if (localOpened)
            {
                locationRef.Value.removeTile(tilePosition.X, tilePosition.Y + 1, "Buildings");
            }
            else
            {
                locationRef.Value.setMapTileIndex(tilePosition.X, tilePosition.Y + 1, 0, "Buildings");
            }
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Clones all monsters in the given volcano dungeon and places them at the same place as their original
        /// </summary>
        /// <param name="dungeon"></param>
        private void DoubleMonstersInVolcanoDungeon(VolcanoDungeon dungeon)
        {
            var original_characters = new NetCollection <NPC>(dungeon.characters);

            foreach (var character in original_characters)
            {
                // exclude player, dwarf and whatever else might creep up here
                if (character is Monster monster)
                {
                    this.CloneVolcanoDungeonMonster(dungeon, monster);
                }
            }
        }
Ejemplo n.º 4
0
        /// <summary>
        /// Clones the given monster and puts it on the same place as the original
        /// </summary>
        /// <param name="dungeon"></param>
        /// <param name="monster"></param>
        private void CloneVolcanoDungeonMonster(VolcanoDungeon dungeon, Monster monster)
        {
            Monster clone            = null;
            var     originalPosition = monster.Position;

            if (monster is Duggy)
            {
                clone = new Duggy(originalPosition, magmaDuggy: true);
            }
            else if (monster is RockCrab)
            {
                clone = new RockCrab(originalPosition, ModEntry.VolcanoRockCrabName);
            }
            else if (monster is Bat bat)
            {
                var batName = bat.Name;
                if (ModEntry.VolcanoBatNameToMineLevel.ContainsKey(batName))
                {
                    clone = new Bat(originalPosition, ModEntry.VolcanoBatNameToMineLevel[batName]);
                }
            }
            else if (monster is LavaLurk)
            {
                clone = new LavaLurk(originalPosition);
            }
            else if (monster is HotHead)
            {
                clone = new HotHead(originalPosition);
            }
            else if (monster is GreenSlime)
            {
                var greenSlime = new GreenSlime(originalPosition, 0);
                greenSlime.makeTigerSlime();
                clone = greenSlime;
            }
            else if (monster is Spiker spike)
            {
                return;
            }
            if (clone == null)
            {
                this.Monitor.Log($"Cloning of monster \"{monster.Name}\" is not supported.", LogLevel.Warn);
            }
            else
            {
                dungeon.addCharacter(clone);
            }
        }
Ejemplo n.º 5
0
        public static bool performTenMinuteClockUpdate(ref ModHooks ___hooks)
        {
            ___hooks.OnGame1_PerformTenMinuteClockUpdate(() =>
            {
                int trulyDarkTime      = Game1.getTrulyDarkTime();
                Game1.gameTimeInterval = 0;

                if (Game1.IsMasterGame)
                {
                    Game1.timeOfDay++;
                }
                if (Game1.timeOfDay % 10 != 0)
                {
                    if (Game1.IsMasterGame && Game1.farmEvent == null)
                    {
                        Game1.netWorldState.Value.UpdateFromGame1();
                    }
                    return;
                }
                if (Game1.timeOfDay % 100 >= 60)
                {
                    Game1.timeOfDay = Game1.timeOfDay - Game1.timeOfDay % 100 + 100;
                }
                Game1.timeOfDay = Math.Min(Game1.timeOfDay, 2600);
                if (Game1.isLightning && Game1.timeOfDay < 2400 && Game1.IsMasterGame)
                {
                    Utility.performLightningUpdate(Game1.timeOfDay);
                }

                if (Game1.timeOfDay == trulyDarkTime)
                {
                    Game1.currentLocation.switchOutNightTiles();
                }
                else if (Game1.timeOfDay == Game1.getModeratelyDarkTime())
                {
                    if (Game1.currentLocation.IsOutdoors && !Game1.IsRainingHere())
                    {
                        Game1.ambientLight = Color.White;
                    }
                    if (!Game1.IsRainingHere() && !(Game1.currentLocation is MineShaft) && Game1.currentSong != null && !Game1.currentSong.Name.Contains("ambient") && Game1.currentLocation is Town)
                    {
                        Game1.changeMusicTrack("none", false, Game1.MusicContext.Default);
                    }
                }

                if (Game1.getMusicTrackName(Game1.MusicContext.Default).StartsWith(Game1.currentSeason) && !Game1.getMusicTrackName(Game1.MusicContext.Default).Contains("ambient") && !Game1.eventUp && Game1.isDarkOut())
                {
                    Game1.changeMusicTrack("none", true, Game1.MusicContext.Default);
                }
                if (Game1.currentLocation.IsOutdoors && !Game1.IsRainingHere() && !Game1.eventUp && Game1.getMusicTrackName(Game1.MusicContext.Default).Contains("day") && Game1.isDarkOut())
                {
                    Game1.changeMusicTrack("none", true, Game1.MusicContext.Default);
                }
                if (Game1.weatherIcon == 1)
                {
                    int num = Convert.ToInt32(Game1.temporaryContent.Load <Dictionary <string, string> >("Data\\Festivals\\" + Game1.currentSeason + Game1.dayOfMonth)["conditions"].Split('/')[1].Split(' ')[0]);
                    if (Game1.whereIsTodaysFest == null)
                    {
                        Game1.whereIsTodaysFest = Game1.temporaryContent.Load <Dictionary <string, string> >("Data\\Festivals\\" + Game1.currentSeason + Game1.dayOfMonth)["conditions"].Split('/')[0];
                    }
                    if (Game1.timeOfDay == num)
                    {
                        Dictionary <string, string> dictionary = Game1.temporaryContent.Load <Dictionary <string, string> >("Data\\Festivals\\" + Game1.currentSeason + Game1.dayOfMonth);
                        string text = dictionary["conditions"].Split('/')[0];
                        if (dictionary.ContainsKey("locationDisplayName"))
                        {
                            text = dictionary["locationDisplayName"];
                        }
                        else
                        {
                            switch (text)
                            {
                            case "Forest":
                                text = (Game1.currentSeason.Equals("winter") ? Game1.content.LoadString("Strings\\StringsFromCSFiles:Game1.cs.2634") : Game1.content.LoadString("Strings\\StringsFromCSFiles:Game1.cs.2635"));
                                break;

                            case "Town":
                                text = Game1.content.LoadString("Strings\\StringsFromCSFiles:Game1.cs.2637");
                                break;

                            case "Beach":
                                text = Game1.content.LoadString("Strings\\StringsFromCSFiles:Game1.cs.2639");
                                break;
                            }
                        }

                        Game1.showGlobalMessage(Game1.content.LoadString("Strings\\StringsFromCSFiles:Game1.cs.2640", Game1.temporaryContent.Load <Dictionary <string, string> >("Data\\Festivals\\" + Game1.currentSeason + Game1.dayOfMonth)["name"]) + text);
                    }
                }
                Game1.player.performTenMinuteUpdate();
                switch (Game1.timeOfDay)
                {
                case 1200:
                    if ((bool)Game1.currentLocation.isOutdoors && !Game1.IsRainingHere() && (Game1.currentSong == null || Game1.currentSong.IsStopped || Game1.currentSong.Name.ToLower().Contains("ambient")))
                    {
                        Game1.playMorningSong();
                    }

                    break;

                case 2000:
                    if (!Game1.IsRainingHere() && Game1.currentLocation is Town)
                    {
                        Game1.changeMusicTrack("none");
                    }

                    break;

                case 2400:
                    Game1.dayTimeMoneyBox.timeShakeTimer = 2000;
                    Game1.player.doEmote(24);
                    Game1.showGlobalMessage(Game1.content.LoadString("Strings\\StringsFromCSFiles:Game1.cs.2652"));
                    break;

                case 2500:
                    Game1.dayTimeMoneyBox.timeShakeTimer = 2000;
                    Game1.player.doEmote(24);
                    break;

                case 2600:
                    Game1.dayTimeMoneyBox.timeShakeTimer = 2000;
                    if (Game1.player.mount != null)
                    {
                        Game1.player.mount.dismount();
                    }

                    if (Game1.player.IsSitting())
                    {
                        Game1.player.StopSitting(animate: false);
                    }

                    if (Game1.player.UsingTool)
                    {
                        if (Game1.player.CurrentTool != null)
                        {
                            FishingRod fishingRod = Game1.player.CurrentTool as FishingRod;
                            if (fishingRod != null && (fishingRod.isReeling || fishingRod.pullingOutOfWater))
                            {
                                break;
                            }
                        }

                        Game1.player.completelyStopAnimatingOrDoingAction();
                    }

                    break;

                case 2800:
                    if (Game1.activeClickableMenu != null)
                    {
                        Game1.activeClickableMenu.emergencyShutDown();
                        Game1.exitActiveMenu();
                    }

                    Game1.player.startToPassOut();
                    if (Game1.player.mount != null)
                    {
                        Game1.player.mount.dismount();
                    }

                    break;
                }

                foreach (GameLocation location in Game1.locations)
                {
                    GameLocation gameLocation = location;
                    if (gameLocation.NameOrUniqueName == Game1.currentLocation.NameOrUniqueName)
                    {
                        gameLocation = Game1.currentLocation;
                    }

                    gameLocation.performTenMinuteUpdate(Game1.timeOfDay);
                    if (gameLocation is Farm)
                    {
                        ((Farm)gameLocation).timeUpdate(10);
                    }
                }

                MineShaft.UpdateMines10Minutes(Game1.timeOfDay);
                VolcanoDungeon.UpdateLevels10Minutes(Game1.timeOfDay);
                if (Game1.IsMasterGame && Game1.farmEvent == null)
                {
                    Game1.netWorldState.Value.UpdateFromGame1();
                }
            });
            return(false);
        }