// public virtual void Request(string path , RESOURCE_TYPE resType = RESOURCE_TYPE.WEB_ASSETBUNLDE , long utime = 0 ) { if( !this.m_mapRes.ContainsKey(path) ) { this.m_lstPath.Add(path); this.m_lstResType.Add(resType); this.m_lstFTime.Add(utime); this.m_mapRes.Add(path,null); } }
public void AddPreLoadResource(RESOURCE_TYPE type, string path) { switch(type) { case RESOURCE_TYPE.RESOURCE_PREFAB: prefabLoadList.Add(path); break; case RESOURCE_TYPE.RESOURCE_TEXTURE: textureLoadList.Add(path); break; case RESOURCE_TYPE.RESOURCE_TEXTASSET: textAssetLoadList.Add(path); break; } }
public ResourceRequireData( string path , bool autosave , long utime , bool autoClear , RESOURCE_TYPE type, ENCRYPT_TYPE encrypt_type, DecryptBytesFunc decryptFunc ) { this.m_strFilePath = path; this.m_cPathUri = new Uri(path); this.m_lUTime = utime; this.m_bAutoSave = autosave; this.m_bAutoClear = autoClear; this.m_eResType = type; this.m_eEncryType = encrypt_type; this.m_funDecryptFunc = decryptFunc; this.m_fLastUseTime = Time.fixedTime; }
/// <summary> /// 开始WW加载 /// </summary> /// <param name="path"></param> /// <param name="crc"></param> /// <param name="version"></param> /// <param name="callback"></param> /// <param name="res_type"></param> /// <param name="encrypt_type"></param> /// <param name="decryptFunc"></param> public static LoadPackage StartWWW( string path , bool autosave = false , long utime = 0 , DOWN_FINISH_CALLBACK callback = null, DOWN_ERROR_CALLBACK error_call = null, RESOURCE_TYPE res_type = RESOURCE_TYPE.WEB_ASSETBUNLDE, ENCRYPT_TYPE encrypt_type = ENCRYPT_TYPE.NORMAL, DecryptBytesFunc decryptFunc = null ) { GameObject obj = new GameObject("WWWLoad"); LoadPackage loader = obj.AddComponent<LoadPackage>(); loader.Init( path , autosave ,utime , callback,error_call, res_type, encrypt_type, decryptFunc); loader.StartCoroutine("Load"); return loader; }
private void Load(string path, RESOURCE_TYPE type) { Event evt = new Event(EVT_TYPE.EVT_TYPE_PRELOAD_PARTIAL_FINISH); switch (type) { case RESOURCE_TYPE.RESOURCE_PREFAB: GameObject obj = Resources.Load<GameObject>(path); if (obj == null) { GameManager.Instance.SendEvent(EVT_TYPE.EVT_TYPE_LOAD_FAILED,path); return; } evt.evt_obj.Add(obj); if (!loadedObjects.ContainsKey(path)) loadedObjects[path] = obj; break; case RESOURCE_TYPE.RESOURCE_TEXTURE: Sprite sprite = Resources.Load<Sprite>(path); if (sprite == null) { GameManager.Instance.SendEvent(EVT_TYPE.EVT_TYPE_LOAD_FAILED,path); return; } evt.evt_obj.Add(sprite); if (!loadedSprites.ContainsKey(path)) loadedSprites[path] = sprite; break; case RESOURCE_TYPE.RESOURCE_TEXTASSET: TextAsset text = Resources.Load<TextAsset>(path); if (text == null) { GameManager.Instance.SendEvent(EVT_TYPE.EVT_TYPE_LOAD_FAILED,path); return; } evt.evt_obj.Add(text); if (!loadedTextAssets.ContainsKey(path)) loadedTextAssets[path] = text; break; } currentLoaded++; evt.evt_obj.Add((float)currentLoaded / totalLoad); GameManager.Instance.SendEvent(evt); }
public void SetResourceType(RESOURCE_TYPE _type) { this.resType = _type; }
private static extern ScDomResult SciterHttpRequest(IntPtr he, [MarshalAs(UnmanagedType.LPWStr)] String url, RESOURCE_TYPE dataType, uint requestType, IntPtr requestParams, uint nParams);
public void SetAmount(RESOURCE_TYPE type, int value) { ResType = type; ResAmount[(int)type] = value; }
public void extractResource(RESOURCE_TYPE type, string path) { //Extract each resource type so that it will be available when the VisualNovelOperation executes }
private static extern ScDomResult SciterRequestElementData(IntPtr he, [MarshalAs(UnmanagedType.LPWStr)] String url, RESOURCE_TYPE dataType, IntPtr initiator);
/// <summary> /// 初始化 /// </summary> /// <param name="id"></param> private void Init( string path , bool autosave = false, long utime = 0, DOWN_FINISH_CALLBACK callback = null, DOWN_ERROR_CALLBACK error_call = null, RESOURCE_TYPE res_type = RESOURCE_TYPE.WEB_ASSETBUNLDE, ENCRYPT_TYPE encrypt_type = ENCRYPT_TYPE.NORMAL, DecryptBytesFunc decryptFunc = null ) { this.m_strPath = path; this.m_lUTime = utime; this.m_bComplete = false; this.m_cWww = null; this.m_cCallBack = callback; this.m_cErrorCallBack = error_call; this.m_delDecryptFunc = decryptFunc; this.m_eEncryptType = encrypt_type; this.m_eResType = res_type; this.m_fProgess = 0; this.m_bAutoSave = autosave; }
// Use this for initialization void Start() { myRType = RESOURCE_TYPE.DEFAULT; }
public Event_BuildingYield(RESOURCE_TYPE type, float amount) { this.type = type; this.amount = amount; }
public int GetAmount(RESOURCE_TYPE type) { return(ResAmount[(int)type]); }
public static extern int WNetOpenEnum(RESOURCE_SCOPE dwScope , RESOURCE_TYPE dwType , RESOURCE_USAGE dwUsage , ref NETRESOURCE lpNetResource , ref IntPtr lphEnum);
static extern int WNetOpenEnum(RESOURCE_SCOPE dwScope, RESOURCE_TYPE dwType, RESOURCE_USAGE dwUsage, [MarshalAs(UnmanagedType.AsAny)][In] object lpNetResource, out IntPtr lphEnum);
private static extern ScDomResult SciterHttpRequest(IntPtr he, [MarshalAs(UnmanagedType.LPWStr)] String url, RESOURCE_TYPE dataType, uint requestType, IntPtr requestParams, uint nParams);
public void Load(BinaryReader reader, int header) { ResType = (RESOURCE_TYPE)reader.ReadByte(); ResAmount[(int)ResType] = reader.ReadInt32(); }
public static bool RunItemTransaction(Cargo sellerCargo, Cargo buyerCargo, RESOURCE_TYPE resourceType, uint amount, float pricePerUnit, bool adjustTransaction = false) { // Get owning party of buyer uint buyerFactionID = 0; uint sellerFactionID = 0; var buyerOwnership = buyerCargo.GetComponent <Ownership>(); var sellerOwnership = sellerCargo.GetComponent <Ownership>(); if (buyerOwnership != null) { buyerFactionID = buyerOwnership.OwnerFactionID; } if (sellerOwnership != null) { sellerFactionID = sellerOwnership.OwnerFactionID; } // TODO add treasury for NPC factions. For now, only player has to pay. float totalPrice = pricePerUnit * amount; bool transactionSuccessful = true; if (buyerFactionID == 1 && GameManager.PlayerCash < totalPrice) // player faction { Debug.LogError("Error during trading - player doesn't have enough cash"); return(false); } // Do the transaction uint withdrawn; if (!sellerCargo.WithdrawResourceToMax((uint)resourceType, amount, out withdrawn) && !(adjustTransaction && withdrawn > 0)) { // Cancel transaction Debug.LogError("Error during trading - the seller does not have the necessary resources in cargo"); sellerCargo.AddResource((uint)resourceType, withdrawn); transactionSuccessful = false; } else { if (adjustTransaction) { totalPrice = withdrawn * pricePerUnit; } // Transfer to buyer uint added; if (!buyerCargo.AddResource((uint)resourceType, withdrawn, out added) && !(adjustTransaction && added > 0)) { // Cancel transaction Debug.LogError("Error during trading - the buyer does not have the necessary cargo space !"); sellerCargo.AddResource((uint)resourceType, withdrawn); buyerCargo.WithdrawResourceToMax((uint)resourceType, added, out added); transactionSuccessful = false; } else if (adjustTransaction && added != withdrawn) { uint n = withdrawn - added; sellerCargo.AddResource((uint)resourceType, n); } } if (transactionSuccessful && buyerFactionID == 1) { GameManager.RemoveCash((int)totalPrice); } else if (transactionSuccessful && sellerFactionID == 1) { GameManager.AddCash((int)totalPrice); } return(transactionSuccessful); }
public void SellTo(Cargo cargo, RESOURCE_TYPE resourceType, uint amount, float pricePerUnit, bool adjustTransaction = false) { RunItemTransaction(cargoComponent, cargo, resourceType, amount, pricePerUnit, adjustTransaction); }
public static extern int WNetOpenEnum(RESOURCE_SCOPE dwScope, RESOURCE_TYPE dwType, RESOURCE_USAGE dwUsage, [MarshalAs(UnmanagedType.AsAny)][In] Object lpNetResource, out IntPtr lphEnum);
/// <summary> /// Requests the resouce. /// </summary> /// <returns>The resouce.</returns> /// <param name="path">Path.</param> /// <param name="autoSave">If set to <c>true</c> auto save.</param> /// <param name="utime">Utime.</param> /// <param name="autoClear">If set to <c>true</c> auto clear.</param> /// <param name="resType">Res type.</param> /// <param name="encrypt_type">Encrypt_type.</param> /// <param name="func">Func.</param> /// <param name="error_call">Error_call.</param> /// <param name="arg">Argument.</param> public static ResourceRequireOwner RequestResouce( string path , bool autoSave , long utime , bool autoClear , RESOURCE_TYPE resType, ENCRYPT_TYPE encrypt_type, REQUEST_FINISH_CALLBACK func , REQUEST_ERROR_CALLBACK error_call,object[] arg ) { if (sInstance.m_delDecryptFunc == null && encrypt_type == ENCRYPT_TYPE.ENCRYPT ) { // Error // 没有资源解密接口 return null; } string resName = (new Uri(path)).AbsolutePath; ResourceRequireOwner owner = new ResourceRequireOwner(); owner.m_cResName = resName; // owner.m_strResValue = resValue; owner.m_delCallBack = func; owner.m_delErrorCall = error_call; owner.m_eResType = resType; owner.m_vecArg = arg; if ( sInstance.m_eLoadType != LOAD_TYPE.NORMAL ) { UnityEngine.Object obj = LoadEditor(resName); if (!sInstance.m_mapRes.ContainsKey(resName)) { object resData = null; switch( resType ) { case RESOURCE_TYPE.WEB_ASSETBUNLDE: case RESOURCE_TYPE.WEB_TEXTURE: resData = obj; break; case RESOURCE_TYPE.WEB_TEXT_BYTES: resData = (obj as TextAsset).bytes; break; case RESOURCE_TYPE.WEB_TEXT_STR: resData = (obj as TextAsset).text; break; } ResourceRequireData data = new ResourceRequireData(resData); sInstance.m_mapRes.Add(resName, data); } sInstance.m_mapRes[resName].AddRequireOwner(owner); sInstance.m_mapRes[resName].Used(); if(sInstance.m_mapRes[resName].Complete) { sInstance.m_mapRes[resName].CompleteCallBack(); } return owner; } if (sInstance.m_mapRes.ContainsKey(resName)) { //增加需求者 sInstance.m_mapRes[resName].AddRequireOwner(owner); sInstance.m_mapRes[resName].Used(); if (sInstance.m_mapRes[resName].Complete) { sInstance.m_mapRes[resName].CompleteCallBack(); } } else { ResourceRequireData rrd = new ResourceRequireData( path , autoSave ,utime ,autoClear, resType, encrypt_type, sInstance.m_delDecryptFunc); sInstance.m_lstRequires.Add(rrd); sInstance.m_mapRes.Add(resName, rrd); rrd.AddRequireOwner(owner); } return owner; }
/// <summary> /// Requests the resouce. /// </summary> /// <returns>The resouce.</returns> /// <param name="path">Path.</param> /// <param name="autoSave">If set to <c>true</c> auto save.</param> /// <param name="utime">Utime.</param> /// <param name="autoClear">If set to <c>true</c> auto clear.</param> /// <param name="resType">Res type.</param> /// <param name="encrypt_type">Encrypt_type.</param> /// <param name="func">Func.</param> /// <param name="error_call">Error_call.</param> /// <param name="arg">Argument.</param> public static ResourceRequireOwner RequestResouce( string path, bool autoSave, long utime, bool autoClear, RESOURCE_TYPE resType, ENCRYPT_TYPE encrypt_type, REQUEST_FINISH_CALLBACK func, REQUEST_ERROR_CALLBACK error_call, object[] arg ) { if (sInstance.m_delDecryptFunc == null && encrypt_type == ENCRYPT_TYPE.ENCRYPT) { // Error // 没有资源解密接口 return(null); } string resName = (new Uri(path)).AbsolutePath; ResourceRequireOwner owner = new ResourceRequireOwner(); owner.m_cResName = resName; // owner.m_strResValue = resValue; owner.m_delCallBack = func; owner.m_delErrorCall = error_call; owner.m_eResType = resType; owner.m_vecArg = arg; if (sInstance.m_eLoadType != LOAD_TYPE.NORMAL) { UnityEngine.Object obj = LoadEditor(resName); if (!sInstance.m_mapRes.ContainsKey(resName)) { object resData = null; switch (resType) { case RESOURCE_TYPE.WEB_ASSETBUNLDE: case RESOURCE_TYPE.WEB_TEXTURE: resData = obj; break; case RESOURCE_TYPE.WEB_TEXT_BYTES: resData = (obj as TextAsset).bytes; break; case RESOURCE_TYPE.WEB_TEXT_STR: resData = (obj as TextAsset).text; break; } ResourceRequireData data = new ResourceRequireData(resData); sInstance.m_mapRes.Add(resName, data); } sInstance.m_mapRes[resName].AddRequireOwner(owner); sInstance.m_mapRes[resName].Used(); if (sInstance.m_mapRes[resName].Complete) { sInstance.m_mapRes[resName].CompleteCallBack(); } return(owner); } if (sInstance.m_mapRes.ContainsKey(resName)) { //增加需求者 sInstance.m_mapRes[resName].AddRequireOwner(owner); sInstance.m_mapRes[resName].Used(); if (sInstance.m_mapRes[resName].Complete) { sInstance.m_mapRes[resName].CompleteCallBack(); } } else { ResourceRequireData rrd = new ResourceRequireData( path, autoSave, utime, autoClear, resType, encrypt_type, sInstance.m_delDecryptFunc); sInstance.m_lstRequires.Add(rrd); sInstance.m_mapRes.Add(resName, rrd); rrd.AddRequireOwner(owner); } return(owner); }
private static extern ScDomResult SciterRequestElementData(IntPtr he, [MarshalAs(UnmanagedType.LPWStr)] String url, RESOURCE_TYPE dataType, IntPtr initiator);
public Resource(RESOURCE_TYPE _rType, int _count) { this.resType = _rType; this.count = _count; }