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);
            }
        }
    }
예제 #2
0
 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;
     }
 }
예제 #3
0
        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));
            }
        }
예제 #4
0
        public async Task <IActionResult> Create([FromBody] DiseaseRequest request)
        {
            try
            {
                await diseaseService.CreateAsync(request);

                return(Ok());
            }
            catch (Exception e)
            {
                return(BadRequest(e.Message));
            }
        }
예제 #5
0
 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();
     }
 }
예제 #6
0
        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();
        }
예제 #7
0
        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));
            }
        }
예제 #8
0
        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));
            }
        }
예제 #9
0
        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));
        }
예제 #10
0
 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();
     }
 }
예제 #11
0
    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();
    }
예제 #12
0
    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++;
            }
        }
    }
예제 #13
0
    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);
        }
    }
예제 #14
0
 public override void Activate(DiseaseRequest request)
 {
     base.Activate(request);
     this.m_LastSanityDecreaseTime = MainLevel.s_GameTime;
 }
예제 #15
0
 public SuccessResponse Put(DiseaseRequest request)
 {
     return(_diseaseService.Update(request));
 }
예제 #16
0
 public CreateResponse Post(DiseaseRequest request)
 {
     return(_diseaseService.Create(request));
 }