/// <summary> /// 创建资源 /// </summary> /// <param name="subType">类型</param> /// <param name="modelId">模型id</param> /// <param name="count">数量</param> /// <param name="entityId">实体id</param> /// <param name="lastTime">持续时间</param> /// <param name="beginTime">开始时间</param> /// <param name="endTime">EndTime</param> /// <param name="isLock">所否锁定资源</param> public GameResourceObject(ResourceTypeSubEnum subType, Int32 modelId, Int64 count, Guid entityId, Int32?lastTime, DateTime?beginTime, DateTime?endTime, Boolean isLock) { this.ResourceTypeSub = subType; this.ModelId = modelId; this.Count = count; this.EntityId = entityId; this.LastTime = lastTime; this.BeginTime = beginTime; this.EndTime = endTime; this.mIsLock = isLock; }
/// <summary> /// 获取实现类 /// </summary> /// <param name="type">资源类型</param> /// <returns>实现类</returns> private static ResourceBase GetResourceImpl(ResourceTypeSubEnum type) { lock (mClassName) { if (!mResourceTypeImpl.ContainsKey(type)) { throw new Exception($"ResourceTypeSub={(Int32)type}的资源未实现"); } return(mResourceTypeImpl[type]); } }
/// <summary> /// 创建资源 /// </summary> /// <param name="subType">类型</param> /// <param name="modelId">模型id</param> /// <param name="count">数量</param> /// <param name="entityId">资源id</param> /// <param name="isLock">是否锁定资源</param> public GameResourceObject(ResourceTypeSubEnum subType, Int32 modelId, Int64 count, Guid entityId, Boolean isLock) : this(subType, modelId, count, entityId, null, null, null, isLock) { }
/// <summary> /// 创建资源 /// </summary> /// <param name="subType">类型</param> /// <param name="modelId">模型id</param> /// <param name="count">数量</param> public GameResourceObject(ResourceTypeSubEnum subType, Int32 modelId, Int64 count, Guid entityId) : this(subType, modelId, count, entityId, null, null, null, true) { }
/// <summary> /// 创建资源 /// </summary> /// <param name="subType">类型</param> /// <param name="modelId">模型id</param> /// <param name="count">数量</param> public GameResourceObject(ResourceTypeSubEnum subType, Int32 modelId, Int64 count) : this(subType, modelId, count, true) { }
/// <summary> /// 创建资源 /// </summary> /// <param name="subType">类型</param> /// <param name="count">数量</param> public GameResourceObject(ResourceTypeSubEnum subType, Int64 count) : this(subType, 0, count) { }
/// <summary> /// 将ResourceTypeSub转化为ResourceType /// </summary> /// <param name="resourceTypeSub">ResourceTypeSub</param> /// <returns>ResourceType</returns> public static ResourceTypeEnum GetResourceType(ResourceTypeSubEnum resourceTypeSub) { Int32 typeID = ((Int32)resourceTypeSub) / 100; return((ResourceTypeEnum)typeID); }
/// <summary> /// 判断游戏资源模型是否存在 /// </summary> /// <param name="resourceTypeSub">游戏资源子类型</param> /// <param name="modelId">资源模型Id</param> /// <returns>是否存在</returns> public static Boolean IfGameResourceModelExists(ResourceTypeSubEnum resourceTypeSub, Int32 modelId) { return(GetResourceImpl(resourceTypeSub).IfModelExists(modelId)); }