public void SetTest() { test_typing.SetActive(true); obtiones.SetActive(false); state = NewGameSettings.in_test; FindObjectOfType <BattleTyper>().Start_typ_test(TestWords, 1000, Time); }
public void Init() { NewGameSettings settings = new NewGameSettings(); settings.MaxSystems = 5; _game = new Game(settings); StaticDataManager.LoadData("Pulsar4x", _game); _player = _game.AddPlayer("Test Player"); _faction = DefaultStartFactory.DefaultHumans(_game, _player, "Test Faction"); _starSystem = _game.Systems.First <KeyValuePair <Guid, StarSystem> >().Value; _planets = _starSystem.SystemManager.GetAllEntitiesWithDataBlob <SystemBodyInfoDB>(); _earth = _planets.Where <Entity>(planet => planet.GetDataBlob <NameDB>().GetName(_faction) == "Earth").First <Entity>(); _ship = _starSystem.SystemManager.GetAllEntitiesWithDataBlob <ShipInfoDB>().First <Entity>(); _shipPropulsionDB = _ship.GetDataBlob <PropulsionDB>(); _target = _ship.Clone(_starSystem.SystemManager); _systems = new List <StarSystem>(); foreach (KeyValuePair <Guid, StarSystem> kvp in _game.Systems) { _systems.Add(kvp.Value); } }
public void TestSelfReferencingEntity() { NameDB name = new NameDB(); Entity testEntity = Entity.Create(_game.GlobalManager, Guid.Empty); name.SetName(testEntity.Guid, "TestName"); testEntity.SetDataBlob(name); //serialise the test entity into a mem stream var mStream = new MemoryStream(); SerializationManager.Export(_game, mStream, testEntity); //create a second game, we're going to import this entity to here (this would be the case in a network game) var settings = new NewGameSettings { GameName = "Test Game2", StartDateTime = DateTime.Now, MaxSystems = 1 }; Game game2 = new Game(settings); //import the entity into the second game. Entity clonedEntity = SerializationManager.ImportEntity(game2, mStream, game2.GlobalManager); mStream.Close(); Assert.IsTrue(testEntity.GetValueCompareHash() == clonedEntity.GetValueCompareHash(), "ValueCompareHash should match");//currently valueCompareHash does not check guid of the entity. I'm undecided wheather it should or not. Entity clonedTest; Assert.IsTrue(game2.GlobalManager.FindEntityByGuid(testEntity.Guid, out clonedTest), "Game2 should have the test entity"); Assert.IsTrue(testEntity.Guid == clonedEntity.Guid, "Guid's need to match, if we get to this assert, then we've got two entities in game2, one of them has the correct guid but no datablobs, the other has a new guid but is complete."); Assert.IsTrue(ReferenceEquals(clonedTest, clonedEntity), "These should be the same object"); Assert.IsTrue(testEntity.DataBlobs.Count == clonedTest.DataBlobs.Count); Assert.IsTrue(testEntity.DataBlobs.Count == clonedEntity.DataBlobs.Count); }
public void CreateGame(NewGameOptionsVM options) { StatusText = "Creating Game..."; // TODO: Databind the GameSettings object in the NewGameOptionsVM var gameSettings = new NewGameSettings { GameName = "Test Game", MaxSystems = options.NumberOfSystems, SMPassword = options.GmPassword, DataSets = options.SelectedModList.Select(dvi => dvi.Directory), CreatePlayerFaction = options.CreatePlayerFaction, DefaultFactionName = options.FactionName, DefaultPlayerPassword = options.FactionPassword, DefaultSolStart = options.DefaultStart, }; Game = new Game(gameSettings); // TODO: Select default player more reliably CurrentPlayer = Game.Players[0]; CurrentAuthToken = new AuthenticationToken(CurrentPlayer, options.FactionPassword); ReadOnlyDictionary <Entity, AccessRole> roles = CurrentPlayer.GetAccessRoles(CurrentAuthToken); CurrentFaction = roles.FirstOrDefault(role => (role.Value & AccessRole.Owner) != 0).Key; StatusText = "Game Created."; StarSystemViewModel = new SystemView.StarSystemVM(this, Game, CurrentFaction); StarSystemViewModel.Initialise(); }
public void Init() { var gameSettings = new NewGameSettings(); gameSettings.MaxSystems = 10; _game = new Game(gameSettings); StaticDataManager.LoadData("Pulsar4x", _game); _entityManager = new EntityManager(_game); }
public void ReturnScore(int characterCount) { test_typing.SetActive(false); obtiones.SetActive(true); caracterCount = characterCount; Debug.Log(characterCount); Debug.Log((characterCount / 5 * 60 / Time).ToString() + "WPM"); WPM_text.text = ("your score: " + characterCount / 5 * 60 / Time).ToString() + "WPM"; state = NewGameSettings.set_optiones; WPM = (characterCount / 5 * 60 / Time); WPM += 5 - WPM % 5; dificulty.value = (WPM - 10) / 90; sliderText.text = WPM.ToString() + " WPM"; }
void Awake() { // DontDestroyOnLoad(gameObject); if (Settings.instance == null) { Settings.instance = this; } else { Debug.LogWarning("A previously awakened Settings MonoBehaviour exists!", gameObject); } if (Settings.newGame == null) { Settings.newGame = _settings; } }
public void Init() { var settings = new NewGameSettings { GameName = "Test Game", StartDateTime = DateTime.Now, MaxSystems = 1 }; _game = new Game(settings); _smAuthToken = new AuthenticationToken(_game.SpaceMaster); _game.GenerateSystems(_smAuthToken, 1); _species1 = Entity.Create(_game.GlobalManager, new List <BaseDataBlob> { new SpeciesDB(1, 0.1, 1.9, 1.0, 0.4, 4, 14, -15, 45) }); _pop1 = new Dictionary <Entity, long> { { _species1, 10 } }; _pop2 = new Dictionary <Entity, long> { { _species1, 5 } }; }
internal TestGame(int numSystems = 10) { GameSettings = new NewGameSettings { GameName = "Unit Test Game", MaxSystems = numSystems, CreatePlayerFaction = false }; Game = new Game(GameSettings); // add a faction: HumanFaction = FactionFactory.CreateFaction(Game, "New Terran Utopian Empire"); // add a species: HumanSpecies = SpeciesFactory.CreateSpeciesHuman(HumanFaction, Game.GlobalManager); // add another faction: GreyAlienFaction = FactionFactory.CreateFaction(Game, "The Grey Empire"); // Add another species: GreyAlienSpecies = SpeciesFactory.CreateSpeciesHuman(GreyAlienFaction, Game.GlobalManager); // Greys Name the Humans. HumanSpecies.GetDataBlob <NameDB>().SetName(GreyAlienFaction.Guid, "Stupid Terrans"); // Humans name the Greys. GreyAlienSpecies.GetDataBlob <NameDB>().SetName(HumanFaction.Guid, "Space bugs"); StarSystemFactory starfac = new StarSystemFactory(Game); Sol = starfac.CreateSol(Game); Earth = NameLookup.GetFirstEntityWithName(Sol, "Earth"); //Sol.Entities[3]; //should be fourth entity created EarthColony = ColonyFactory.CreateColony(HumanFaction, HumanSpecies, Earth); DefaultEngineDesign = DefaultStartFactory.DefaultThrusterDesign(Game, HumanFaction); DefaultWeaponDesign = DefaultStartFactory.DefaultSimpleLaser(Game, HumanFaction); DefaultShipDesign = DefaultStartFactory.DefaultShipDesign(Game, HumanFaction); Vector3 position = Earth.GetDataBlob <PositionDB>().AbsolutePosition_AU; DefaultShip = ShipFactory.CreateShip(DefaultShipDesign, HumanFaction, position, Earth, Sol, "Serial Peacemaker"); Sol.SetDataBlob(DefaultShip.ID, new TransitableDB()); }
internal static Game CreateTestUniverse(int numSystems, DateTime testTime, bool generateDefaultHumans = false) { var gamesettings = new NewGameSettings { GameName = "Unit Test Game", StartDateTime = testTime, MaxSystems = numSystems, DefaultSolStart = generateDefaultHumans, CreatePlayerFaction = false }; var game = new Game(gamesettings); var smAuthToken = new AuthenticationToken(game.SpaceMaster); // Systems are currently generated in the Game Constructor. // Later, Systems will be initialized in the game constructor, but not actually generated until player discovery. //game.GenerateSystems(smAuthToken, numSystems); // add a faction: Entity humanFaction = FactionFactory.CreateFaction(game, "New Terran Utopian Empire"); // add a species: Entity humanSpecies = SpeciesFactory.CreateSpeciesHuman(humanFaction, game.GlobalManager); // add another faction: Entity greyAlienFaction = FactionFactory.CreateFaction(game, "The Grey Empire"); // Add another species: Entity greyAlienSpecies = SpeciesFactory.CreateSpeciesHuman(greyAlienFaction, game.GlobalManager); // Greys Name the Humans. humanSpecies.GetDataBlob <NameDB>().SetName(greyAlienFaction.Guid, "Stupid Terrans"); // Humans name the Greys. greyAlienSpecies.GetDataBlob <NameDB>().SetName(humanFaction.Guid, "Space bugs"); //TODO Expand the "Test Universe" to cover more datablobs and entities. And ships. Etc. if (generateDefaultHumans) { DefaultStartFactory.DefaultHumans(game, "Humans"); } return(game); }
public void ApplySettings(NewGameSettings settings) { newGameSettings = settings; }
/// <summary> /// Initializes the transitioner to create a new game on scene change /// </summary> /// <param name="settings"></param> public void InitNewGame(NewGameSettings settings) { newGameSettings = settings; }
public void Init() { var gameSettings = new NewGameSettings(); gameSettings.MaxSystems = 10; _game = new Game(gameSettings); StaticDataManager.LoadData("Pulsar4x", _game); _entityManager = new EntityManager(_game); _faction = FactionFactory.CreateFaction(_game, "Terran"); // Terrian? /*_galaxyFactory = new GalaxyFactory(); * _starSystemFactory = new StarSystemFactory(_galaxyFactory); * * _starSystem = _starSystemFactory.CreateSol(_game);*/// Seems unnecessary for now _gasDictionary = new Dictionary <string, AtmosphericGasSD>(); foreach (WeightedValue <AtmosphericGasSD> atmos in _game.StaticData.AtmosphericGases) { _gasDictionary.Add(atmos.Value.ChemicalSymbol, atmos.Value); } // Create Earth _earthPlanet = setEarthPlanet(); _coldPlanet = setEarthPlanet(); _hotPlanet = setEarthPlanet(); _lowGravPlanet = setEarthPlanet(); _highGravPlanet = setEarthPlanet(); _coldPlanet.GetDataBlob <SystemBodyInfoDB>().BaseTemperature = -20.0f; _hotPlanet.GetDataBlob <SystemBodyInfoDB>().BaseTemperature = 120.0f; _lowGravPlanet.GetDataBlob <SystemBodyInfoDB>().Gravity = 0.05; _highGravPlanet.GetDataBlob <SystemBodyInfoDB>().Gravity = 5.0; _faction = FactionFactory.CreateFaction(_game, "Terran"); _humanSpecies = SpeciesFactory.CreateSpeciesHuman(_faction, _entityManager); _exampleSpecies = SpeciesFactory.CreateSpeciesHuman(_faction, _entityManager); _lowGravSpecies = SpeciesFactory.CreateSpeciesHuman(_faction, _entityManager); _highGravSpecies = SpeciesFactory.CreateSpeciesHuman(_faction, _entityManager); _lowTempSpecies = SpeciesFactory.CreateSpeciesHuman(_faction, _entityManager); _highTempSpecies = SpeciesFactory.CreateSpeciesHuman(_faction, _entityManager); _humanSpecies.GetDataBlob <SpeciesDB>().TemperatureToleranceRange = 20; _exampleSpecies.GetDataBlob <SpeciesDB>().TemperatureToleranceRange = 20; _lowGravSpecies.GetDataBlob <SpeciesDB>().TemperatureToleranceRange = 20; _highGravSpecies.GetDataBlob <SpeciesDB>().TemperatureToleranceRange = 20; _lowTempSpecies.GetDataBlob <SpeciesDB>().TemperatureToleranceRange = 20; _highTempSpecies.GetDataBlob <SpeciesDB>().TemperatureToleranceRange = 20; _lowGravSpecies.GetDataBlob <SpeciesDB>().BaseGravity = 0.4; _lowGravSpecies.GetDataBlob <SpeciesDB>().MaximumGravityConstraint = 0.5; _lowGravSpecies.GetDataBlob <SpeciesDB>().MinimumGravityConstraint = 0.01; _highGravSpecies.GetDataBlob <SpeciesDB>().BaseGravity = 4.0; _highGravSpecies.GetDataBlob <SpeciesDB>().MaximumGravityConstraint = 5.5; _highGravSpecies.GetDataBlob <SpeciesDB>().MinimumGravityConstraint = 4.5; _lowTempSpecies.GetDataBlob <SpeciesDB>().BaseTemperature = -50.0; _lowTempSpecies.GetDataBlob <SpeciesDB>().MaximumTemperatureConstraint = 0.0; _lowTempSpecies.GetDataBlob <SpeciesDB>().MinimumTemperatureConstraint = -100.0; _highTempSpecies.GetDataBlob <SpeciesDB>().BaseTemperature = 200.0; _highTempSpecies.GetDataBlob <SpeciesDB>().MaximumTemperatureConstraint = 300.0; _highTempSpecies.GetDataBlob <SpeciesDB>().MinimumTemperatureConstraint = 100.0; }