void Start() { if (!id) { return; }// Enable/Disable debugging. debug = GameManager.instance.patientDebug; nPCDebug = GameManager.instance.nPCDebug; // Check for identification. if (!id) { Debug.LogError(name + " does not have a patient id.."); gameObject.SetActive(false); } patientState = PatientState.idle; name = id.name; SetHeader(); // Search for own room. foreach (var cell in Map.instance.cells) { if (cell.cellNumber == id.patientNumber) { home = cell.GetComponent <Place>(); } } // Check ward wing. if (id.patientNumber >= 0 && id.patientNumber <= 15) { wing = Wings.Central; } else if (id.patientNumber >= 16 && id.patientNumber <= 27) { wing = Wings.West; } else if (id.patientNumber >= 28 && id.patientNumber <= 39) { wing = Wings.East; } // Setup components. animator = GetComponent <Animator>(); audioS = GetComponent <AudioSource>(); navMeshAgent = GetComponent <UnityEngine.AI.NavMeshAgent>(); navMeshAgent.autoBraking = false; navMeshAgent.stoppingDistance = .5f; navMeshAgent.Warp(home.transform.position); isBusy = false; // Start routine; FindRoutine(); InvokeRepeating("CheckRoutine", 0.5f, 0.5f); if (Vector3.Distance(transform.position, home.transform.position) > 1) { navMeshAgent.Warp(home.transform.position); } }
void GoToPlace(Place.PlaceType placeType) { if (placeType == currentPlace.placeType) { return; } lastpatientState = patientState; patientState = PatientState.goToPlace; place.placeType = placeType; }
IEnumerator AssignRoutineWithDelay(Routine r, float maxDelay) { yield return(new WaitForSeconds(Random.Range(0, maxDelay))); assignReset = false; lastpatientState = patientState; patientState = r.state; place.placeType = r.goTo; StopAllCoroutines(); }
void FinishPreviousRoutine() { switch (lastpatientState) { case PatientState.sittingIdle: isBusy = true; StartCoroutine(Stand(true)); lastpatientState = PatientState.goToPlace; break; case PatientState.sittingEating: isBusy = true; StartCoroutine(ExitCafeteria(currentPlace.GetComponent <Cafeteria>())); lastpatientState = PatientState.goToPlace; break; //case PatientState.idle: // break; //case PatientState.waiting: // break; //case PatientState.talking: // break; //case PatientState.moving: // break; //case PatientState.washing: // break; //case PatientState.peeing: // break; //case PatientState.showering: // break; //case PatientState.running: // break; // Sitting states case PatientState.sittingTalking: // Disable talking. animator.SetBool("Talking", false); animator.SetLayerWeight(1, 0); isBusy = true; StartCoroutine(Stand(true)); lastpatientState = PatientState.goToPlace; break; //case PatientState.wakeUp: // break; //case PatientState.sleep: // break; //case PatientState.goToPlace: // break; default: lastpatientState = PatientState.goToPlace; break; } }
public IEnumerable <string> NextSymptoms(string state) { PatientState patientState = JsonConvert.DeserializeObject <PatientState>(state); List <string> syms = patientState.Symptoms; List <string> notSyms = patientState.NotSymptoms; List <string> newSyms = dModel.GetNextSymptoms(syms, notSyms); return(newSyms.Take(4)); }
public void MushroomGrowth() { if (state != PatientState.alive) { return; } state = PatientState.dead; if (!specialMushroom.gameObject.active) { specialMushroom.gameObject.SetActive(true); } }
public Patient(string pesel, string name, string surname, DateTime birthDate, PatientState patientState, Sex patientSex) : base(pesel, "PESEL", new List <string>()) { if (pesel.Length < 11 || pesel.Length > 11) { throw new FormatException("PESEL musi mieć 11 cyfr"); } //PrimaryKey = pesel; Surname = surname; Name = name; BirthDate = birthDate; PatientState = patientState; PatientSex = patientSex; } /// <summary>
public void EatenByMaggots() { if (state != PatientState.dead) { return; } smokePoofParticle.Play(); state = PatientState.skeleton; NormalBody.SetActive(false); SkeletalBody.SetActive(true); skeletonKey.SetActive(true); }
public void ResetPatient() { smokePoofParticle.Play(); state = PatientState.alive; NormalBody.SetActive(true); ZombieBody.SetActive(false); SkeletalBody.SetActive(false); foreach (GameObject w in woundList) { woundList.Remove(w); Destroy(w.gameObject); } }
public void BurnZombie() { if (state != PatientState.zombie) { return; } smokePoofParticle.Play(); state = PatientState.burned; ZombieBody.SetActive(false); if (!AshPileUnlock.gameObject.active) { AshPileUnlock.SetActive(true); } }
public void TurnZombie() { if (state != PatientState.alive) { return; } smokePoofParticle.Play(); state = PatientState.zombie; NormalBody.SetActive(false); ZombieBody.SetActive(true); if (!MaggotsUnlock.gameObject.active) { MaggotsUnlock.SetActive(true); } }
private void BecomeHealthy() { var oldWound = Wound; Wound = PatientWounds.Healthy; State = PatientState.Treated; animationController.SetBool("Bleeding", false); animationController.SetBool("Knife", false); animationController.SetBool("Sick", false); animationController.SetBool("Healthy", true); animationController.SetBool("Crazy", false); animationController.SetBool("Dead", false); // The next bool resets the animation animationController.SetBool("Moving", false); switch (oldWound) { case PatientWounds.Hemorhagie: TreatmentFlags.isHemorhagieOccupied = false; break; case PatientWounds.Psychology: TreatmentFlags.isPsychologyOccupied = false; break; case PatientWounds.Vomitorium: TreatmentFlags.isVomitoriumOccupied = false; break; case PatientWounds.Surgery: TreatmentFlags.isSurgeryOccupied = false; break; case PatientWounds.Exorcism: TreatmentFlags.isExorcismOccupied = false; break; } gameManager.PatientCured(); SpawnReward(5, new Color(1, 1, 1, 0)); }
protected void ArriveAtPlace(Place place) { lastpatientState = patientState; patientState = PatientState.idle; switch (place.GetComponent <Place>().placeType) { case Place.PlaceType.home: int r = Random.Range(0, 2); if (r == 0) { navMeshAgent.destination = FindSeat(place).transform.position; } else if (r == 1) { navMeshAgent.destination = place.GetComponent <Cell>().bed.transform.position; } break; case Place.PlaceType.hall: break; case Place.PlaceType.cafeteria: //patientState = PatientState.sittingEating; StartCoroutine(ArriveCafeteria(place.GetComponent <Cafeteria>())); break; case Place.PlaceType.bathroomCentre: patientState = PatientState.peeing; StartCoroutine(ArriveBathroom(place.GetComponent <Bathroom>())); break; case Place.PlaceType.bathroomEast: patientState = PatientState.peeing; StartCoroutine(ArriveBathroom(place.GetComponent <Bathroom>())); break; case Place.PlaceType.bathroomWest: patientState = PatientState.peeing; StartCoroutine(ArriveBathroom(place.GetComponent <Bathroom>())); break; case Place.PlaceType.shower: break; case Place.PlaceType.dayRoom: StartCoroutine(ArriveDayroom(place.GetComponent <DayRoom>())); break; case Place.PlaceType.therapy1: StartCoroutine(Sit(FindRandomSeat(place))); break; case Place.PlaceType.therapy2: StartCoroutine(Sit(FindRandomSeat(place))); break; case Place.PlaceType.therapy3: StartCoroutine(Sit(FindRandomSeat(place))); break; case Place.PlaceType.therapy4: StartCoroutine(Sit(FindRandomSeat(place))); break; case Place.PlaceType.therapy5: StartCoroutine(Sit(FindRandomSeat(place))); break; case Place.PlaceType.therapy6: StartCoroutine(Sit(FindRandomSeat(place))); break; default: break; } }
protected override void collidedWith(Collision2D coll) { //Patient cannot find seat if (panicMode) { return; } var nameOfCollided = coll.gameObject.name; //Patient collided with the player, and was seated if (nameOfCollided == "Player" && !transportedByPlayer) { if (PlayerFlags.IdOfLastClickedPatient == id) { if (!PlayerFlags.isPlayerBeingFollowed) { if (isSeated) { PlayerFlags.isPlayerBeingFollowed = true; player.StartCarrying(this); transportedByPlayer = true; isSeated = false; isChairOccupied[occupiedChairIndex] = false; speed = 20.0f; } else if (Wound == PatientWounds.Dead) { PlayerFlags.isPlayerBeingFollowed = true; player.StartCarrying(this); transportedByPlayer = true; } } } } else if (nameOfCollided == "Entrance") { if (Wound == PatientWounds.Healthy) { GameManager.RemovePatient(this); Destroy(this.transform.parent.gameObject); } } //***********************************************/ //Check if the patient can be deposited someplace //***********************************************/ else if (transportedByPlayer) { bool deposited = false; switch (nameOfCollided) { case "Hemorhagie": if (Wound != PatientWounds.Hemorhagie) { return; } if (TreatmentFlags.isHemorhagieOccupied) { return; } TreatmentFlags.isHemorhagieOccupied = true; deposited = true; player.StopCarrying(this); if (firstInitCollisionWithTreatment) { clearTargets(); firstInitCollisionWithTreatment = false; } addTarget(TreatmentFlags.HemorhagiePosition); break; case "Psychology": if (Wound != PatientWounds.Psychology) { return; } if (TreatmentFlags.isPsychologyOccupied) { return; } TreatmentFlags.isPsychologyOccupied = true; player.StopCarrying(this); deposited = true; if (firstInitCollisionWithTreatment) { clearTargets(); firstInitCollisionWithTreatment = false; } addTarget(TreatmentFlags.PsychologyPosition); break; case "Vomitorium": if (Wound != PatientWounds.Vomitorium) { return; } if (TreatmentFlags.isVomitoriumOccupied) { return; } TreatmentFlags.isVomitoriumOccupied = true; player.StopCarrying(this); deposited = true; if (firstInitCollisionWithTreatment) { clearTargets(); firstInitCollisionWithTreatment = false; } addTarget(TreatmentFlags.VomitoriumPosition); break; case "Surgery": if (Wound != PatientWounds.Surgery) { return; } if (TreatmentFlags.isSurgeryOccupied) { return; } TreatmentFlags.isSurgeryOccupied = true; player.StopCarrying(this); deposited = true; if (firstInitCollisionWithTreatment) { clearTargets(); firstInitCollisionWithTreatment = false; } addTarget(TreatmentFlags.SurgeryPosition); break; case "Exorcism": if (Wound != PatientWounds.Exorcism) { return; } if (TreatmentFlags.isExorcismOccupied) { return; } TreatmentFlags.isExorcismOccupied = true; player.StopCarrying(this); deposited = true; if (firstInitCollisionWithTreatment) { clearTargets(); firstInitCollisionWithTreatment = false; } addTarget(TreatmentFlags.ExorcismPosition); break; case "Morgue": if (Wound != PatientWounds.Dead) { return; } GameManager.RemovePatient(this); player.StopCarrying(this); transportedByPlayer = false; PlayerFlags.isPlayerBeingFollowed = false; Destroy(this.transform.parent.gameObject); break; } if (deposited) { State = PatientState.GettingTreated; transportedByPlayer = false; PlayerFlags.isPlayerBeingFollowed = false; } } }
private void Die() { state = PatientState.dead; Debug.Log("Is dead"); }
void Update() { if (!id) { return; } if (GameManager.instance.patientPath) { DrawPath(); } UpdateAnimator(); switch (patientState) { case PatientState.idle: if (currentPlace) { IdleSwitch(); } break; case PatientState.sittingIdle: // Start talking. //if (Random.Range(0, 200) == 50) //{ // animator.SetLayerWeight(1, 1); // animator.SetBool("Talking", true); // UpdateState(PatientState.sittingTalking); //} break; case PatientState.talking: // Stop talking. if (Random.Range(0, 150) == 50) { animator.SetBool("Talking", false); UpdateState(PatientState.waiting); animator.SetLayerWeight(1, 0); } break; case PatientState.sittingTalking: // Stop talking. if (Random.Range(0, 100) == 50) { animator.SetLayerWeight(1, 1); animator.SetBool("Talking", false); UpdateState(PatientState.sittingIdle); animator.SetLayerWeight(1, 0); } break; case PatientState.sleep: if (lastpatientState != patientState && !isBusy) { StartCoroutine("GoToSleep"); UpdateState(patientState); } break; case PatientState.wakeUp: if (lastpatientState != patientState && !isBusy) { StartCoroutine("WakeUp"); UpdateState(patientState); } break; case PatientState.goToPlace: if (lastpatientState != PatientState.goToPlace) { FinishPreviousRoutine(); } else if (!isBusy) { GoToPlaceSwitch(place); UpdateHeader(" going to " + place.placeType); navMeshAgent.isStopped = false; patientState = PatientState.moving; } break; } }
public void Set( PatientState state, float time ) { //Debug.Log("PatientState.Set(" + state.Name + "," + time + ")"); //state.Debug(); if (State == null) { // state is uninitialized, just make one #if DEBUG_VITALS UnityEngine.Debug.LogWarning("PatientVitals.Set(" + state.Name + "," + time + ")"); #endif State = new VitalState(); State.Name = state.Name; State.AddVital(new Vital("HR", state.HR, 0.0f, 2.0f)); State.AddVital(new Vital("BP_SYS", state.BP_SYS, 0.0f, 1.5f)); State.AddVital(new Vital("BP_DIA", state.BP_DIA, 0.0f, 1.0f)); State.AddVital(new Vital("SP", state.SP, 0f, 1.25f)); State.AddVital(new Vital("TEMP", state.TEMP, 0f, 5.0f)); State.AddVital(new Vital("RESP", state.RESP, 0f, 1.25f)); #if DEBUG_VITALS UnityEngine.Debug.Log("#1 :::: HR=" + state.HR + " : BP_SYS=" + state.BP_SYS + " : BP_DIA=" + state.BP_DIA); #endif } else { // update current state #if DEBUG_VITALS UnityEngine.Debug.LogWarning("PatientVitals.Set(" + state.Name + "," + time + ")"); #endif State.Name = state.Name; State.GetVital("HR").Set(state.HR, time); State.GetVital("BP_SYS").Set(state.BP_SYS, time); State.GetVital("BP_DIA").Set(state.BP_DIA, time); State.GetVital("SP").Set(state.SP, time); State.GetVital("TEMP").Set(state.TEMP, time); State.GetVital("RESP").Set(state.RESP, time); #if DEBUG_VITALS UnityEngine.Debug.Log("#2 :::: HR=" + state.HR + " : BP_SYS=" + state.BP_SYS + " : BP_DIA=" + state.BP_DIA); #endif } }
public PatientState(PatientState state) { Name = state.Name; HR = state.HR; BP_SYS = state.BP_SYS; BP_DIA = state.BP_DIA; SP = state.SP; TEMP = state.TEMP; RESP = state.RESP; }
public PatientState Test(string state) { PatientState patientState = JsonConvert.DeserializeObject <PatientState>(state); return(patientState); }
public ActionResult Create(DateTime date, TimeSlots time, int Id, int time1, FormCollection f) { // check if patient has already make an appointment with same clinic in same day string currentUserId = User.Identity.GetUserId(); var clinic = db.Clinics.Find(Id); var c = db.Appointments.Where(x => x.PatientState.PatientId == currentUserId && x.ClinicId == Id && x.DayofApp == date).ToList(); if (c.Count > 1) { ViewBag.Result = "You have applied before !"; return(View()); } // check if he has a previous Patient state with same name with same category string patientstatename = f["pa"]; List <Appointment> check; var ExpatientStates = db.PatientStates.Where(x => x.PatientId == currentUserId && x.StateName == patientstatename).ToList(); var st1 = ExpatientStates.FirstOrDefault(); check = db.Appointments.Where(u => u.PatientStateId == st1.Id && u.Clinic.CategoryId == clinic.CategoryId).ToList(); //if (check.Count == 0) PatientState p; // new patientstate if not there one if (ExpatientStates.Count == 0 || check.Count == 0) { p = new PatientState { PatientId = currentUserId, StateName = patientstatename, InProgress = true, StartTime = date }; db.PatientStates.Add(p); db.SaveChanges(); } //get the old one else { var qqqqq = from e in check where e.Clinic.CategoryId == clinic.CategoryId select e.PatientStateId; int id = qqqqq.FirstOrDefault(); p = ExpatientStates.FirstOrDefault(e => e.Id == id); } #region old way to get ava //Days st = Days.Saturday; //Days q=Days.Saturday; //for (int i = 1; i < 8; i++) //{ // if (q.GetDisplayName() == date.DayOfWeek.ToString()) { st = q; } // q = (Days)i; //} //get the time slot to make it unavailable : 1) get the day //var day= from r in db.DayLists // where r.ClinicId == Id && (r.DayName==st) // select r; // var x = db.AvailableTimesLists.TakeWhile(t => t.DayListId == day.First().Id && t.Slot_start == time); //var tim = from t in db.AvailableTimesLists // where t.DayListId == day && t.Slot_start == time // select t; // var a = db.AvailableTimesLists.Where(s => s.DayListId == day.FirstOrDefault().Id && s.Slot_start == time).FirstOrDefault(); //var a = tim.FirstOrDefault(); #endregion // get time slot of this day to make it taken var a = db.AvailableTimesLists.Find(time1); a.Taken = true; db.Entry(a).State = EntityState.Modified; db.SaveChanges(); //make an appointment with this tSlot with status "scheduled" var model = from r in db.AppointmentStatus where r.Name == "Scheduled" select r; Appointment app = new Appointment { ClinicId = Id, AppointmentStatusId = model.First().Id, DayofApp = date, PatientStateId = p.Id, TimeStart = time, Slot = time1 }; db.Appointments.Add(app); db.SaveChanges(); StatusHistory s = new StatusHistory { StatusId = model.First().Id, AppointmentId = app.Id, Details = "first" }; db.StatusHistories.Add(s); db.SaveChanges(); return(RedirectToAction("MyAppointments")); #region commented //if (clinicid == null) { return new HttpStatusCodeResult(HttpStatusCode.BadRequest); } //d.ClinicId = int.Parse(clinicid); //var c = db.Clinics.Find(d.ClinicId); //if (c.DayLists.ToList().Find(q => q.DayName == d.DayName) != null) { return RedirectToAction("YourclinicDaylist"); } //if (ModelState.IsValid) //{ // db.DayLists.Add(d); // for (int i = (int)c.StartTime; i < (int)c.EndTime; i++) // { // AvailableTimesList availableTimes = new AvailableTimesList { DayListId = d.Id, Taken = false, Slot_start = (TimeSlots)i }; // db.AvailableTimesLists.Add(availableTimes); // } // db.SaveChanges(); // return RedirectToAction("YourclinicDaylist"); //} #endregion }