public override void Freed()
 {
     foreach (KeyValuePair <string, ResourcesDto> item in _resourcesCacheDic)
     {
         ResourcesDto resourcesDto = item.Value;
         Object.Destroy(resourcesDto.ResourceObj);
         resourcesDto.ResourceObj = null;
     }
     _resourcesCacheDic.Clear();
     _destroyTempList.Clear();
     Resources.UnloadUnusedAssets();
     Object.Destroy(this.gameObject);
 }
Esempio n. 2
0
        public void ShowResources(ResourcesDto resources)
        {
            var i = 2;

            Ui.Current.ResourcesText.text =
                string.Format(
                    "Свободные люди: {0}/{1}\n"
                    + Names.ResourcesNames.Aggregate("", (sum, r) => sum + r + ": {" + i++ + "}\n"),
                    new object[]
            {
                resources.FreePeople,
                resources.MaxPeople,
            }.Concat(
                        resources.ResourcesArray.Select(r => (object)((int)r).ToString())).ToArray());
        }
Esempio n. 3
0
        public void PutResources(int id, ResourcesDto resourcesDto)
        {
            if (!ModelState.IsValid)
            {
                throw new HttpResponseException(HttpStatusCode.BadRequest);
            }

            var resources = _context.Resources.SingleOrDefault(r => r.ResourcesId == id);

            if (resources == null)
            {
                throw new HttpResponseException(HttpStatusCode.NotFound);
            }

            Mapper.Map(resourcesDto, resources);

            _context.SaveChanges();
        }
Esempio n. 4
0
        /// <summary>
        /// 加载资源
        /// </summary>
        /// <param name="path">路径</param>
        /// <param name="isRecycle">是否自动回收</param>
        /// <returns></returns>
        public Object ResourcesLoad(string path, bool isRecycle = true)
        {
            ResourcesDto dto;

            if (_resourcesDtoDic.ContainsKey(path))
            {
                dto = _resourcesDtoDic[path];
            }
            else
            {
                Object obj = Resources.Load(path);
                if (obj != null)
                {
                    dto = new ResourcesDto(path, obj, isRecycle);
                    _resourcesDtoDic.Add(path, dto);
                    goto End;
                }
                return(null);
            }
            End : dto.LastUseTime = Time.time;
            return(dto.CacheObj);
        }
Esempio n. 5
0
        public IActionResult GetUserResources()
        {
            var response = ResourcesDto.FromController(this);

            return(Ok(response));
        }