Mini Galaxy Gen

Added flags to game manager and player settings to check tutorial status
Created alternate galaxy generation process for tutorial
This commit is contained in:
Reinier Vens 2021-04-22 02:53:06 +01:00
commit b1bd89a687
224 changed files with 423 additions and 208 deletions

View file

@ -65,6 +65,7 @@ public class ActionGameManager : MonoBehaviour
}
public static Sector CurrentSector;
public static bool IsTutorial;
public GameSettings Settings;
//public string StarterShipTemplate = "Longinus";
@ -186,6 +187,10 @@ public class ActionGameManager : MonoBehaviour
public void SaveState()
{
PlayerSettings.SavedRun = CurrentSector == null ? null : new SavedGame(CurrentSector, Zone, DockedEntity ?? CurrentEntity);
if(PlayerSettings.SavedRun != null)
{
PlayerSettings.SavedRun.IsTutorial = IsTutorial;
}
SavePlayerSettings();
}
@ -457,12 +462,16 @@ public class ActionGameManager : MonoBehaviour
{
var nearestFaction = CurrentSector.Factions.MinBy(f => CurrentSector.HomeZones[f].Distance[Zone.SectorZone]);
var loadoutGenerator = new LoadoutGenerator(
var loadoutGenerator = IsTutorial ? new LoadoutGenerator(
ref ItemManager.Random,
ItemManager,
CurrentSector,
Zone.SectorZone,
nearestFaction,
.5f) : new LoadoutGenerator(
ref ItemManager.Random,
ItemManager,
nearestFaction,
.5f);
var turret = EntitySerializer.Unpack(ItemManager, Zone, loadoutGenerator.GenerateTurretLoadout(), true);
@ -473,47 +482,47 @@ public class ActionGameManager : MonoBehaviour
turret.Activate();
});
ConsoleController.AddCommand("pingscene",
_ =>
{
var startTime = Time.time;
Observable.EveryUpdate().TakeWhile(_ => Time.time - startTime < 5).Subscribe(
_ => Debug.Log($"{(int) (Time.time - startTime)}"),
() =>
{
var nearestFaction = CurrentSector.Factions.MinBy(f => CurrentSector.HomeZones[f].Distance[Zone.SectorZone]);
var nearestFactionHomeZone = CurrentSector.HomeZones[nearestFaction];
var factionPresence = nearestFaction.InfluenceDistance - nearestFactionHomeZone.Distance[Zone.SectorZone] + 1;
var loadoutGenerator = new LoadoutGenerator(
ref ItemManager.Random,
ItemManager,
CurrentSector,
Zone.SectorZone,
nearestFaction,
.5f);
for (int i = 0; i < 8; i++)
{
var ship = EntitySerializer.Unpack(ItemManager, Zone, loadoutGenerator.GenerateShipLoadout(), true);
ship.Position.xz = _currentEntity.Position.xz +
ItemManager.Random.NextFloat2Direction() * ItemManager.Random.NextFloat(50, 500);
ship.Zone = Zone;
Zone.Entities.Add(ship);
ship.Activate();
}
for (int i = 0; i < 8; i++)
{
var turret = EntitySerializer.Unpack(ItemManager, Zone, loadoutGenerator.GenerateTurretLoadout(), true);
turret.Position.xz = _currentEntity.Position.xz +
ItemManager.Random.NextFloat2Direction() * ItemManager.Random.NextFloat(50, 500);
turret.Zone = Zone;
Zone.Entities.Add(turret);
turret.Activate();
}
});
});
// ConsoleController.AddCommand("pingscene",
// _ =>
// {
// var startTime = Time.time;
// Observable.EveryUpdate().TakeWhile(_ => Time.time - startTime < 5).Subscribe(
// _ => Debug.Log($"{(int) (Time.time - startTime)}"),
// () =>
// {
// var nearestFaction = CurrentSector.Factions.MinBy(f => CurrentSector.HomeZones[f].Distance[Zone.SectorZone]);
// var nearestFactionHomeZone = CurrentSector.HomeZones[nearestFaction];
// var factionPresence = nearestFaction.InfluenceDistance - nearestFactionHomeZone.Distance[Zone.SectorZone] + 1;
//
// var loadoutGenerator = new LoadoutGenerator(
// ref ItemManager.Random,
// ItemManager,
// CurrentSector,
// Zone.SectorZone,
// nearestFaction,
// .5f);
//
// for (int i = 0; i < 8; i++)
// {
// var ship = EntitySerializer.Unpack(ItemManager, Zone, loadoutGenerator.GenerateShipLoadout(), true);
// ship.Position.xz = _currentEntity.Position.xz +
// ItemManager.Random.NextFloat2Direction() * ItemManager.Random.NextFloat(50, 500);
// ship.Zone = Zone;
// Zone.Entities.Add(ship);
// ship.Activate();
// }
//
// for (int i = 0; i < 8; i++)
// {
// var turret = EntitySerializer.Unpack(ItemManager, Zone, loadoutGenerator.GenerateTurretLoadout(), true);
// turret.Position.xz = _currentEntity.Position.xz +
// ItemManager.Random.NextFloat2Direction() * ItemManager.Random.NextFloat(50, 500);
// turret.Zone = Zone;
// Zone.Entities.Add(turret);
// turret.Activate();
// }
// });
// });
}
public void BeginDrag(DragObject dragObject)
@ -584,7 +593,8 @@ public class ActionGameManager : MonoBehaviour
ItemManager,
Settings.ZoneSettings,
CurrentSector,
sectorZone
sectorZone,
IsTutorial
);
sectorZone.Contents = new Zone(ItemManager, Settings.PlanetSettings, sectorZone.PackedContents, sectorZone);
}
@ -682,7 +692,8 @@ public class ActionGameManager : MonoBehaviour
{
SectorMap.QueueZoneReveal(CurrentSector.Entrance.AdjacentZones.Prepend(CurrentSector.Entrance));
PopulateLevel(CurrentSector.Entrance);
var loadoutGenerator = new LoadoutGenerator(ref ItemManager.Random, ItemManager, CurrentSector, Zone.SectorZone, null, 2);
var loadoutGenerator = IsTutorial ? new LoadoutGenerator(ref ItemManager.Random, ItemManager, null, 2) :
new LoadoutGenerator(ref ItemManager.Random, ItemManager, CurrentSector, Zone.SectorZone, null, 2);
var ship = EntitySerializer.Unpack(
ItemManager,
Zone,

View file

@ -25,6 +25,10 @@ public class GameSettings : ScriptableObject
public int AsteroidMeshCount = 5;
public float MinimapAsteroidSize = 3;
public float PlanetRotationSpeed = 1;
public NameGeneratorSettings NameGeneratorSettings;
public TutorialGenerationSettings TutorialGenerationSettings;
public SectorBackgroundSettings TutorialBackgroundSettings;
public SectorBackgroundSettings SectorBackgroundSettings;
public SectorGenerationSettings SectorGenerationSettings;
public BodySettingsCollection[] BodySettingsCollections;
public PlanetSettings PlanetSettings;