public static void GenerateLoot(int sectorID, out List <Loot> lootList) { var sectorParameters = State.SectorsParameters.Find(x => x.SectorID == sectorID); lootList = new List <Loot>(); List <Artifact> chosenArtifacts = new List <Artifact>(); int artefactsLeft = State.Artifacts.FindAll(artifact => artifact.Status == ArtifactStatus.NotFound && (artifact.Sector == 0 || artifact.Sector == sectorID)).Count; for (int i = 0; i < sectorParameters.LootSpotCount; i++) { var loot = new Loot(); // static artifact spawn rate for now if (Rand.RND.Next(0, 4) == 0 && artefactsLeft > 0) { loot.LootType = LootType.Artefact; var newArtifacts = State.Artifacts.FindAll(artifact => artifact.Status == ArtifactStatus.NotFound && (artifact.Sector == 0 || artifact.Sector == sectorID) && !chosenArtifacts.Contains(artifact)); loot.Artifact = newArtifacts[Rand.RND.Next(0, newArtifacts.Count - 1)]; chosenArtifacts.Add(loot.Artifact); artefactsLeft--; } else { // 33% probability for each not-zero mineral while (true) { LootType[] values = (LootType[])Enum.GetValues(typeof(LootType)); loot.LootType = values[Rand.RND.Next(0, 3)]; int mineralCount = sectorParameters.GetMineralByType(loot.LootType); if (mineralCount != 0) { loot.AddMineralsByType(loot.LootType, mineralCount); break; } } } lootList.Add(loot); } }
public static void GenerateLoot(int sectorID, out List<Loot> lootList) { var sectorParameters = State.SectorsParameters.Find(x => x.SectorID == sectorID); lootList = new List<Loot>(); List<Artifact> chosenArtifacts = new List<Artifact>(); int artefactsLeft = State.Artifacts.FindAll(artifact => artifact.Status == ArtifactStatus.NotFound && (artifact.Sector == 0 || artifact.Sector == sectorID)).Count; for (int i = 0; i < sectorParameters.LootSpotCount; i++) { var loot = new Loot(); // static artifact spawn rate for now if (Rand.RND.Next(0, 4) == 0 && artefactsLeft > 0) { loot.LootType = LootType.Artefact; var newArtifacts = State.Artifacts.FindAll(artifact => artifact.Status == ArtifactStatus.NotFound && (artifact.Sector == 0 || artifact.Sector == sectorID) && !chosenArtifacts.Contains(artifact)); loot.Artifact = newArtifacts[Rand.RND.Next(0, newArtifacts.Count - 1)]; chosenArtifacts.Add(loot.Artifact); artefactsLeft--; } else { // 33% probability for each not-zero mineral while (true) { LootType[] values = (LootType[])Enum.GetValues(typeof(LootType)); loot.LootType = values[Rand.RND.Next(0, 3)]; int mineralCount = sectorParameters.GetMineralByType(loot.LootType); if (mineralCount != 0) { loot.AddMineralsByType(loot.LootType, mineralCount); break; } } } lootList.Add(loot); } }