public HomeController(WitcherLogic WitcherLogic, HumanLogic HumanLogic, MonsterLogic MonsterLogic, StatLogic StatLogic) { this.WitcherLogic = WitcherLogic; this.HumanLogic = HumanLogic; this.MonsterLogic = MonsterLogic; this.StatLogic = StatLogic; }
public override List <KeyValuePair <string, object> > getInformation(bool onlyName = false) { if (onlyName) { return(base.getInformation(onlyName)); } if (information == null) { HumanLogic human = GetComponent <HumanLogic> (); if (human != null) { distance = Mathf.FloorToInt(human.totalWalkingDistance); // mood = calculateMood (human.mood); // TODO } information = base.getInformation(); information.Add(new KeyValuePair <string, object> ("Date of birth", dateOfBirth)); information.Add(new KeyValuePair <string, object> ("Money", Misc.getMoney(money))); // information.Add (new KeyValuePair<string, object> ("Mood", mood)); information.Add(new KeyValuePair <string, object> ("Have walked", Misc.getDistance(distance))); information.Add(new KeyValuePair <string, object> ("Destination", destination)); keepInformationUpToDate(true, information); } return(information); }
private IEnumerator checkAndUpdateHumanInfo(List <KeyValuePair <string, object> > information) { HumanLogic human = GetComponent <HumanLogic> (); while (human != null) { distance = Mathf.FloorToInt(human.totalWalkingDistance); // mood = calculateMood (human.mood); // TODO int indexHaveWalked = information.FindIndex(pair => pair.Key == "Have walked"); information.RemoveAt(indexHaveWalked); information.Insert(indexHaveWalked, new KeyValuePair <string, object>("Have walked", Misc.getDistance(distance))); // TODO - Mood yield return(new WaitForSeconds(1f)); } }
public void DeleteHuman() { Mock <IRepository <Human> > mock3 = new Mock <IRepository <Human> >(MockBehavior.Loose); mock3.Setup(x => x.Delete(It.IsAny <string>())); HumanLogic hl = new HumanLogic(mock3.Object); Human h1 = new Human() { Name = "Chad", Job = "Emperor", Nationality = "Temerian", Wage = 2000 }; hl.Delete(h1); mock3.Verify(x => x.Delete(h1), Times.Once); }
public void reportColliderExit(Collider col, string colliderName) { if (!destroying) { CollisionObj rawCollisionObj = getColliderType(col); if (rawCollisionObj != null) { VehicleCollisionObj vehicleCollisionObj = rawCollisionObj.typeName == VehicleCollisionObj.NAME ? (VehicleCollisionObj)rawCollisionObj : null; HumanCollisionObj humanCollisionObj = rawCollisionObj.typeName == HumanCollisionObj.NAME ? (HumanCollisionObj)rawCollisionObj : null; if (vehicleCollisionObj != null) { removeVehicleInVision(vehicleCollisionObj); } else if (humanCollisionObj != null) { HumanLogic otherHuman = humanCollisionObj.Human; waitForHumans.Remove(otherHuman); } } } }
public void initInformation() { type = TYPE_HUMAN; // Check for stored information in HumanLogic HumanLogic human = GetComponent <HumanLogic>(); Vehicle vehicle = GetComponent <Vehicle> (); Setup.PersonSetup data = null; if (human != null) { data = human.personality; destination = findInformationPOI(human.targetPos); } else if (vehicle != null && vehicle.characteristics != null) { long personId; if (passengerIndex == -1) { personId = vehicle.characteristics.driverId; } else { personId = vehicle.characteristics.passengerIds [passengerIndex]; } data = Game.instance.loadedLevel.setup.getReferencePerson(personId); } if (data != null) { if (data.name == null) { if (data.country != null || Game.instance.loadedLevel.country != null) { name = NameGenerator.generate(data.country != null ? data.country : Game.instance.loadedLevel.country); } else { name = NameGenerator.generate(); } } else { name = data.name; } if (data.dob != null) { dateOfBirth = Misc.parseDate(data.dob); } else { DateTime now = DateTime.Now; int daysOld = Misc.randomRange(6574, 29220); // 18-80 years old in days dateOfBirth = new DateTime(now.Ticks - Misc.daysToTicks(daysOld)); // Days to ticks } if (data.money != 0f) { money = data.money; } else { money = Misc.randomRange(0f, 500f); } return; } else { // TODO - Also handle random names from countries specified in <person>? if (Game.instance.loadedLevel != null && Game.instance.loadedLevel.country != null) { name = NameGenerator.generate(Game.instance.loadedLevel.country); } else { name = NameGenerator.generate(); } // TODO - Make sure random ranges are valid dates DateTime now = DateTime.Now; int daysOld = Misc.randomRange(6574, 29220); // 18-80 years old in days dateOfBirth = new DateTime(now.Ticks - Misc.daysToTicks(daysOld)); // Days to ticks money = Misc.randomRange(0f, 500f); } // Debug.Log("New human: " + name); }
public EditController(WitcherLogic wlogic, HumanLogic hlogic, MonsterLogic mlogic) { this.wlogic = wlogic; this.hlogic = hlogic; this.mlogic = mlogic; }
public void reportCollision(Collider col, string colliderName) { // ColliderName = "BODY" or "VISION" if (!destroying) { CollisionObj rawCollisionObj = getColliderType(col); if (rawCollisionObj != null) { VehicleCollisionObj vehicleCollisionObj = rawCollisionObj.typeName == VehicleCollisionObj.NAME ? (VehicleCollisionObj)rawCollisionObj : null; HumanCollisionObj humanCollisionObj = rawCollisionObj.typeName == HumanCollisionObj.NAME ? (HumanCollisionObj)rawCollisionObj : null; if (vehicleCollisionObj != null) { setVehicleInVision(vehicleCollisionObj); } else if (humanCollisionObj != null) { HumanLogic otherHuman = humanCollisionObj.Human; bool shouldDecide = humanId < otherHuman.humanId; if (colliderName == "VISION") { // Scenarios: // Meeting in intersection, moving towards same point // One walking faster, moving in same direction (towards same point) // Meeting, not moving towards same point // One or both have already deviated from target, meeting on the way to temporary point float angle = Quaternion.Angle(transform.rotation, otherHuman.transform.rotation); if (shouldDecide || angle < 20f) { if (angle >= 20f && angle <= 160f) { // Walking with an angle towards each other - one should wait otherHuman.waitForAWhile(); } else if (angle < 20f) { // Walking alongside, they divide their speed, the one ahead goes a tiny bit quicker float totalWalkingSpeed = speedFactor + otherHuman.speedFactor; speedFactor = totalWalkingSpeed * 0.45f; otherHuman.speedFactor = totalWalkingSpeed * 0.55f; } else { // Walking towards each other, decide one deviation point for each Vector3 otherPosition = otherHuman.transform.position; Quaternion otherRotation = otherHuman.transform.rotation; Vector3 otherHumanToMe = transform.position - otherPosition; Vector3 otherPersonMovement = otherRotation * Vector3.right; bool isToTheRight = Vector3.Cross(otherPersonMovement, otherHumanToMe).z < 0; Vector3 meetingPosition = transform.position + (otherPosition - transform.position) / 2f; deviationTarget = meetingPosition + Quaternion.Euler(0f, 0f, transform.rotation.eulerAngles.z + (isToTheRight ? 90f : -90f)) * BODY_WIDTH; timedDeviationTarget = null; otherHuman.deviationTarget = meetingPosition + Quaternion.Euler(0f, 0f, otherRotation.eulerAngles.z + (isToTheRight ? 90f : -90f)) * BODY_WIDTH; otherHuman.timedDeviationTarget = null; } } } else if (colliderName == "BODY") { if (walkPath.Count > 0 && otherHuman.walkPath.Count > 0) { float ourDistance = Misc.getDistance(transform.position, walkPath [0]); float otherDistance = Misc.getDistance(otherHuman.transform.position, otherHuman.walkPath [0]); if (ourDistance > otherDistance || (ourDistance == otherDistance && !shouldDecide)) { if (!otherHuman.waitForHumans.Contains(this)) { waitForHumans.Add(otherHuman); } } } } } } } }
void OnTriggerEnter(Collider col) { HumanLogic human = GetComponentInParent <HumanLogic>(); human.reportCollision(col, HumanCollider.colliderNamesForGameObjectName[name]); }
public HumanController(HumanLogic logic) { this.logic = logic; }
public HumanCollisionObj(HumanLogic human, string collisionObjType) : base(collisionObjType, HumanCollisionObj.NAME) { this.Human = human; }