private void LoadAssets() { FontMgr.Add("Fonts/Arial14"); TextureMgr.Add("Sprites/Link"); TextureMgr.Add("Sprites/Leaper"); TextureMgr.Add("Sprites/character-4directions"); TextureMgr.Add("Sprites/Pistol"); TextureMgr.Add("Sprites/SMG"); TextureMgr.Add("Sprites/Shotgun"); TextureMgr.Add("Sprites/Bullet"); TextureMgr.Add("Tilesets/alttp_tiles"); TextureMgr.Add("Sprites/Monolith"); TextureMgr.Add("Sprites/Pickme"); SfxMgr.Add("Sounds/PistolShot"); SfxMgr.Add("Sounds/PistolReload"); SfxMgr.Add("Sounds/SMGShot"); SfxMgr.Add("Sounds/SMGReload"); SfxMgr.Add("Sounds/ShotgunShot"); SfxMgr.Add("Sounds/ShotgunReload"); SfxMgr.Add("Sounds/ShotgunPump"); SfxMgr.Add("Sounds/DefaultDamage"); SfxMgr.Add("Sounds/LinkDamage"); SfxMgr.Add("Sounds/LeaperDamage"); MusicMgr.Add("Music/song1"); }
public void Fill(clgf.Anim.Anim anim, clgf.Anim.Element elem, TextureMgr tmgr, string texpath) { //if (string.IsNullOrEmpty(elem.seednow)) //{ // return; //} if (anim.parent.seeds.ContainsKey(elem.seednow) == false) { return; } var seed = anim.parent.seeds[elem.seednow]; //string filename = System.IO.Path.GetFileNameWithoutExtension(elem.seed.texname); block = tmgr.GetTexture(System.IO.Path.Combine(texpath, seed.texname)); seedorient = seed.orient; seedsize = seed.size; color = elem.color; pos = elem.pos; scale = elem.scale; rotate = elem.rotate; bounds = Seed.CalcRotate(seed.size * scale, seed.orient * scale, rotate); bounds.Offset(pos.X, pos.Y); tag = elem.tag; if (tag == null) { tag = ""; } if (tag.IndexOf("dummy:") == 0) { isdummy = true; tag = tag.Substring(6); } }
public SpriteFontWithSeed(int fontsize, Sprite sprite, string baseseed, TextureMgr tmgr, string texpath) { this.fontsize = fontsize; this.baseseed = baseseed; this.sprite = sprite; this.tmgr = tmgr; this.texpath = texpath; }
public void Init(GraphicsDevice gdevice, ContentManager content, IGameState first, object tag) { apptag = tag; GraphicsDevice = gdevice; spritebatch = new SpriteBatch(gdevice); tmgr = new TextureMgr(); tmgr.Init(gdevice, content); //scene = new Scene.Scene(); ChangeState(first); }
//public DrawFrame GetFrameByAdvTime(float delta) //{ // int lastid = (int)(timer * fps); // if (play) // { // timer += delta; // } // int newid = (int)(timer * fps); // while (newid - lastid > 1) // { // timer -= 1.0f / fps;//限制不跳帧 // newid --; // } // return frames[newid]; //} public static SpriteAni CreateAni(Anim data, TextureMgr tmgr, string texpath = "") { SpriteAni ani = new SpriteAni(); ani.fps = data.fps; while (ani.frames.Count < data.frames.Count) { ani.frames.Add(new DrawFrame(data.size)); } int lastframe = 0; for (int i = 0; i < data.frames.Count; i++) { //while (ani.frames[i].drawElements.Count < data.frames[i].elems.Count) //{ // ani.frames[i].drawElements.Add(new DrawElement()); //} #region fill frame for (int j = data.frames[i].elems.Count - 1; j >= 0; j--) { if (string.IsNullOrEmpty(data.frames[i].elems[j].seednow)) { continue; } DrawElement e = new DrawElement(); //在这里要反转层顺序 Element se = data.frames[i].elems[j]; if (string.IsNullOrEmpty(se.sound) == false) { ani.frames[i].sounds.Add(se.sound); Console.WriteLine("find sound:" + se.sound); } e.Fill(data, se, tmgr, texpath); if (e.isdummy == true || string.IsNullOrWhiteSpace(se.seedasdummy) == false) { Dummy dm = new Dummy(); dm.pos = e.pos; dm.rotate = e.rotate; dm.name = e.tag; if (string.IsNullOrWhiteSpace(se.seedasdummy) == false) { dm.name = se.seedasdummy; } dm.seed = se.seed; dm.elem = e; ani.frames[i].dummys.Add(dm); } if (!e.isdummy) { ani.frames[i].drawElements.Add(e); string tag = ""; if (string.IsNullOrEmpty(se.tag) == false) { tag = se.tag; } else { tag = ""; } if (tag != "") { if (ani.frames[i].bounds.ContainsKey("") == false) { ani.frames[i].bounds[""] = e.bounds; } else { RectangleF src = ani.frames[i].bounds[""]; ani.frames[i].bounds[""] = RectangleF.Union(src, e.bounds); } } if (ani.frames[i].bounds.ContainsKey(tag) == false) { ani.frames[i].bounds[tag] = e.bounds; } else { RectangleF src = ani.frames[i].bounds[tag]; ani.frames[i].bounds[tag] = RectangleF.Union(src, e.bounds); } } } #endregion if (i == 0 && data.frames[0].frametags.Count == 0) { ani.elements["in"] = new AniElement(ani, 0, data.frames.Count - 1, false); } if (i == data.frames.Count - 1 && data.frames[i].frametags.Count == 0 && lastframe > 0) { ani.elements["out"] = new AniElement(ani, lastframe + 1, data.frames.Count - 1, false); } if (data.frames[i].frametags.Count > 0) { lastframe = i; if (ani.elements.ContainsKey("in")) { if (ani.elements["in"].frameend == data.frames.Count - 1) { ani.elements["in"].frameend = i - 1; ani.elements["in"].FixLife(); } } } foreach (var tag in data.frames[i].frametags) { if (ani.elements.ContainsKey(tag)) { ani.elements[tag].frameend = i; ani.elements[tag].FixLife(); } else { ani.elements[tag] = new AniElement(ani, i, i, true); } } } string[] ttags = new string[ani.framecount]; foreach (var e in ani.elements) { for (int i = e.Value.framestart; i <= e.Value.frameend; i++) { ttags[i] = e.Key; } } string begintag = ""; int begini = 0; for (int i = 0; i < ani.framecount; i++) { if (string.IsNullOrEmpty(ttags[i]) == false) { if (begintag != ttags[i]) { if (begintag == "") { } else { string endtag = ttags[i]; if (begini + 1 <= i - 1) { ani.elements[begintag + "-" + endtag] = new AniElement(ani, begini + 1, i - 1, false); } } } begintag = ttags[i]; begini = i; } } ani.allelement = new AniElement(ani, 0, ani.framecount - 1, true); return(ani); }