private static void InitialiseInhab(Inhabitant thing,Room room,AMaterialStats stats) { int trytimes = 0; bool done = false; Coord size = new Coord(3, 3); while (!done && trytimes < 20) { //Random distribution HACK! u can make more distribution types int tryx = MyRandom.Random.Next(0, room.RoomOccupiedGrid.GetLength(0) - size.X); int tryy = MyRandom.Random.Next(0, room.RoomOccupiedGrid.GetLength(1) - size.Y); if (CheckClear(new Coord(tryx, tryy), size,room.RoomOccupiedGrid)) { MakeNotCLear(new Coord(tryx, tryy), size, room.RoomOccupiedGrid); thing.Initialise(size - new Coord(1, 1) , room.Position + (new Vector2(tryx+1.5f, tryy+1.5f)*Globals.SmallGridSize) , room.RoomAmbient.RoomColour, room.RoomAmbient.GlowColour, stats , room.RoomAmbient.RoomTileset); done = true; } trytimes++; } }
public IActionResult RequestChechOut(int id) { Inhabitant inhabitant = this.GetById(id); if (inhabitant == null) { return(new NotFoundResult()); } TimeSpan usingTime = DateTime.Now - inhabitant.CheckIn; Room room = this.dbService.Context.Rooms .Where(r => r.Id == inhabitant.RoomId).FirstOrDefault(); RoomCategory category = room.Category; using (var db = this.dbService.Context) { db.Inhabitants.Remove(inhabitant); db.SaveChanges(); } HttpContext.Response.StatusCode = StatusCodes.Status200OK; return(new JsonResult(new { Price = Logic.CalculatePrice(this.Config, category, usingTime) })); }
// Update is called once per frame void Update() { if (Input.GetMouseButtonDown(0)) { mouseDown = true; } if (Input.GetMouseButtonUp(0)) { mouseDown = false; } if (mouseDown) { Vector3 mousePosition = Input.mousePosition; Vector2 v = Camera.main.ScreenToWorldPoint(mousePosition); Collider2D[] col = Physics2D.OverlapPointAll(v); if (col.Length > 0) { foreach (Collider2D c in col) { Inhabitant inhabitant = c.gameObject.GetComponent <Inhabitant> (); inhabitant.Clicked(); } } } }
void assignHouseAndOffice() { List <GameObject> offices = new List <GameObject>(city.GetComponent <Roads>().offices); List <GameObject> houses = new List <GameObject>(city.GetComponent <Roads>().houses); for (int i = 0; i < city.GetComponent <Roads>().population; i++) { int idxOffice = Random.Range(0, offices.Count - 1); int idxHome = Random.Range(0, houses.Count - 1); GameObject johnsHome = houses[idxHome]; GameObject johnsWork = offices[idxOffice]; Inhabitant johnDo = new Inhabitant(johnsHome, johnsWork); population.Add(johnDo); johnsHome.GetComponent <Home>().inhabitants++; johnsHome.GetComponent <Home>().WhosAtHome++; johnsWork.GetComponent <Office>().workers++; if (johnsHome.GetComponent <Home>().inhabitants >= johnsHome.GetComponent <Home>().nInhabitants) { houses.Remove(johnsHome); } if (johnsWork.GetComponent <Office>().workers >= johnsWork.GetComponent <Office>().nbWorkers) { offices.Remove(johnsWork); } } }
static void Main(string[] args) { Doors doors = new Doors(70); Inhabitant homie = new Inhabitant("John Flitch", "90930293", "92832832"); HouseModel house = new HouseModel("malinowa 2", 90, 2); Console.ReadKey(); }
public void Spawn(Attributes attributes) { Vector2 position = Random.insideUnitCircle.normalized; Inhabitant inhabitant = Instantiate <Inhabitant>(prefab, position, Quaternion.identity, transform); inhabitant.attributes = attributes; inhabitant.SendMessage("OnValidate"); }
public void Test_InhabitantEditorPresenter_Common() { var view = Substitute.For <IInhabitantEditorView>(); var model = new ALModel(null); var record = new Inhabitant(); var presenter = new InhabitantEditorPresenter(view); presenter.SetContext(model, record); Assert.IsTrue(presenter.ApplyChanges()); }
public IActionResult RequestGet(int id) { Inhabitant inhabitant = this.GetById(id); if (inhabitant == null) { return(new NotFoundResult()); } HttpContext.Response.StatusCode = StatusCodes.Status200OK; return(new JsonResult(this.PrepareToJson(inhabitant))); }
private object PrepareToJson(Inhabitant i) { if (i == null) { return(null); } return(new { Id = i.Id, RoomId = i.RoomId, CustomerId = i.CustomerId, CheckIn = i.CheckIn }); }
void Update() { lifeTimer += Time.deltaTime; Inhabitant i = GetComponent <Inhabitant> (); if (lifeTimer > lifeTime) { if (i != null) { GetComponent <Inhabitant> ().Kill(); } else { Destroy(gameObject); } } }
static void Main(string[] args) { var peopleNumber = int.Parse(Console.ReadLine()); List <Inhabitant> inhabitants = new List <Inhabitant>(); for (int i = 0; i < peopleNumber; i++) { var tokens = Console.ReadLine().Split(" ", StringSplitOptions.RemoveEmptyEntries).ToArray(); var name = tokens[0]; var age = int.Parse(tokens[1]); if (tokens.Length == 4) { string id = tokens[2]; string birthDate = tokens[3]; Inhabitant citizen = new Citizen(name, age, id, birthDate); inhabitants.Add(citizen); } else if (tokens.Length == 3) { string group = tokens[2]; Inhabitant rebel = new Rebel(name, age, group); inhabitants.Add(rebel); } } string buyerName; while ((buyerName = Console.ReadLine()) != "End") { Inhabitant buyer = inhabitants.FirstOrDefault(i => i.Name == buyerName); if (buyer != null) { buyer.BuyFood(); } } Console.WriteLine(inhabitants.Sum(i => i.Food)); }
public IActionResult RequestChechIn(int roomId, int customerId) { if (!this.CanBeInhabited(roomId, customerId)) { return(new ConflictResult()); } Inhabitant inhabitant; using (var db = this.dbService.Context) { inhabitant = new Inhabitant { CustomerId = customerId, RoomId = roomId, CheckIn = DateTime.Now }; db.Inhabitants.Add(inhabitant); db.SaveChanges(); } using (var db = this.dbService.Context) { var customer = db.Customers.Where(c => c.Id == customerId).FirstOrDefault(); customer.InhabitantId = inhabitant.Id; db.Customers.Update(customer); var room = db.Rooms.Where(r => r.Id == roomId).FirstOrDefault(); room.InhabitantId = inhabitant.Id; db.Rooms.Update(room); db.SaveChanges(); } HttpContext.Response.StatusCode = StatusCodes.Status201Created; return(new JsonResult(this.PrepareToJson(this.GetById(inhabitant.Id)))); }
public void SetContext(IModel model, Inhabitant record) { fPresenter.SetContext(model, record); }
public void AddInhabitant(Inhabitant inhabitant) => throw new NotImplementedException();
public override string ToString() { return(string.Concat("kindDef=", KindDef, ", context=", Context, ", faction=", Faction, ", tile=", Tile, ", forceGenerateNewPawn=", ForceGenerateNewPawn.ToString(), ", newborn=", Newborn.ToString(), ", allowDead=", AllowDead.ToString(), ", allowDowned=", AllowDowned.ToString(), ", canGeneratePawnRelations=", CanGeneratePawnRelations.ToString(), ", mustBeCapableOfViolence=", MustBeCapableOfViolence.ToString(), ", colonistRelationChanceFactor=", ColonistRelationChanceFactor, ", forceAddFreeWarmLayerIfNeeded=", ForceAddFreeWarmLayerIfNeeded.ToString(), ", allowGay=", AllowGay.ToString(), ", prohibitedTraits=", ProhibitedTraits, ", allowFood=", AllowFood.ToString(), ", allowAddictions=", AllowAddictions.ToString(), ", inhabitant=", Inhabitant.ToString(), ", certainlyBeenInCryptosleep=", CertainlyBeenInCryptosleep.ToString(), ", biocodeWeaponChance=", BiocodeWeaponChance, ", validatorPreGear=", ValidatorPreGear, ", validatorPostGear=", ValidatorPostGear, ", fixedBiologicalAge=", FixedBiologicalAge, ", fixedChronologicalAge=", FixedChronologicalAge, ", fixedGender=", FixedGender, ", fixedMelanin=", FixedMelanin, ", fixedLastName=", FixedLastName, ", fixedBirthName=", FixedBirthName)); }
private void Awake() { inhabitant = GetComponent <Inhabitant>(); }
public override string ToString() { return("kindDef=" + KindDef + ", context=" + Context + ", faction=" + Faction + ", tile=" + Tile + ", forceGenerateNewPawn=" + ForceGenerateNewPawn.ToString() + ", newborn=" + Newborn.ToString() + ", allowDead=" + AllowDead.ToString() + ", allowDowned=" + AllowDowned.ToString() + ", canGeneratePawnRelations=" + CanGeneratePawnRelations.ToString() + ", mustBeCapableOfViolence=" + MustBeCapableOfViolence.ToString() + ", colonistRelationChanceFactor=" + ColonistRelationChanceFactor + ", forceAddFreeWarmLayerIfNeeded=" + ForceAddFreeWarmLayerIfNeeded.ToString() + ", allowGay=" + AllowGay.ToString() + ", prohibitedTraits=" + ProhibitedTraits + ", allowFood=" + AllowFood.ToString() + ", allowAddictions=" + AllowAddictions.ToString() + ", inhabitant=" + Inhabitant.ToString() + ", certainlyBeenInCryptosleep=" + CertainlyBeenInCryptosleep.ToString() + ", biocodeWeaponChance=" + BiocodeWeaponChance + ", validatorPreGear=" + ValidatorPreGear + ", validatorPostGear=" + ValidatorPostGear + ", fixedBiologicalAge=" + FixedBiologicalAge + ", fixedChronologicalAge=" + FixedChronologicalAge + ", fixedGender=" + FixedGender + ", fixedMelanin=" + FixedMelanin + ", fixedLastName=" + FixedLastName + ", fixedBirthName=" + FixedBirthName); }
private bool CreatePerson(List <GameObject> structures) { int houseMaxIter = 0; // Choosing a house GameObject home = null; while (home == null) { if (houseMaxIter > 1000) { return(false); } Housing structure = structures[UnityEngine.Random.Range(0, structures.Count - 1)].GetComponent <Housing>(); if (structure.ElectableAsLifePlace()) { structure.AddHabitant(); home = structure.gameObject; } houseMaxIter++; } // Chosing a connectable workplace GameObject work = null; // List<Waypoint> aStarResult = null; // List<Waypoint> aStarResultReverse = null; int workMaxIter = 0; while (work == null) { if (workMaxIter > 1000) { return(false); } Housing structure = structures[UnityEngine.Random.Range(0, structures.Count - 1)].GetComponent <Housing>(); if (structure.ElectableAsWorkPlace()) { if (home.GetComponent <Housing>().CarPosition != null && structure.CarPosition != null) { //aStarResult = AstarFinder.AStar(home.GetComponent<Housing>().CarPosition, structure.CarPosition); //aStarResultReverse = AstarFinder.AStar(structure.CarPosition, home.GetComponent<Housing>().CarPosition); //if (aStarResult != null && aStarResultReverse != null) //{ work = structure.gameObject; //} } } workMaxIter++; } // Instantiate a person GameObject selectedPrefab = charactersPrefabs[UnityEngine.Random.Range(0, charactersPrefabs.Count - 1)]; GameObject person = GameObject.Instantiate(selectedPrefab, new Vector3(0, -100, 0), Quaternion.identity); Inhabitant personManager = person.GetComponent <Inhabitant>(); personManager.livingPlace = home.GetComponent <Housing>(); personManager.workPlace = work.GetComponent <Housing>(); personManager.planning = allPlannings[UnityEngine.Random.Range(0, allPlannings.Count - 1)]; personManager.asCar = UnityEngine.Random.Range(0, 10) < 5 ? true : false; //print(personManager.asCar); // if it has a car creates it if (personManager.asCar) { GameObject carPrefEmpty = GameObject.Instantiate(carPrefab); // carPrefEmpty.transform.position = new Vector3(0, 1.1f, 0); carPrefEmpty.transform.localScale = new Vector3(.5f, .5f, .5f); /*GameObject carBody = */ Instantiate(carPrefabsBody[UnityEngine.Random.Range(0, carPrefabsBody.Count - 1)], new Vector3(0, .1f, 0), Quaternion.Euler(-90, 90, 90), carPrefEmpty.transform); personManager.SetCar(carPrefEmpty); } else { //Debug.Log("PIETON"); } //home.transform.position = new Vector3(home.transform.position.x, 10, home.transform.position.z); //work.transform.position = new Vector3(work.transform.position.x, 10, work.transform.position.z); //aStarResult.Reverse(); //personManager.roadToWork = aStarResult; //aStarResultReverse.Reverse(); //personManager.roadToWork = aStarResultReverse; return(true); }
// Die Methoden // Fügt dem Stamm einen Zwerg hinzu public void AddBewohner(Inhabitant input) { this.bewohner.Add(input); }