public AnimatedTexture(string asset, string name, string extension, TextureRecs textureRecs, bool orderAsc, int framesPerSec) { Asset = asset; Name = name; //MultiPicture = false; width = textureRecs.Recs[0].Width; height = textureRecs.Recs[0].Height; OrderAsc = orderAsc; //myTexture = CacheManager.Load(asset); //, extension, textureRecs.IsLive ? CacheLiveType.Live : CacheLiveType.Scene, false); if (OrderAsc) { Recs = textureRecs.Recs; } else { //Recs = textureRecs.Recs.Select(re => new Rectangle(myTexture.Width - re.X - re.Width, re.Y, re.Width, re.Height)).ToArray(); Recs = textureRecs.Recs.Select(re => new Rectangle(textureRecs.Width - re.X - re.Width, re.Y, re.Width, re.Height)).ToArray(); } FrameCount = Recs.Length; //width = (myTextures[0].Width * assets.Length) / frameCount; TimePerFrame = (float)1 / framesPerSec; Frame = 0; TotalElapsed = 0; Paused = false; }
static Texture2D LoadTexture(string name, bool isUser, bool isTemp, TextureShape shape, float[] shapeParms) { var dics = isTemp ? TextureTempDics : TextureDics; Texture2D tex = null; bool reload = false; lock (dics) { if (dics != null && (!dics.TryGetValue(name, out tex) || tex != null && tex.IsDisposed)) { reload = true; if (tex != null) { dics.Remove(name); } } } if (reload) { string res = ""; if (isUser) { res = name; } else { //res = "Textures" + Platform.Current.GetSlash + name; res = name; if (!name.Contains(".")) { TextureRecs rec = Session.TextureRecs.FirstOrDefault(te => te.Key.Split('#')[0] == name).Value; res = res + "." + rec.Ext; } else { } } tex = Platform.Current.LoadTexture(res, isUser); GameTools.ProcessTextureShape(tex, shape, shapeParms); lock (dics) { if (tex == null) { dics.Add(name, null); } else { dics.Add(name, tex); } } } return(tex); }