public static Tile Create(int id, int index) { if (tiles.ContainsKey(id)) { if (tiles[id].IsTimeOut()) { tiles[id].imageId = index; DownLoadImage.Load(index, tiles[id].gameObject, "LoadComplete", Manager.Instance.IsLocal(index)); } return(tiles[id]); } else { Transform parent = GetParent(); GameObject newOne = Instantiate(Manager.Instance.tile) as GameObject; newOne.name = id.ToString(); newOne.transform.parent = parent; Tile result = newOne.GetComponent <Tile>(); result.id = id; result.imageId = index; usingTime[index] = 0; newOne.transform.position = new Vector3(id % 100, id / 100, 0); DownLoadImage.Load(index, newOne, "LoadComplete", Manager.Instance.IsLocal(index)); return(result); } }
void OnApplicationQuit() { DeleteImageDirectory(); foreach (Image image in DownLoadImage.GetTexture(Tile.SaveData())) { SaveImange(image); } }
public static void Load(int id, GameObject target, string functionName, bool local) { GameObject go = new GameObject(); DownLoadImage dl = go.AddComponent <DownLoadImage>(); dl.id = id; dl.target = target; dl.furnitureName = functionName; if (local) { dl.url = string.Format(urlFormatFile, Application.dataPath, id.ToString("d3")); } else { dl.url = string.Format(urlFormatHttp, id.ToString("d3")); } if (loaded.ContainsKey(id)) { dl.Complete(loaded[id]); } else { if (loading.ContainsKey(id)) { loading[id].Add(dl); } else { loadingList.Enqueue(id); loading[id] = new List <DownLoadImage>(); loading[id].Add(dl); if (loadingCurrent < loadingMax) { Next(); } } } }