public void Load() { int num = 0; this.m_Requests.Clear(); SaveGame.LoadVal("PDMReqCount", out num, false); for (int i = 0; i < num; i++) { DiseaseRequest diseaseRequest = new DiseaseRequest(); SaveGame.LoadVal("PDMReq" + i.ToString() + "Delay", out diseaseRequest.m_Delay, false); int index = 0; SaveGame.LoadVal("PDMReq" + i.ToString() + "DisIndex", out index, false); diseaseRequest.m_Disease = this.m_Diseases.ElementAt(index).Value; SaveGame.LoadVal("PDMReq" + i.ToString() + "Level", out diseaseRequest.m_Level, false); SaveGame.LoadVal("PDMReq" + i.ToString() + "ReqTime", out diseaseRequest.m_RequestTime, false); this.m_Requests.Add(diseaseRequest); } for (int j = 0; j < this.m_Diseases.Count; j++) { if (j < 4) { this.m_Diseases.ElementAt(j).Value.Load(j); } else if (j == 4 && SaveGame.m_SaveGameVersion >= GreenHellGame.s_GameVersionEarlyAccessUpdate11) { this.m_Diseases.ElementAt(j).Value.Load(j); } } }
public void Activate(DiseaseRequest request) { if (!this.m_Active) { this.m_Active = true; this.m_StartTime = MainLevel.Instance.GetCurrentTimeMinutes(); this.m_Level = request.m_Level; this.ActivateSymptoms(); PlayerSanityModule.Get().OnEvent(PlayerSanityModule.SanityEventType.Disease, 1); PlayerDiseasesModule.Get().UnlockKnownDisease(this.m_Type); this.m_Activated = true; } }
public async Task <IActionResult> Edit([FromRoute] Guid id, [FromBody] DiseaseRequest request) { try { var disease = await diseaseService.EditAsync(id, request); return(Ok(disease)); } catch (Exception e) { return(BadRequest(e.Message)); } }
public async Task <IActionResult> Create([FromBody] DiseaseRequest request) { try { await diseaseService.CreateAsync(request); return(Ok()); } catch (Exception e) { return(BadRequest(e.Message)); } }
public CreateResponse Create(DiseaseRequest request) { try { var disease = TypeAdapter.Adapt <Disease>(request); _diseaseValidator.ValidateAndThrowException(disease, "Base,Create"); _diseaseRepository.Add(disease); return(new CreateResponse(disease.Id)); } catch (DataAccessException) { throw new ApplicationException(); } }
public async Task CreateAsync(DiseaseRequest request) { Disease disease = new Disease(request.Title, request.SymptomUk, request.SymptomUa); var inBase = await applicationContext.Diseases.FirstOrDefaultAsync(x => x.Title == request.Title); if (inBase != null) { throw new Exception(localizer["Disease already exists."]); } await applicationContext.Diseases.AddAsync(disease); await applicationContext.SaveChangesAsync(); }
public IActionResult UpdateDisease(int diseaseId, [FromBody] DiseaseRequest disease) { if (!ModelState.IsValid) { return(BadRequest("Invalid disease input")); } try { return(Ok(this.diseaseManager.Update(diseaseId, Mapper.Map <Disease>(disease)))); } catch (ArgumentException exception) { return(BadRequest(exception.Message)); } }
public IActionResult AddDisease([FromBody] DiseaseRequest disease) { if (!ModelState.IsValid) { return(BadRequest("Invalid disease input")); } try { int newDiseaseId = this.diseaseManager.Add(Mapper.Map <Disease>(disease)); return(Created("diseases/", newDiseaseId)); } catch (ArgumentException exception) { return(BadRequest(exception.Message)); } }
public async Task <Disease> EditAsync(Guid id, DiseaseRequest request) { Disease newDisease = new Disease(request.Title, request.SymptomUk, request.SymptomUa); Disease disease = await GetAsync(id); if (disease == null) { throw new Exception(localizer["Disease with this identifier doesn`t exist."]); } disease = newDisease; disease.Id = id; applicationContext.Diseases.Update(disease); await applicationContext.SaveChangesAsync(); return(await GetAsync(disease.Id)); }
public SuccessResponse Update(DiseaseRequest request) { try { var currentDisease = _diseaseRepository.FindBy(request.Id); currentDisease.ThrowExceptionIfRecordIsNull(); var diseasToCopy = TypeAdapter.Adapt <Disease>(request); TypeAdapter.Adapt(diseasToCopy, currentDisease); _diseaseValidator.ValidateAndThrowException(currentDisease, "Base,Update"); _diseaseRepository.Update(currentDisease); return(new SuccessResponse { IsSuccess = true }); } catch (DataAccessException) { throw new ApplicationException(); } }
public void RequestDisease(ConsumeEffect type, float delay, int level) { if (this.m_Diseases[(int)type].IsActive()) { return; } Disease disease = this.GetDisease(type); if (disease == null) { return; } DiseaseRequest diseaseRequest = new DiseaseRequest(); diseaseRequest.m_RequestTime = Time.time; diseaseRequest.m_Disease = disease; diseaseRequest.m_Delay = delay; diseaseRequest.m_Level = level; this.m_Requests.Add(diseaseRequest); this.UpdateRequests(); }
private void UpdateRequests() { int i = 0; while (i < this.m_Requests.Count) { DiseaseRequest diseaseRequest = this.m_Requests[i]; if (Time.time - diseaseRequest.m_RequestTime >= diseaseRequest.m_Delay) { if (diseaseRequest.m_Disease != null) { diseaseRequest.m_Disease.Activate(diseaseRequest); } this.m_Requests.Remove(diseaseRequest); } else { i++; } } }
public void Load() { int num = 0; this.m_Requests.Clear(); SaveGame.LoadVal("PDMReqCount", out num, false); for (int i = 0; i < num; i++) { DiseaseRequest diseaseRequest = new DiseaseRequest(); SaveGame.LoadVal("PDMReq" + i.ToString() + "Delay", out diseaseRequest.m_Delay, false); int index = 0; SaveGame.LoadVal("PDMReq" + i.ToString() + "DisIndex", out index, false); diseaseRequest.m_Disease = this.m_Diseases.ElementAt(index).Value; SaveGame.LoadVal("PDMReq" + i.ToString() + "Level", out diseaseRequest.m_Level, false); SaveGame.LoadVal("PDMReq" + i.ToString() + "ReqTime", out diseaseRequest.m_RequestTime, false); this.m_Requests.Add(diseaseRequest); } for (int j = 0; j < this.m_Diseases.Count; j++) { this.m_Diseases.ElementAt(j).Value.Load(j); } }
public override void Activate(DiseaseRequest request) { base.Activate(request); this.m_LastSanityDecreaseTime = MainLevel.s_GameTime; }
public SuccessResponse Put(DiseaseRequest request) { return(_diseaseService.Update(request)); }
public CreateResponse Post(DiseaseRequest request) { return(_diseaseService.Create(request)); }