// Use this for initialization void Awake() { if (instance == null) { instance = this; } else if (instance != this) { Destroy(gameObject); } PersonCreator player = new PersonCreator("RPlayer", "Player", "Player", 0.5f, 1, AINum.player); Body playerBody = (Body)FindObjectOfType(typeof(Body)); //playerBody.AddAffecter(new Fire(playerBody, 40f)); //playerBody.AddAffecter(new Fire(playerBody, 20f)); PersonCreator innkeeper = new PersonCreator("RInnkeeper", "Innkeeper", "Innkeeper", -6.5f, 1, AINum.turret); //List<Item> items = new List<Item> { }; //GameObject packObj = Instantiate(Resources.Load("ItemPackage"), new Vector3(5.5f, 0f), Quaternion.identity) as GameObject; //ItemPackage pack = packObj.GetComponent<ItemPackage>(); //pack.CreateItemPackage(items, "RChest", 5.5f, 2); //Sword sword2 = new Sword(innkeeperBody, 1); DontDestroyOnLoad(gameObject); }
public void Test_Act_ContinueFelling() { Console.WriteLine(""); Console.WriteLine("Preparing test"); Console.WriteLine(""); var context = MockEngineContext.New(); var settings = EngineSettings.DefaultVerbose; settings.FellingRate = 10; var person = new PersonCreator(settings).CreateAdult(); var tile = context.World.Tiles[0]; tile.AddPerson(person); tile.AddTrees(new PlantCreator(context.Settings).CreateTrees(2)); var needEntry = new NeedEntry(ActivityVerb.Fell, ItemType.Wood, PersonVitalType.NotSet, 50, 101); var activity = new FellWoodActivity(person, needEntry, settings, new ConsoleHelper(settings)); activity.Target = tile.Trees [0]; Console.WriteLine(""); Console.WriteLine("Executing target"); Console.WriteLine(""); activity.Act(person); Assert.AreEqual(10, activity.Target.PercentHarvested); }
private void DoCreateTestFileButton_Click(object sender, RoutedEventArgs e) { try { var dialog = new SaveFileDialog(); dialog.FileName = FilePath.Text; dialog.InitialDirectory = Path.GetDirectoryName(FilePath.Text); if (dialog.ShowDialog(this) == true) { List <Person> people = PersonCreator.Work(35); List <Chicken> chickens = ChickenCreator.Work(30); // Passing in LogServiceMessage in optional. I'm using it here to help debug any issues while writing a file. using (var writerService = new ClassToExcelWriterService(LogServiceMessage)) { writerService.AddWorksheet(people, "People", true); writerService.AddWorksheet(chickens, "Chickens", true); writerService.SaveToFile(dialog.FileName); } LogMessage("File saved"); } } catch (Exception ex) { LogError(ex); } }
PersonCreator GetCreator() { IDataFabricator fabricator = new BogusFabricator(); IUserDataAccess userData = new InMemoryUserDataProvider(); PersonCreator creator = new PersonCreator(fabricator, userData); return(creator); }
public ActionResult DelPerson(int id = 0) { MOVIEADVISOREntities6 entities = new MOVIEADVISOREntities6(); PersonCreator creator = new PersonCreator(); creator.RemovePerson(entities.PERSONS.Where(m => m.ID == id).First()); return(RedirectToAction("Index")); }
private void btnGenerateName_Click(object sender, EventArgs e) { string name = string.Empty; PersonCreator personCreator = new PersonCreator(); Person person; person = personCreator.RandomizedPerson(); name = $"{person.FirstName} \"{person.Nickname}\" {person.LastName}"; lblGeneratedName.Text = name; }
public GameEnvironmentPopulator(GameEnvironment world) { World = world; // TODO: Should all these creators be consistent with their constructor parameters? TileCreator = new TileCreator(world); PersonCreator = new PersonCreator(world.Context.Settings); PlantCreator = new PlantCreator(world.Context.Settings); }
public void AddPeopleToTile(GameTile tile, decimal numberOfPeople) { var randomNumber = Random.Next(2); if (randomNumber < numberOfPeople) { var people = PersonCreator.CreateAdults((int)numberOfPeople); tile.AddPeople(people); } }
public ActionResult AddPerson(PersonShow model, string action, string movie = null, string role = null, HttpPostedFileBase foto = null, HttpPostedFileBase poster = null) { MOVIEADVISOREntities6 entities = new MOVIEADVISOREntities6(); PersonCreator creator = new PersonCreator(); model = creator.update(model, action, foto, poster, Server, movie, role); List <SelectListItem> movies = new List <SelectListItem>(); List <SelectListItem> roles = new List <SelectListItem>(); List <MOVIES> tempMoviesHolder = entities.MOVIES.ToList(); foreach (var mov in tempMoviesHolder) { bool isFree = true; foreach (var mov1 in model.moviesList) { if (mov.ID == mov1.movie.ID) { isFree = false; } } if (isFree) { movies.Add(new SelectListItem() { Text = mov.TITLE, Value = mov.ID.ToString() }); } } ViewBag.movies = movies.AsEnumerable(); List <ROLES> tempRolesHolder = entities.ROLES.ToList(); foreach (var rol in tempRolesHolder) { roles.Add(new SelectListItem() { Text = rol.TITLE, Value = rol.ID.ToString() }); } ViewBag.roles = roles.AsEnumerable(); if (action == "Сохранить") { return(RedirectToAction("Index")); } return(View(model)); }
public void CreatePersonFromPersonsCreator() { List <Person> Persons = new List <Person>(); var textParser = new TextParser(); PersonCreator personCreator = new PersonCreator(textParser); var person = FileReader.ReadAllFromDirectory("Persons/"); Assert.IsType <Person>(personCreator.CreatePersonFromFile(person[0])); }
public void SavePersonToFile() { List <Person> Persons = new List <Person>(); var textParser = new TextParser(); PersonCreator personCreator = new PersonCreator(textParser); var person = FileReader.ReadAllFromDirectory("Persons/"); personCreator.SavePersonToFile(personCreator.CreatePersonFromFile(person[0])); }
public GameEnvironment(EngineContext context) { Context = context; Populator = new GameEnvironmentPopulator(this); PersonCreator = new PersonCreator(context.Settings); PlantCreator = new PlantCreator(context.Settings); Tiles = new GameTile[] {}; People = new Person[] {}; Plants = new Plant[] { }; Logic = new GameLogic(); Tiles = new GameTile[] { new GameTile(this) }; }
public void CanReadAndWriteRandomPersonDataWithNoHeaders() { const bool hasHeaderRow = false; // Arrange List <Person> expectedList = PersonCreator.Work(20); // Act var saveAndReadHelper = new SaveAndReadHelper <Person, Person>(); var actualList = saveAndReadHelper.SaveAndRead(expectedList, hasHeaderRow); // Assert PersonHelper.CompareExpectedWithActualAndAssertIfNotEqual(expectedList, actualList); }
public void GetPerson_ReturnsPopulatedPerson() { //Given PersonCreator creator = GetCreator(); //When Person person = creator.CreatePerson <Person>(); //Then Assert.NotEqual(Guid.Empty, person.Id); Assert.NotEmpty(person.FirstName); Assert.NotEmpty(person.LastName); Assert.True(IsEmailAddress(person.Email)); Assert.NotEqual(Gender.Invalid, person.Gender); }
public void Test_GetThirstyCollectWaterAndDrink() { Console.WriteLine(""); Console.WriteLine("Preparing test"); Console.WriteLine(""); var context = MockEngineContext.New(); context.Data.IsVerbose = true; context.Settings.DefaultCollectWaterRate = 50; // Increase the rate of water collection so the test goes faster context.Settings.DefaultDrinkAmount = 20; // Increase the amount the person drinks so the test goes faster context.Settings.WaterForThirstRatio = 10; // Disabled otherwise the thirst vital will never remain at zero //context.World.Logic.AddEffect (new ThirstEffect(context.Settings, context.Console)); context.World.Logic.AddNeed(new DrinkWaterNeedIdentifier(context.Settings, context.Console)); context.World.Logic.AddActivity(typeof(CollectWaterActivity)); context.World.Logic.AddActivity(typeof(DrinkWaterActivity)); var tile = context.World.Tiles [0]; tile.Inventory[ItemType.Water] = 200; var person = new PersonCreator(context.Settings).CreateAdult(); // TODO: Store the PersonCreator object somewhere else person.Vitals[PersonVitalType.Thirst] = 90; tile.AddPerson(person); context.Player = person; Console.WriteLine(""); Console.WriteLine("Executing test"); Console.WriteLine(""); context.Initialize(); // TODO: Should Start be part of the test? Or part of the preparation before the above console output? context.Run(10); Console.WriteLine(""); Console.WriteLine("Analysing test"); Console.WriteLine(""); Assert.AreEqual(0, person.Vitals[PersonVitalType.Thirst]); }
public void CreatePeople_ReturnsPopulatedPeople() { //Given const int userCount = 4; PersonCreator creator = GetCreator(); //When List <Person> users = creator.CreatePeople <Person>(userCount); //Then Assert.All <Person>(users, user => Assert.NotEqual(Guid.Empty, user.Id)); Assert.All <Person>(users, user => Assert.True(IsEmailAddress(user.Email))); Assert.All <Person>(users, user => Assert.NotEmpty(user.FirstName)); Assert.All <Person>(users, user => Assert.NotEmpty(user.LastName)); Assert.All <Person>(users, user => Assert.NotEqual(Gender.Invalid, user.Gender)); }
public void Test_DecideAndBuildShelter() { Console.WriteLine(""); Console.WriteLine("Preparing test"); Console.WriteLine(""); var context = MockEngineContext.New(); context.Data.IsVerbose = true; context.Settings.MinimumTreeSize = 90; // Increase the size of the trees to speed up test context.Settings.WoodRequiredForTimber = 1.1m; // Reduce the waste rate to increase the speed of the test context.Settings.ConstructionRate = 50; // Increase construction rate to speed up test context.Settings.TimberMillingRate = 50; context.Settings.FellingRate = 50; context.World.Logic.AddNeed(new BuildShelterNeedIdentifier(context.Settings, context.Console)); //context.World.Logic.AddDecision (new ShelterDecision ()); context.World.Logic.AddActivity(typeof(BuildShelterActivity)); context.World.Logic.AddActivity(typeof(MillTimberActivity)); context.World.Logic.AddActivity(typeof(FellWoodActivity)); var tile = context.World.Tiles [0]; var person = new PersonCreator(context.Settings).CreateAdult(); // TODO: Store the PersonCreator object somewhere else tile.AddPerson(person); tile.AddTrees(new PlantCreator(context.Settings).CreateTrees(10)); // TODO: Should this PlantCreator object be stored somewhere better? context.Player = person; Console.WriteLine(""); Console.WriteLine("Executing test"); Console.WriteLine(""); context.Initialize(); // TODO: Should Start be part of the test? Or part of the preparation before the above console output? context.Run(20); Console.WriteLine(""); Console.WriteLine("Analysing test"); Console.WriteLine(""); Assert.IsNotNull(person.Home); Assert.AreEqual(100, person.Home.PercentComplete); Assert.AreEqual(null, person.Activity); }
public void AllValuesAreCopiedFromPersonDtoToNewEntity() { var personDto = new PersonDTO { FirstName = "Adam", LastName = "Adamsson", Age = 21 }; var expectedPerson = new Person { FirstName = "Adam", LastName = "Adamsson", Age = 21 }; Assert.That(PersonCreator.CreatePersonEntity(personDto), new IsSamePersonConstraint(expectedPerson)); }
internal SerializedDataStorage() { try { _persons = SerializationManager.Deserialize <List <Person> >(FileFolderHelper.StorageFilePath); } catch (FileNotFoundException) { List <Person> fifty = new List <Person>(); for (int i = 0; i < 50; i++) { fifty.Add(PersonCreator.CreateRandomePerson()); } _persons = fifty; } }
public void CreatePerson_ValidEntity_FieldsAreCopiedDefaultsAreSet() { var dto = new PersonDTO { FirstName = "Adam", LastName = "Adamsson", Age = 21 }; var newEntity = PersonCreator.CreatePersonEntity(dto); Assert.IsNotNull(newEntity.Id); Assert.AreEqual("Adam", newEntity.FirstName); Assert.AreEqual("Adamsson", newEntity.LastName); Assert.AreEqual(21, newEntity.Age); Assert.AreEqual(DateTime.Now.ToShortDateString(), newEntity.Created.ToShortDateString()); }
public void Test_Act_FinishedFelling() { Console.WriteLine(""); Console.WriteLine("Preparing test"); Console.WriteLine(""); var context = MockEngineContext.New(); var settings = EngineSettings.DefaultVerbose; settings.FellingRate = 10; var person = new PersonCreator(settings).CreateAdult(); var tile = context.World.Tiles[0]; tile.AddPerson(person); tile.AddTrees(new PlantCreator(context.Settings).CreateTrees(2)); var needEntry = new NeedEntry(ActivityVerb.Fell, ItemType.Wood, PersonVitalType.NotSet, 50, 101); person.AddNeed(needEntry); var activity = new FellWoodActivity(person, needEntry, settings, new ConsoleHelper(settings)); activity.Target = tile.Trees [0]; activity.Target.PercentHarvested = 100; activity.TotalWoodFelled = 40; // Add just enough so the activity can finish var totalWoodExpected = activity.Target.Size; Console.WriteLine(""); Console.WriteLine("Executing test"); Console.WriteLine(""); activity.Act(person); Assert.IsTrue(activity.IsFinished); Assert.IsNull(activity.Target); Assert.AreEqual(totalWoodExpected, person.Inventory.Items [ItemType.Wood]); Assert.AreEqual(0, person.Needs.Count); }
public void Test_GetHungryCollectFoodAndEat() { Console.WriteLine(""); Console.WriteLine("Preparing test"); Console.WriteLine(""); var context = MockEngineContext.New(); context.Settings.DefaultGatherFoodRate = 50; // Increase the rate of food gathering so the test goes faster context.Settings.DefaultEatAmount = 100; // Increase the amount the person eats so the test goes faster context.World.Logic.AddNeed(new EatFoodNeedIdentifier(context.Settings, context.Console)); context.World.Logic.AddActivity(typeof(GatherFoodActivity)); context.World.Logic.AddActivity(typeof(EatFoodActivity)); var tile = context.World.Tiles [0]; tile.Inventory[ItemType.Food] = 200; var person = new PersonCreator(context.Settings).CreateAdult(); // TODO: Store the PersonCreator object somewhere else person.Vitals[PersonVitalType.Hunger] = 90; tile.AddPerson(person); context.Player = person; Console.WriteLine(""); Console.WriteLine("Executing test"); Console.WriteLine(""); context.Initialize(); // TODO: Should Start be part of the test? Or part of the preparation before the above console output? context.Run(5); Console.WriteLine(""); Console.WriteLine("Analysing test"); Console.WriteLine(""); Assert.AreEqual(40, person.Vitals[PersonVitalType.Hunger]); }
public void CreateStudents_ReturnsPopulatedStudents() { //Given PersonCreator creator = GetCreator(); const int userCount = 4; const int birthYear = 2012; //When List <Student> students = creator.CreateStudents(userCount, birthYear); //Then Assert.All <Student>(students, user => Assert.NotEqual(Guid.Empty, user.Id)); Assert.All <Student>(students, user => Assert.True(IsEmailAddress(user.Email))); Assert.All <Student>(students, user => Assert.NotEmpty(user.FirstName)); Assert.All <Student>(students, user => Assert.NotEmpty(user.LastName)); Assert.All <Student>(students, user => Assert.NotEqual(DateTime.MinValue, user.DateOfBirth)); Assert.All <Student>(students, user => Assert.NotEqual(DateTime.MinValue, user.EntryDate)); Assert.All <Student>(students, user => Assert.NotEmpty(user.HomeLanguage)); Assert.All <Student>(students, user => Assert.NotEmpty(user.HomeCommunicationLanguage)); Assert.All <Student>(students, user => Assert.NotEmpty(user.PictureUrl)); Assert.All <Student>(students, user => Assert.NotEqual(Gender.Invalid, user.Gender)); }