protected override void resetSharedState() { base.resetSharedState(); if ((bool)addedSlimesToday) { return; } addedSlimesToday.Value = true; Random rand = new Random((int)Game1.stats.DaysPlayed + (int)Game1.uniqueIDForThisGame + 12); Microsoft.Xna.Framework.Rectangle spawnArea = new Microsoft.Xna.Framework.Rectangle(13, 15, 7, 6); for (int tries = 5; tries > 0; tries--) { Vector2 tile = Utility.getRandomPositionInThisRectangle(spawnArea, rand); if (isTileLocationTotallyClearAndPlaceable(tile)) { GreenSlime i = new GreenSlime(tile * 64f, 9999899); characters.Add(i); } } if (rand.NextDouble() < 0.5 && isTileLocationTotallyClearAndPlaceable(new Vector2(17f, 18f))) { objects.Add(new Vector2(17f, 18f), new Object(new Vector2(17f, 18f), 56)); } GreenSlime slime2 = new GreenSlime(new Vector2(42f, 34f) * 64f); slime2.makeTigerSlime(); characters.Add(slime2); slime2 = new GreenSlime(new Vector2(38f, 33f) * 64f); slime2.makeTigerSlime(); characters.Add(slime2); }
/// <inheritdoc/> public override void OnWarped(object sender, WarpedEventArgs e) { if (e.NewLocation is not MineShaft && e.NewLocation is not VolcanoDungeon) { return; } var count = Game1.getFarm().buildings.Where(b => (b.owner.Value == e.Player.UniqueMultiplayerID || !Game1.IsMultiplayer) && b.indoors.Value is SlimeHutch && !b.isUnderConstruction() && b.indoors.Value.characters.Any()).Sum(b => b.indoors.Value.characters.Count(npc => npc is GreenSlime)) + Game1.getFarm().characters.Count(npc => npc is GreenSlime); var r = new Random(Guid.NewGuid().GetHashCode()); while (count-- > 0) { var x = r.Next(e.NewLocation.Map.GetLayer("Back").LayerWidth); var y = r.Next(e.NewLocation.Map.GetLayer("Back").LayerHeight); var spawnPosition = new Vector2(x, y); GreenSlime slime; switch (e.NewLocation) { case MineShaft shaft when e.NewLocation is MineShaft: { shaft.checkForMapAlterations(x, y); if (!shaft.isTileClearForMineObjects(spawnPosition) || shaft.isTileOccupied(spawnPosition)) { continue; } slime = new GreenSlime(Vector2.Zero, shaft.mineLevel); if (shaft.GetAdditionalDifficulty() > 0 && r.NextDouble() < Math.Min(shaft.GetAdditionalDifficulty() * 0.1f, 0.5f)) { slime.stackedSlimes.Value = r.NextDouble() < 0.0099999997764825821 ? 4 : 2; } slime.setTilePosition(x, y); shaft.characters.Add(shaft.BuffMonsterIfNecessary(slime)); break; } case VolcanoDungeon dungeon when e.NewLocation is VolcanoDungeon: { if (!e.NewLocation.isTileLocationTotallyClearAndPlaceable(spawnPosition)) { continue; } slime = new GreenSlime(spawnPosition, 1); slime.makeTigerSlime(); dungeon.characters.Add(slime); break; } } } }
/// <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); } }
protected override void resetSharedState() { base.resetSharedState(); if ((bool)addedSlimesToday) { return; } addedSlimesToday.Value = true; Random rand = new Random((int)Game1.stats.DaysPlayed + (int)Game1.uniqueIDForThisGame + 12); Microsoft.Xna.Framework.Rectangle spawnArea = new Microsoft.Xna.Framework.Rectangle(28, 24, 19, 8); for (int tries = 5; tries > 0; tries--) { Vector2 tile = Utility.getRandomPositionInThisRectangle(spawnArea, rand); if (isTileLocationTotallyClearAndPlaceable(tile)) { GreenSlime i = new GreenSlime(tile * 64f, 0); i.makeTigerSlime(); characters.Add(i); } } }