protected override void LoadContent() { // Create a new SpriteBatch, which can be used to draw textures. spriteBatch = new SpriteBatch(GraphicsDevice); basicFont = Content.Load <SpriteFont>("basicFont"); skeletonRenderer = new SkeletonMeshRenderer(graphics.GraphicsDevice); spineboy = Content.Load <SpineAsset>("spineboy"); spineboy.AnimationState.SetAnimation(0, spineboy.SkeletonData.Animations.Items[0].Name, true); spineboy.Skeleton.X += 400; spineboy.Skeleton.Y += this.GraphicsDevice.Viewport.Height; spineboy.Skeleton.UpdateWorldTransform(); }
private void OpenGLControl_OnOpenGLInitialized(object sender, OpenGLEventArgs args) { var gl = args.OpenGL; gl.Enable(OpenGL.GL_TEXTURE_2D); gl.Enable(OpenGL.GL_BLEND); gl.BlendFunc(OpenGL.GL_SRC_ALPHA, OpenGL.GL_ONE_MINUS_SRC_ALPHA); SkeletonLoader.gl = gl; skeletonRenderer = new SkeletonMeshRenderer(gl); isGLReady = true; }
public override void Draw(SpriteBatch sprite, SkeletonMeshRenderer skeletonMeshRenderer, GameTime gameTime, int mapShiftX, int mapShiftY, int centerX, int centerY, ReflectionDrawableBoundary drawReflectionInfo, int RenderWidth, int RenderHeight, float RenderObjectScaling, RenderResolution mapRenderResolution, int TickCount) { // control minimap render UI position via // Position.X, Position.Y // Draw the main drame base.Draw(sprite, skeletonMeshRenderer, gameTime, 0, 0, centerX, centerY, drawReflectionInfo, RenderWidth, RenderHeight, RenderObjectScaling, mapRenderResolution, TickCount); int minimapPosX = (mapShiftX + (RenderWidth / 2)) / 16; int minimapPosY = (mapShiftY + (RenderHeight / 2)) / 16; item_pixelDot.Draw(sprite, skeletonMeshRenderer, gameTime, -Position.X, -Position.Y, minimapPosX, minimapPosY, drawReflectionInfo, RenderWidth, RenderHeight, RenderObjectScaling, mapRenderResolution, TickCount); //IDXObject lastFrameDrawn = base.LastFrameDrawn; //int minimapMainFrameWidth = lastFrameDrawn.Width; //int minimapMainFrameHeight = lastFrameDrawn.Height; // draw minimap buttons foreach (MapObjects.UIObject.UIObject uiBtn in uiButtons) { BaseDXDrawableItem buttonToDraw = uiBtn.GetBaseDXDrawableItemByState(); // Position drawn is relative to the MinimapItem int drawRelativeX = -(this.Position.X) - uiBtn.X; // Left to right int drawRelativeY = -(this.Position.Y) - uiBtn.Y; // Top to bottom buttonToDraw.Draw(sprite, skeletonMeshRenderer, gameTime, drawRelativeX, drawRelativeY, centerX, centerY, null, RenderWidth, RenderHeight, RenderObjectScaling, mapRenderResolution, TickCount); } }
public void DrawObject(SpriteBatch sprite, SkeletonMeshRenderer skeletonMeshRenderer, GameTime gameTime, int mapShiftX, int mapShiftY, bool flip) { spineObject.state.Update(gameTime.ElapsedGameTime.Milliseconds / 1000f); spineObject.state.Apply(spineObject.skeleton); spineObject.skeleton.FlipX = flip; spineObject.skeleton.X = X - mapShiftX; spineObject.skeleton.Y = Y - mapShiftY; spineObject.skeleton.UpdateWorldTransform(); skeletonMeshRenderer.PremultipliedAlpha = spineObject.spineAnimationItem.PremultipliedAlpha; skeletonMeshRenderer.Begin(); skeletonMeshRenderer.Draw(spineObject.skeleton); skeletonMeshRenderer.End(); }
/// <summary> /// Draw /// </summary> /// <param name="sprite"></param> /// <param name="skeletonMeshRenderer"></param> /// <param name="mapShiftX"></param> /// <param name="mapShiftY"></param> /// <param name="centerX"></param> /// <param name="centerY"></param> /// <param name="width"></param> /// <param name="height"></param> /// <param name="TickCount">Ticks since system startup</param> public virtual void Draw(SpriteBatch sprite, SkeletonMeshRenderer skeletonMeshRenderer, GameTime gameTime, int mapShiftX, int mapShiftY, int centerX, int centerY, int width, int height, float RenderObjectScaling, MapRenderResolution mapRenderResolution, int TickCount) { if (notAnimated) { if (frame0.X - mapShiftX + frame0.Width > 0 && frame0.Y - mapShiftY + frame0.Height > 0 && frame0.X - mapShiftX < width && frame0.Y - mapShiftY < height) { frame0.DrawObject(sprite, skeletonMeshRenderer, gameTime, mapShiftX, mapShiftY, flip); } } else { GetCurrFrame(TickCount).DrawObject(sprite, skeletonMeshRenderer, gameTime, mapShiftX, mapShiftY, flip); } }
public SpineObject(GraphicsDevice Graphics, string filename, float scale, Vector2 pos, string headSlot = "head") { skeletonRenderer = new SkeletonMeshRenderer(Graphics); skeletonRenderer.PremultipliedAlpha = true; Atlas atlas = new Atlas("Content/" + filename + ".atlas", new XnaTextureLoader(Graphics)); SkeletonData skeletonData; SkeletonJson json = new SkeletonJson(atlas); json.Scale = scale; skeletonData = json.ReadSkeletonData("Content/" + filename + ".json"); skeleton = new Skeleton(skeletonData); AnimationStateData stateData = new AnimationStateData(skeleton.Data); state = new AnimationState(stateData); this.pos = pos; this.headSlot = skeleton.FindSlot(headSlot); }
public void LoadContent(ContentManager contentManager) { skeletonRenderer = new SkeletonMeshRenderer(App.graphicsDevice); skeletonRenderer.PremultipliedAlpha = App.GV.Alpha; atlas = new Atlas(App.GV.SelectFile, new XnaTextureLoader(App.graphicsDevice)); json = new SkeletonJson(atlas); json.Scale = App.GV.Scale; skeletonData = json.ReadSkeletonData(Common.GetJsonPath(App.GV.SelectFile)); skeleton = new Skeleton(skeletonData); if (App.isNew) { App.GV.PosX = Convert.ToSingle(App.GV.FrameWidth / 2f); App.GV.PosY = Convert.ToSingle((skeleton.Data.Height + App.GV.FrameHeight) / 2f); } App.GV.FileHash = skeleton.Data.Hash; stateData = new AnimationStateData(skeleton.Data); state = new AnimationState(stateData); App.GV.AnimeList = state.Data.skeletonData.Animations.Select(x => x.Name).ToList(); App.GV.SkinList = state.Data.skeletonData.Skins.Select(x => x.Name).ToList(); if (App.GV.SelectAnimeName != "") { state.SetAnimation(0, App.GV.SelectAnimeName, App.GV.IsLoop); } else { state.SetAnimation(0, state.Data.skeletonData.animations[0].name, App.GV.IsLoop); } if (App.isNew) { MainWindow.SetCBAnimeName(); } App.isNew = false; }
public void DrawBackground(SpriteBatch sprite, SkeletonMeshRenderer skeletonMeshRenderer, GameTime gameTime, int x, int y, Color color, bool flip, ReflectionDrawableBoundary drawReflectionInfo) { spineObject.state.Update(gameTime.ElapsedGameTime.Milliseconds / 1000f); spineObject.state.Apply(spineObject.skeleton); //if (spineObject.skeleton.FlipX != flip || spineObject.skeleton.X != x || spineObject.skeleton.Y != y) // reduce the number of updates [removed, recent spine object includes the ones that does not move] //{ spineObject.skeleton.FlipX = flip; spineObject.skeleton.X = x; //x + (Width); spineObject.skeleton.Y = y; //y + (Height / 2); spineObject.skeleton.UpdateWorldTransform(); //} skeletonMeshRenderer.PremultipliedAlpha = spineObject.spineAnimationItem.PremultipliedAlpha; skeletonMeshRenderer.Begin(); skeletonMeshRenderer.Draw(spineObject.skeleton); skeletonMeshRenderer.End(); }
public void DrawBackground(SpriteBatch sprite, SkeletonMeshRenderer skeletonMeshRenderer, GameTime gameTime, int x, int y, Color color, bool flip) { spineObject.state.Update(gameTime.ElapsedGameTime.Milliseconds / 1000f); spineObject.state.Apply(spineObject.skeleton); if (spineObject.skeleton.FlipX != flip || spineObject.skeleton.X != x || spineObject.skeleton.Y != y) // reduce the number of updates { spineObject.skeleton.FlipX = flip; spineObject.skeleton.X = x; //x + (Width); spineObject.skeleton.Y = y; //y + (Height / 2); spineObject.skeleton.UpdateWorldTransform(); } skeletonMeshRenderer.PremultipliedAlpha = spineObject.spineAnimationItem.PremultipliedAlpha; skeletonMeshRenderer.Begin(); skeletonMeshRenderer.Draw(spineObject.skeleton); skeletonMeshRenderer.End(); }
private void DrawHVCopies(SpriteBatch sprite, SkeletonMeshRenderer skeletonMeshRenderer, GameTime gameTime, int simWidth, int simHeight, int x, int y, int cx, int cy, IDXObject frame) { int width = frame.Width; DrawVerticalCopies(sprite, skeletonMeshRenderer, gameTime, simHeight, x, y, cy, frame); int copyX = x - cx; while (copyX + width > 0) { DrawVerticalCopies(sprite, skeletonMeshRenderer, gameTime, simHeight, copyX, y, cy, frame); copyX -= cx; } copyX = x + cx; while (copyX < simWidth) { DrawVerticalCopies(sprite, skeletonMeshRenderer, gameTime, simHeight, copyX, y, cy, frame); copyX += cx; } }
private void DrawVerticalCopies(SpriteBatch sprite, SkeletonMeshRenderer skeletonMeshRenderer, GameTime gameTime, int simHeight, int x, int y, int cy, IDXObject frame) { int height = frame.Height; Draw2D(sprite, skeletonMeshRenderer, gameTime, x, y, frame); int copyY = y - cy; while (copyY + height > 0) { Draw2D(sprite, skeletonMeshRenderer, gameTime, x, copyY, frame); copyY -= cy; } copyY = y + cy; while (copyY < simHeight) { Draw2D(sprite, skeletonMeshRenderer, gameTime, x, copyY, frame); copyY += cy; } }
public override void Draw(SpriteBatch sprite, SkeletonMeshRenderer skeletonMeshRenderer, GameTime gameTime, int mapShiftX, int mapShiftY, int centerX, int centerY, int RenderWidth, int RenderHeight, float RenderObjectScaling, RenderResolution mapRenderResolution, int TickCount) { // control minimap render UI position via // Position.X, Position.Y // Draw the main drame base.Draw(sprite, skeletonMeshRenderer, gameTime, 0, 0, centerX, centerY, RenderWidth, RenderHeight, RenderObjectScaling, mapRenderResolution, TickCount); int minimapPosX = (mapShiftX + (RenderWidth / 2)) / 16; int minimapPosY = (mapShiftY + (RenderHeight / 2)) / 16; item_pixelDot.Draw(sprite, skeletonMeshRenderer, gameTime, -Position.X, -Position.Y, minimapPosX, minimapPosY, RenderWidth, RenderHeight, RenderObjectScaling, mapRenderResolution, TickCount); }
/// <summary> /// Draw /// </summary> /// <param name="sprite"></param> /// <param name="skeletonMeshRenderer"></param> /// <param name="gameTime"></param> /// <param name="mapShiftX"></param> /// <param name="mapShiftY"></param> /// <param name="centerX"></param> /// <param name="centerY"></param> /// <param name="renderWidth"></param> /// <param name="renderHeight"></param> /// <param name="RenderObjectScaling"></param> /// <param name="mapRenderResolution"></param> /// <param name="TickCount"></param> public override void Draw(SpriteBatch sprite, SkeletonMeshRenderer skeletonMeshRenderer, GameTime gameTime, int mapShiftX, int mapShiftY, int centerX, int centerY, int renderWidth, int renderHeight, float RenderObjectScaling, MapRenderResolution mapRenderResolution, int TickCount) { Point MousePos = Mouse.GetState().Position; // relative to the window already if ((mouseCursorItemStates & (int)MouseCursorItemStates.LeftPress) != (int)MouseCursorItemStates.LeftPress && (mouseCursorItemStates & (int)MouseCursorItemStates.RightPress) != (int)MouseCursorItemStates.RightPress) // default { base.Draw(sprite, skeletonMeshRenderer, gameTime, -MousePos.X, -MousePos.Y, centerX, centerY, renderWidth, renderHeight, RenderObjectScaling, mapRenderResolution, TickCount); } else // if left or right press is active, draw pressed state { cursorItemPressedState.Draw(sprite, skeletonMeshRenderer, gameTime, -MousePos.X, -MousePos.Y, centerX, centerY, renderWidth, renderHeight, RenderObjectScaling, mapRenderResolution, TickCount); } }
public void LoadContent(ContentManager contentManager) { skeletonRenderer = new SkeletonMeshRenderer(App.graphicsDevice); skeletonRenderer.PremultipliedAlpha = App.globalValues.Alpha; atlas = new Atlas(App.globalValues.SelectAtlasFile, new XnaTextureLoader(App.graphicsDevice)); if (Common.IsBinaryData(App.globalValues.SelectSpineFile)) { binary = new SkeletonBinary(atlas); binary.Scale = App.globalValues.Scale; skeletonData = binary.ReadSkeletonData(App.globalValues.SelectSpineFile); } else { json = new SkeletonJson(atlas); json.Scale = App.globalValues.Scale; skeletonData = json.ReadSkeletonData(App.globalValues.SelectSpineFile); } App.globalValues.SpineVersion = skeletonData.Version; skeleton = new Skeleton(skeletonData); Common.SetInitLocation(skeleton.Data.Height); App.globalValues.FileHash = skeleton.Data.Hash; stateData = new AnimationStateData(skeleton.Data); state = new AnimationState(stateData); List <string> AnimationNames = new List <string>(); listAnimation = state.Data.skeletonData.Animations; foreach (Animation An in listAnimation) { AnimationNames.Add(An.name); } App.globalValues.AnimeList = AnimationNames; List <string> SkinNames = new List <string>(); listSkin = state.Data.skeletonData.Skins; foreach (Skin Sk in listSkin) { SkinNames.Add(Sk.name); } App.globalValues.SkinList = SkinNames; if (App.globalValues.SelectAnimeName != "") { state.SetAnimation(0, App.globalValues.SelectAnimeName, App.globalValues.IsLoop); } else { state.SetAnimation(0, state.Data.skeletonData.animations.Items[0].name, App.globalValues.IsLoop); } if (App.isNew) { MainWindow.SetCBAnimeName(); } App.isNew = false; }
public virtual void DrawAnimation(SkeletonMeshRenderer skeletonRenderer) { }
public void DrawObject(Microsoft.Xna.Framework.Graphics.SpriteBatch spriteBatch, SkeletonMeshRenderer meshRenderer, GameTime gameTime, int mapShiftX, int mapShiftY, bool flip, ReflectionDrawableBoundary drawReflectionInfo) { int drawX = X - mapShiftX; int drawY = Y - mapShiftY; spriteBatch.Draw(texture, new Rectangle(drawX, drawY, texture.Width, texture.Height), null, // src rectangle Color.White, // color 0f, // angle new Vector2(0f, 0f), // origin flip ? SpriteEffects.FlipHorizontally : SpriteEffects.None, // flip 0f // layer depth ); if (drawReflectionInfo != null && drawReflectionInfo.Reflection) { const float reflectionAngle = 0f; // using flip instead of angle // TODO gradient in an optimized way.. hm spriteBatch.Draw(texture, new Rectangle(drawX, drawY, texture.Width, texture.Height), null, // src rectangle _REFLECTION_OPACITY_COLOR, reflectionAngle, new Vector2(0, -texture.Height), // origin flip ? SpriteEffects.FlipHorizontally | SpriteEffects.FlipVertically : SpriteEffects.None | SpriteEffects.FlipVertically, 0f // layer depth ); } }
public void DrawBackground(Microsoft.Xna.Framework.Graphics.SpriteBatch sprite, SkeletonMeshRenderer meshRenderer, GameTime gameTime, int x, int y, Color color, bool flip, ReflectionDrawableBoundary drawReflectionInfo) { sprite.Draw(texture, new Rectangle(x, y, texture.Width, texture.Height), null, color, 0f, new Vector2(0f, 0f), flip ? SpriteEffects.FlipHorizontally : SpriteEffects.None, 0f); }
public void Draw2D(SpriteBatch sprite, SkeletonMeshRenderer skeletonRenderer, GameTime gameTime, int x, int y, IDXObject frame) { frame.DrawBackground(sprite, skeletonRenderer, gameTime, x, y, Color, flip); }
public void Draw() { if (App.GV.SpineVersion != "3.4.02" || App.GV.FileHash != skeleton.Data.Hash) { state = null; skeletonRenderer = null; return; } App.graphicsDevice.Clear(Color.Transparent); Player.DrawBG(ref App.spriteBatch); state.Update(App.GV.Speed / 1000f); if (binary != null) { if (App.GV.Scale != binary.Scale) { binary.Scale = App.GV.Scale; skeletonData = binary.ReadSkeletonData(Common.GetSkelPath(App.GV.SelectFile)); skeleton = new Skeleton(skeletonData); } } else if (json != null) { if (App.GV.Scale != json.Scale) { json.Scale = App.GV.Scale; skeletonData = json.ReadSkeletonData(Common.GetJsonPath(App.GV.SelectFile)); skeleton = new Skeleton(skeletonData); } } skeleton.X = App.GV.PosX; skeleton.Y = App.GV.PosY; skeleton.FlipX = App.GV.FilpX; skeleton.FlipY = App.GV.FilpY; skeleton.RootBone.Rotation = App.GV.Rotation; skeleton.UpdateWorldTransform(); state.TimeScale = App.GV.TimeScale; state.Apply(skeleton); skeletonRenderer.PremultipliedAlpha = App.GV.Alpha; skeletonRenderer.Begin(); skeletonRenderer.Draw(skeleton); skeletonRenderer.End(); if (state != null) { TrackEntry entry = state.GetCurrent(0); if (entry != null) { if (App.GV.IsRecoding && App.GV.GifList != null && entry.LastTime < entry.EndTime) { if (App.GV.GifList.Count == 0) { TrackEntry te = state.GetCurrent(0); te.Time = 0; App.GV.TimeScale = 1; App.GV.Lock = 0; } App.GV.GifList.Add(Common.TakeRecodeScreenshot(App.graphicsDevice)); } if (App.GV.IsRecoding && entry.LastTime >= entry.EndTime) { state.TimeScale = 0; App.GV.IsRecoding = false; Common.RecodingEnd(entry.EndTime); state.TimeScale = 1; App.GV.TimeScale = 1; } if (App.GV.TimeScale == 0) { entry.Time = entry.EndTime * App.GV.Lock; entry.TimeScale = 0; } else { App.GV.Lock = (entry.LastTime % entry.EndTime) / entry.EndTime; entry.TimeScale = 1; } App.GV.LoadingProcess = $"{ Math.Round((entry.Time % entry.EndTime) / entry.EndTime * 100, 2)}%"; } } }
/// <summary> /// Load game assets /// </summary> protected override void LoadContent() { // BGM if (Program.InfoManager.BGMs.ContainsKey(mapBoard.MapInfo.bgm)) { audio = new WzMp3Streamer(Program.InfoManager.BGMs[mapBoard.MapInfo.bgm], true); if (audio != null) { audio.Volume = 0.3f; audio.Play(); } } if (mapBoard.VRRectangle == null) { vr = new Rectangle(0, 0, mapBoard.MapSize.X, mapBoard.MapSize.Y); } else { vr = new Rectangle(mapBoard.VRRectangle.X + mapBoard.CenterPoint.X, mapBoard.VRRectangle.Y + mapBoard.CenterPoint.Y, mapBoard.VRRectangle.Width, mapBoard.VRRectangle.Height); } //SetStyle(ControlStyles.AllPaintingInWmPaint | ControlStyles.Opaque, true); // Background and objects List <WzObject> usedProps = new List <WzObject>(); //WzDirectory MapFile = Program.WzManager["map"]; // Map.wz //WzDirectory tileDir = (WzDirectory)MapFile["Tile"]; foreach (LayeredItem tileObj in mapBoard.BoardItems.TileObjs) { WzImageProperty tileParent = (WzImageProperty)tileObj.BaseInfo.ParentObject; mapObjects[tileObj.LayerNumber].Add( MapSimulatorLoader.CreateMapItemFromProperty(tileParent, tileObj.X, tileObj.Y, mapBoard.CenterPoint, _DxDeviceManager.GraphicsDevice, ref usedProps, tileObj is IFlippable ? ((IFlippable)tileObj).Flip : false)); } foreach (BackgroundInstance background in mapBoard.BoardItems.BackBackgrounds) { WzImageProperty bgParent = (WzImageProperty)background.BaseInfo.ParentObject; backgrounds_back.Add( MapSimulatorLoader.CreateBackgroundFromProperty(bgParent, background, mapBoard.CenterPoint.X, mapBoard.CenterPoint.Y, _DxDeviceManager.GraphicsDevice, ref usedProps, background.Flip)); } foreach (BackgroundInstance background in mapBoard.BoardItems.FrontBackgrounds) { WzImageProperty bgParent = (WzImageProperty)background.BaseInfo.ParentObject; backgrounds_front.Add( MapSimulatorLoader.CreateBackgroundFromProperty(bgParent, background, mapBoard.CenterPoint.X, mapBoard.CenterPoint.Y, _DxDeviceManager.GraphicsDevice, ref usedProps, background.Flip)); } foreach (WzObject obj in usedProps) { obj.MSTag = null; obj.MSTagSpine = null; // cleanup } usedProps.Clear(); // Spine object skeletonMeshRenderer = new SkeletonMeshRenderer(GraphicsDevice); skeletonMeshRenderer.PremultipliedAlpha = false; // Minimap minimapPos = new Point((int)Math.Round((mapBoard.MinimapPosition.X + mapBoard.CenterPoint.X) / (double)mapBoard.mag), (int)Math.Round((mapBoard.MinimapPosition.Y + mapBoard.CenterPoint.Y) / (double)mapBoard.mag)); this.minimap = BoardItem.TextureFromBitmap(GraphicsDevice, mapBoard.MiniMap); // System.Drawing.Bitmap bmp = new System.Drawing.Bitmap(1, 1); bmp.SetPixel(0, 0, System.Drawing.Color.White); pixel = BoardItem.TextureFromBitmap(GraphicsDevice, bmp); sprite = new SpriteBatch(GraphicsDevice); }
/// <summary> /// Load spine related assets and contents /// </summary> protected override void LoadContent() { // Font spriteBatch = new SpriteBatch(GraphicsDevice); // Spine this.wzSpineObject.spineAnimationItem.LoadResources(graphicsDeviceMgr.GraphicsDevice); // load spine resources (this must happen after window is loaded) this.wzSpineObject.skeleton = new Skeleton(this.wzSpineObject.spineAnimationItem.SkeletonData); skeletonRenderer = new SkeletonMeshRenderer(GraphicsDevice) { PremultipliedAlpha = this.wzSpineObject.spineAnimationItem.PremultipliedAlpha }; // Skin Skin skin = this.wzSpineObject.spineAnimationItem.SkeletonData.Skins.FirstOrDefault(); // just set the first skin if (skin != null) { this.wzSpineObject.skeleton.SetSkin(skin.Name); } this.spineSkinIndex = 0; // Define mixing between animations. this.wzSpineObject.stateData = new AnimationStateData(this.wzSpineObject.skeleton.Data); this.wzSpineObject.state = new AnimationState(this.wzSpineObject.stateData); // Events this.wzSpineObject.state.Start += Start; this.wzSpineObject.state.End += End; this.wzSpineObject.state.Complete += Complete; this.wzSpineObject.state.Event += Event; int i = 0; foreach (Animation animation in this.wzSpineObject.spineAnimationItem.SkeletonData.Animations) { wzSpineObject.state.SetAnimation(i++, animation.Name, true); } /*if (name == "spineboy") * { * stateData.SetMix("run", "jump", 0.2f); * stateData.SetMix("jump", "run", 0.4f); * * // Event handling for all animations. * state.Start += Start; * state.End += End; * state.Complete += Complete; * state.Event += Event; * * state.SetAnimation(0, "test", false); * TrackEntry entry = state.AddAnimation(0, "jump", false, 0); * entry.End += End; // Event handling for queued animations. * state.AddAnimation(0, "run", true, 0); * } * else if (name == "raptor") * { * state.SetAnimation(0, "walk", true); * state.SetAnimation(1, "empty", false); * state.AddAnimation(1, "gungrab", false, 2); * } * else * { * state.SetAnimation(0, "walk", true); * }*/ wzSpineObject.skeleton.X = 800; wzSpineObject.skeleton.Y = 600; wzSpineObject.skeleton.UpdateWorldTransform(); }
private void LoadContent(ContentManager contentManager) { skeletonRenderer = new SkeletonMeshRenderer(_graphicsDevice); skeletonRenderer.PremultipliedAlpha = App.GV.Alpha; atlas = new Atlas(App.GV.SelectFile, new XnaTextureLoader(_graphicsDevice)); if (Common.IsBinaryData(App.GV.SelectFile)) { binary = new SkeletonBinary(atlas); binary.Scale = App.GV.Scale; skeletonData = binary.ReadSkeletonData(Common.GetSkelPath(App.GV.SelectFile)); } else { json = new SkeletonJson(atlas); json.Scale = App.GV.Scale; skeletonData = json.ReadSkeletonData(Common.GetJsonPath(App.GV.SelectFile)); } skeleton = new Skeleton(skeletonData); if (isNew) { App.GV.PosX = skeleton.Data.Width; App.GV.PosY = skeleton.Data.Height; } App.GV.FileHash = skeleton.Data.Hash; stateData = new AnimationStateData(skeleton.Data); state = new AnimationState(stateData); if (isRecoding) { state.Start += State_Start; state.Complete += State_Complete; } List <string> AnimationNames = new List <string>(); LA = state.Data.skeletonData.Animations; foreach (Animation An in LA) { AnimationNames.Add(An.name); } App.GV.AnimeList = AnimationNames; List <string> SkinNames = new List <string>(); LS = state.Data.skeletonData.Skins; foreach (Skin Sk in LS) { SkinNames.Add(Sk.name); } App.GV.SkinList = SkinNames; if (App.GV.SelectAnimeName != "") { state.SetAnimation(0, App.GV.SelectAnimeName, App.GV.IsLoop); } else { state.SetAnimation(0, state.Data.skeletonData.animations.Items[0].name, App.GV.IsLoop); } if (isNew) { MainWindow.SetCBAnimeName(); } isNew = false; }
public void DrawObject(Microsoft.Xna.Framework.Graphics.SpriteBatch spriteBatch, SkeletonMeshRenderer meshRenderer, GameTime gameTime, int mapShiftX, int mapShiftY, bool flip) { spriteBatch.Draw(texture, new Rectangle(X - mapShiftX, Y - mapShiftY, texture.Width, texture.Height), null, Color.White, 0f, new Vector2(0f, 0f), flip ? SpriteEffects.FlipHorizontally : SpriteEffects.None, 0f); }
/// <summary> /// Load game assets /// </summary> protected override void LoadContent() { WzDirectory MapWzFile = Program.WzManager["map"]; // Map.wz WzDirectory UIWZFile = Program.WzManager["ui"]; WzDirectory SoundWZFile = Program.WzManager["sound"]; this.bBigBangUpdate = UIWZFile["UIWindow2.img"]?["BigBang!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"] != null; // different rendering for pre and post-bb, to support multiple vers this.bBigBang2Update = UIWZFile["UIWindow2.img"]?["BigBang2!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"] != null; // BGM if (Program.InfoManager.BGMs.ContainsKey(mapBoard.MapInfo.bgm)) { audio = new WzMp3Streamer(Program.InfoManager.BGMs[mapBoard.MapInfo.bgm], true); if (audio != null) { audio.Volume = 0.3f; audio.Play(); } } if (mapBoard.VRRectangle == null) { vr_fieldBoundary = new Rectangle(0, 0, mapBoard.MapSize.X, mapBoard.MapSize.Y); } else { vr_fieldBoundary = new Rectangle(mapBoard.VRRectangle.X + mapBoard.CenterPoint.X, mapBoard.VRRectangle.Y + mapBoard.CenterPoint.Y, mapBoard.VRRectangle.Width, mapBoard.VRRectangle.Height); } //SetStyle(ControlStyles.AllPaintingInWmPaint | ControlStyles.Opaque, true); // test benchmark #if DEBUG var watch = new System.Diagnostics.Stopwatch(); watch.Start(); #endif /////// Background and objects List <WzObject> usedProps = new List <WzObject>(); // Objects Task t_tiles = Task.Run(() => { foreach (LayeredItem tileObj in mapBoard.BoardItems.TileObjs) { WzImageProperty tileParent = (WzImageProperty)tileObj.BaseInfo.ParentObject; mapObjects[tileObj.LayerNumber].Add( MapSimulatorLoader.CreateMapItemFromProperty(texturePool, tileParent, tileObj.X, tileObj.Y, mapBoard.CenterPoint, _DxDeviceManager.GraphicsDevice, ref usedProps, tileObj is IFlippable ? ((IFlippable)tileObj).Flip : false)); } }); // Background Task t_Background = Task.Run(() => { foreach (BackgroundInstance background in mapBoard.BoardItems.BackBackgrounds) { WzImageProperty bgParent = (WzImageProperty)background.BaseInfo.ParentObject; backgrounds_back.Add( MapSimulatorLoader.CreateBackgroundFromProperty(texturePool, bgParent, background, _DxDeviceManager.GraphicsDevice, ref usedProps, background.Flip)); } foreach (BackgroundInstance background in mapBoard.BoardItems.FrontBackgrounds) { WzImageProperty bgParent = (WzImageProperty)background.BaseInfo.ParentObject; backgrounds_front.Add( MapSimulatorLoader.CreateBackgroundFromProperty(texturePool, bgParent, background, _DxDeviceManager.GraphicsDevice, ref usedProps, background.Flip)); } }); // Reactors Task t_reactor = Task.Run(() => { foreach (ReactorInstance reactor in mapBoard.BoardItems.Reactors) { //WzImage imageProperty = (WzImage)NPCWZFile[reactorInfo.ID + ".img"]; ReactorItem reactorItem = MapSimulatorLoader.CreateReactorFromProperty(texturePool, reactor, _DxDeviceManager.GraphicsDevice, ref usedProps); mapObjects_Reactors.Add(reactorItem); } }); // NPCs Task t_npc = Task.Run(() => { foreach (NpcInstance npc in mapBoard.BoardItems.NPCs) { //WzImage imageProperty = (WzImage) NPCWZFile[npcInfo.ID + ".img"]; if (npc.Hide) { continue; } NpcItem npcItem = MapSimulatorLoader.CreateNpcFromProperty(texturePool, npc, _DxDeviceManager.GraphicsDevice, ref usedProps); mapObjects_NPCs.Add(npcItem); } }); // Mobs Task t_mobs = Task.Run(() => { foreach (MobInstance mob in mapBoard.BoardItems.Mobs) { //WzImage imageProperty = Program.WzManager.FindMobImage(mobInfo.ID); // Mob.wz Mob2.img Mob001.wz if (mob.Hide) { continue; } MobItem npcItem = MapSimulatorLoader.CreateMobFromProperty(texturePool, mob, _DxDeviceManager.GraphicsDevice, ref usedProps); mapObjects_Mobs.Add(npcItem); } }); // Portals Task t_portal = Task.Run(() => { WzSubProperty portalParent = (WzSubProperty)MapWzFile["MapHelper.img"]["portal"]; WzSubProperty gameParent = (WzSubProperty)portalParent["game"]; //WzSubProperty editorParent = (WzSubProperty) portalParent["editor"]; foreach (PortalInstance portal in mapBoard.BoardItems.Portals) { PortalItem portalItem = MapSimulatorLoader.CreatePortalFromProperty(texturePool, gameParent, portal, _DxDeviceManager.GraphicsDevice, ref usedProps); if (portalItem != null) { mapObjects_Portal.Add(portalItem); } } }); // Tooltips Task t_tooltips = Task.Run(() => { WzSubProperty farmFrameParent = (WzSubProperty)UIWZFile["UIToolTip.img"]?["Item"]?["FarmFrame"]; foreach (ToolTipInstance tooltip in mapBoard.BoardItems.ToolTips) { TooltipItem item = MapSimulatorLoader.CreateTooltipFromProperty(texturePool, UserScreenScaleFactor, farmFrameParent, tooltip, _DxDeviceManager.GraphicsDevice); mapObjects_tooltips.Add(item); } }); // Cursor Task t_cursor = Task.Run(() => { WzImageProperty cursorImageProperty = (WzImageProperty)UIWZFile["Basic.img"]?["Cursor"]; this.mouseCursor = MapSimulatorLoader.CreateMouseCursorFromProperty(texturePool, cursorImageProperty, 0, 0, _DxDeviceManager.GraphicsDevice, ref usedProps, false); }); // Spine object Task t_spine = Task.Run(() => { skeletonMeshRenderer = new SkeletonMeshRenderer(GraphicsDevice) { PremultipliedAlpha = false, }; skeletonMeshRenderer.Effect.World = this.matrixScale; }); // Minimap Task t_minimap = Task.Run(() => { if (!mapBoard.MapInfo.hideMinimap) { miniMap = MapSimulatorLoader.CreateMinimapFromProperty(UIWZFile, mapBoard, GraphicsDevice, UserScreenScaleFactor, mapBoard.MapInfo.strMapName, mapBoard.MapInfo.strStreetName, SoundWZFile, bBigBangUpdate); } }); while (!t_tiles.IsCompleted || !t_Background.IsCompleted || !t_reactor.IsCompleted || !t_npc.IsCompleted || !t_mobs.IsCompleted || !t_portal.IsCompleted || !t_tooltips.IsCompleted || !t_cursor.IsCompleted || !t_spine.IsCompleted || !t_minimap.IsCompleted) { Thread.Sleep(100); } #if DEBUG // test benchmark watch.Stop(); Debug.WriteLine($"Map WZ files loaded. Execution Time: {watch.ElapsedMilliseconds} ms"); #endif // spriteBatch = new SpriteBatch(GraphicsDevice); // default positioning for character SetCameraMoveX(true, true, 0); SetCameraMoveY(true, true, 0); ///////////// Border int leftRightVRDifference = (int)((vr_fieldBoundary.Right - vr_fieldBoundary.Left) * RenderObjectScaling); if (leftRightVRDifference < RenderWidth) // viewing range is smaller than the render width.. { this.bDrawVRBorderLeftRight = true; // flag this.texture_vrBoundaryRectLeft = CreateVRBorder(VR_BORDER_WIDTHHEIGHT, vr_fieldBoundary.Height, _DxDeviceManager.GraphicsDevice); this.texture_vrBoundaryRectRight = CreateVRBorder(VR_BORDER_WIDTHHEIGHT, vr_fieldBoundary.Height, _DxDeviceManager.GraphicsDevice); this.texture_vrBoundaryRectTop = CreateVRBorder(vr_fieldBoundary.Width * 2, VR_BORDER_WIDTHHEIGHT, _DxDeviceManager.GraphicsDevice); this.texture_vrBoundaryRectBottom = CreateVRBorder(vr_fieldBoundary.Width * 2, VR_BORDER_WIDTHHEIGHT, _DxDeviceManager.GraphicsDevice); } /* * DXObject leftDXVRObject = new DXObject( * vr_fieldBoundary.Left - VR_BORDER_WIDTHHEIGHT, * vr_fieldBoundary.Top, * texture_vrBoundaryRectLeft); * this.leftVRBorderDrawableItem = new BaseDXDrawableItem(leftDXVRObject, false); * //new BackgroundItem(int cx, int cy, int rx, int ry, BackgroundType.Regular, 255, true, leftDXVRObject, false, (int) RenderResolution.Res_All); * * // Right VR * DXObject rightDXVRObject = new DXObject( * vr_fieldBoundary.Right, * vr_fieldBoundary.Top, * texture_vrBoundaryRectRight); * this.rightVRBorderDrawableItem = new BaseDXDrawableItem(rightDXVRObject, false); */ ///////////// End Border // Debug items System.Drawing.Bitmap bitmap_debug = new System.Drawing.Bitmap(1, 1); bitmap_debug.SetPixel(0, 0, System.Drawing.Color.White); texture_debugBoundaryRect = bitmap_debug.ToTexture2D(_DxDeviceManager.GraphicsDevice); // cleanup // clear used items foreach (WzObject obj in usedProps) { // Spine events WzSpineObject spineObj = (WzSpineObject)obj.MSTagSpine; if (spineObj != null) { spineObj.state.Start += Start; spineObj.state.End += End; spineObj.state.Complete += Complete; spineObj.state.Event += Event; } obj.MSTag = null; obj.MSTagSpine = null; // cleanup } usedProps.Clear(); }
public override void DrawAnimation(SkeletonMeshRenderer skeletonRenderer) { statsUI.DrawAnimation(skeletonRenderer); }
private void InnerBegin() { switch (lastItem) { case ItemType.Sprite: if (this.sprite == null) { this.sprite = new SpriteBatchEx(this.GraphicsDevice); } this.sprite.Begin(SpriteSortMode.Deferred, this.alphaBlendState, transformMatrix: this.matrix); break; case ItemType.Skeleton: if (this.spineRender == null) { this.spineRender = new SkeletonMeshRenderer(this.GraphicsDevice); } this.spineRender.Effect.World = matrix ?? Matrix.Identity; this.spineRender.Begin(); break; case ItemType.D2DObject: if (this.d2dRender == null) { this.d2dRender = new D2DRenderer(this.GraphicsDevice); } if (this.matrix == null) { this.d2dRender.Begin(); } else { this.d2dRender.Begin(this.matrix.Value); } break; case ItemType.Sprite_BlendAdditive: if (this.sprite == null) { this.sprite = new SpriteBatchEx(this.GraphicsDevice); } this.sprite.Begin(SpriteSortMode.Deferred, BlendState.Additive, transformMatrix: this.matrix); break; case ItemType.Sprite_BlendNonPremultiplied: if (this.sprite == null) { this.sprite = new SpriteBatchEx(this.GraphicsDevice); } this.sprite.Begin(SpriteSortMode.Deferred, BlendState.NonPremultiplied, transformMatrix: this.matrix); break; case ItemType.Sprite_BlendMask: if (this.sprite == null) { this.sprite = new SpriteBatchEx(this.GraphicsDevice); } this.sprite.Begin(SpriteSortMode.Deferred, this.maskState, transformMatrix: this.matrix); break; } }
/// <summary> /// Load game assets /// </summary> protected override void LoadContent() { WzDirectory MapWzFile = Program.WzManager["map"]; // Map.wz WzDirectory UIWZFile = Program.WzManager["ui"]; // BGM if (Program.InfoManager.BGMs.ContainsKey(mapBoard.MapInfo.bgm)) { audio = new WzMp3Streamer(Program.InfoManager.BGMs[mapBoard.MapInfo.bgm], true); if (audio != null) { audio.Volume = 0.3f; audio.Play(); } } if (mapBoard.VRRectangle == null) { vr_fieldBoundary = new Rectangle(0, 0, mapBoard.MapSize.X, mapBoard.MapSize.Y); } else { vr_fieldBoundary = new Rectangle(mapBoard.VRRectangle.X + mapBoard.CenterPoint.X, mapBoard.VRRectangle.Y + mapBoard.CenterPoint.Y, mapBoard.VRRectangle.Width, mapBoard.VRRectangle.Height); } //SetStyle(ControlStyles.AllPaintingInWmPaint | ControlStyles.Opaque, true); // Background and objects List <WzObject> usedProps = new List <WzObject>(); foreach (LayeredItem tileObj in mapBoard.BoardItems.TileObjs) { WzImageProperty tileParent = (WzImageProperty)tileObj.BaseInfo.ParentObject; mapObjects[tileObj.LayerNumber].Add( MapSimulatorLoader.CreateMapItemFromProperty(texturePool, tileParent, tileObj.X, tileObj.Y, mapBoard.CenterPoint, _DxDeviceManager.GraphicsDevice, ref usedProps, tileObj is IFlippable ? ((IFlippable)tileObj).Flip : false)); } foreach (BackgroundInstance background in mapBoard.BoardItems.BackBackgrounds) { WzImageProperty bgParent = (WzImageProperty)background.BaseInfo.ParentObject; backgrounds_back.Add( MapSimulatorLoader.CreateBackgroundFromProperty(texturePool, bgParent, background, _DxDeviceManager.GraphicsDevice, ref usedProps, background.Flip)); } foreach (BackgroundInstance background in mapBoard.BoardItems.FrontBackgrounds) { WzImageProperty bgParent = (WzImageProperty)background.BaseInfo.ParentObject; backgrounds_front.Add( MapSimulatorLoader.CreateBackgroundFromProperty(texturePool, bgParent, background, _DxDeviceManager.GraphicsDevice, ref usedProps, background.Flip)); } // Load reactors foreach (ReactorInstance reactor in mapBoard.BoardItems.Reactors) { //WzImage imageProperty = (WzImage)NPCWZFile[reactorInfo.ID + ".img"]; ReactorItem reactorItem = MapSimulatorLoader.CreateReactorFromProperty(texturePool, reactor, _DxDeviceManager.GraphicsDevice, ref usedProps); mapObjects_Reactors.Add(reactorItem); } // Load NPCs foreach (NpcInstance npc in mapBoard.BoardItems.NPCs) { //WzImage imageProperty = (WzImage) NPCWZFile[npcInfo.ID + ".img"]; NpcItem npcItem = MapSimulatorLoader.CreateNpcFromProperty(texturePool, npc, _DxDeviceManager.GraphicsDevice, ref usedProps); mapObjects_NPCs.Add(npcItem); } // Load Mobs foreach (MobInstance mob in mapBoard.BoardItems.Mobs) { //WzImage imageProperty = Program.WzManager.FindMobImage(mobInfo.ID); // Mob.wz Mob2.img Mob001.wz MobItem npcItem = MapSimulatorLoader.CreateMobFromProperty(texturePool, mob, _DxDeviceManager.GraphicsDevice, ref usedProps); mapObjects_Mobs.Add(npcItem); } // Load portals WzSubProperty portalParent = (WzSubProperty)MapWzFile["MapHelper.img"]["portal"]; WzSubProperty gameParent = (WzSubProperty)portalParent["game"]; //WzSubProperty editorParent = (WzSubProperty) portalParent["editor"]; foreach (PortalInstance portal in mapBoard.BoardItems.Portals) { PortalItem portalItem = MapSimulatorLoader.CreatePortalFromProperty(texturePool, gameParent, portal, _DxDeviceManager.GraphicsDevice, ref usedProps); if (portalItem != null) { mapObjects_Portal.Add(portalItem); } } // Load tooltips WzSubProperty farmFrameParent = (WzSubProperty)UIWZFile["UIToolTip.img"]?["Item"]?["FarmFrame"]; foreach (ToolTipInstance tooltip in mapBoard.BoardItems.ToolTips) { TooltipItem item = MapSimulatorLoader.CreateTooltipFromProperty(texturePool, farmFrameParent, tooltip, _DxDeviceManager.GraphicsDevice); mapObjects_tooltips.Add(item); } // Cursor WzImageProperty cursorImageProperty = (WzImageProperty)UIWZFile["Basic.img"]?["Cursor"]; this.mouseCursor = MapSimulatorLoader.CreateMouseCursorFromProperty(texturePool, cursorImageProperty, 0, 0, _DxDeviceManager.GraphicsDevice, ref usedProps, false); // Spine object skeletonMeshRenderer = new SkeletonMeshRenderer(GraphicsDevice) { PremultipliedAlpha = false }; // Minimap WzSubProperty minimapFrameProperty = (WzSubProperty)UIWZFile["UIWindow2.img"]?["MiniMap"]; miniMap = MapSimulatorLoader.CreateMinimapFromProperty(minimapFrameProperty, mapBoard, GraphicsDevice, mapBoard.MapInfo.strMapName, mapBoard.MapInfo.strStreetName); // spriteBatch = new SpriteBatch(GraphicsDevice); // default positioning for character SetCameraMoveX(true, true, 0); SetCameraMoveY(true, true, 0); // cleanup // clear used items foreach (WzObject obj in usedProps) { obj.MSTag = null; obj.MSTagSpine = null; // cleanup } usedProps.Clear(); }
public void Update(GameTime gameTime) { if (App.globalValues.SelectAnimeName != "" && App.globalValues.SetAnime) { state.ClearTracks(); skeleton.SetToSetupPose(); state.SetAnimation(0, App.globalValues.SelectAnimeName, App.globalValues.IsLoop); App.globalValues.SetAnime = false; } if (App.globalValues.SelectSkin != "" && App.globalValues.SetSkin) { skeleton.SetSkin(App.globalValues.SelectSkin); skeleton.SetSlotsToSetupPose(); App.globalValues.SetSkin = false; } if (App.globalValues.SelectSpineVersion != "3.2.xx" || App.globalValues.FileHash != skeleton.Data.Hash) { state = null; skeletonRenderer = null; return; } App.graphicsDevice.Clear(Color.Transparent); Player.DrawBG(ref App.spriteBatch); App.globalValues.TimeScale = (float)App.globalValues.Speed / 30f; state.Update((float)gameTime.ElapsedGameTime.TotalMilliseconds / 1000f); state.Apply(skeleton); if (binary != null) { if (App.globalValues.Scale != binary.Scale) { binary.Scale = App.globalValues.Scale; skeletonData = binary.ReadSkeletonData(App.globalValues.SelectSpineFile); skeleton = new Skeleton(skeletonData); } } else if (json != null) { if (App.globalValues.Scale != json.Scale) { json.Scale = App.globalValues.Scale; skeletonData = json.ReadSkeletonData(App.globalValues.SelectSpineFile); skeleton = new Skeleton(skeletonData); } } skeleton.X = App.globalValues.PosX; skeleton.Y = App.globalValues.PosY; skeleton.FlipX = App.globalValues.FilpX; skeleton.FlipY = App.globalValues.FilpY; skeleton.RootBone.Rotation = App.globalValues.Rotation; skeleton.UpdateWorldTransform(); skeletonRenderer.PremultipliedAlpha = App.globalValues.Alpha; skeletonRenderer.Begin(); skeletonRenderer.Draw(skeleton); skeletonRenderer.End(); }
public void Draw(SkeletonMeshRenderer skeletonRenderer) { skeletonRenderer.Draw(skeleton); }
/// <summary> /// Load game assets /// </summary> protected override void LoadContent() { WzDirectory MapWzFile = Program.WzManager["map"]; // Map.wz WzDirectory UIWZFile = Program.WzManager["ui"]; // BGM if (Program.InfoManager.BGMs.ContainsKey(mapBoard.MapInfo.bgm)) { audio = new WzMp3Streamer(Program.InfoManager.BGMs[mapBoard.MapInfo.bgm], true); if (audio != null) { audio.Volume = 0.3f; audio.Play(); } } if (mapBoard.VRRectangle == null) { vr_fieldBoundary = new Rectangle(0, 0, mapBoard.MapSize.X, mapBoard.MapSize.Y); } else { vr_fieldBoundary = new Rectangle(mapBoard.VRRectangle.X + mapBoard.CenterPoint.X, mapBoard.VRRectangle.Y + mapBoard.CenterPoint.Y, mapBoard.VRRectangle.Width, mapBoard.VRRectangle.Height); } //SetStyle(ControlStyles.AllPaintingInWmPaint | ControlStyles.Opaque, true); // test benchmark #if DEBUG var watch = new System.Diagnostics.Stopwatch(); watch.Start(); #endif /////// Background and objects List <WzObject> usedProps = new List <WzObject>(); // Objects Task t_tiles = Task.Run(() => { foreach (LayeredItem tileObj in mapBoard.BoardItems.TileObjs) { WzImageProperty tileParent = (WzImageProperty)tileObj.BaseInfo.ParentObject; mapObjects[tileObj.LayerNumber].Add( MapSimulatorLoader.CreateMapItemFromProperty(texturePool, tileParent, tileObj.X, tileObj.Y, mapBoard.CenterPoint, _DxDeviceManager.GraphicsDevice, ref usedProps, tileObj is IFlippable ? ((IFlippable)tileObj).Flip : false)); } }); // Background Task t_Background = Task.Run(() => { foreach (BackgroundInstance background in mapBoard.BoardItems.BackBackgrounds) { WzImageProperty bgParent = (WzImageProperty)background.BaseInfo.ParentObject; backgrounds_back.Add( MapSimulatorLoader.CreateBackgroundFromProperty(texturePool, bgParent, background, _DxDeviceManager.GraphicsDevice, ref usedProps, background.Flip)); } foreach (BackgroundInstance background in mapBoard.BoardItems.FrontBackgrounds) { WzImageProperty bgParent = (WzImageProperty)background.BaseInfo.ParentObject; backgrounds_front.Add( MapSimulatorLoader.CreateBackgroundFromProperty(texturePool, bgParent, background, _DxDeviceManager.GraphicsDevice, ref usedProps, background.Flip)); } }); // Reactors Task t_reactor = Task.Run(() => { foreach (ReactorInstance reactor in mapBoard.BoardItems.Reactors) { //WzImage imageProperty = (WzImage)NPCWZFile[reactorInfo.ID + ".img"]; ReactorItem reactorItem = MapSimulatorLoader.CreateReactorFromProperty(texturePool, reactor, _DxDeviceManager.GraphicsDevice, ref usedProps); mapObjects_Reactors.Add(reactorItem); } }); // NPCs Task t_npc = Task.Run(() => { foreach (NpcInstance npc in mapBoard.BoardItems.NPCs) { //WzImage imageProperty = (WzImage) NPCWZFile[npcInfo.ID + ".img"]; if (npc.Hide) { continue; } NpcItem npcItem = MapSimulatorLoader.CreateNpcFromProperty(texturePool, npc, _DxDeviceManager.GraphicsDevice, ref usedProps); mapObjects_NPCs.Add(npcItem); } }); // Mobs Task t_mobs = Task.Run(() => { foreach (MobInstance mob in mapBoard.BoardItems.Mobs) { //WzImage imageProperty = Program.WzManager.FindMobImage(mobInfo.ID); // Mob.wz Mob2.img Mob001.wz if (mob.Hide) { continue; } MobItem npcItem = MapSimulatorLoader.CreateMobFromProperty(texturePool, mob, _DxDeviceManager.GraphicsDevice, ref usedProps); mapObjects_Mobs.Add(npcItem); } }); // Portals Task t_portal = Task.Run(() => { WzSubProperty portalParent = (WzSubProperty)MapWzFile["MapHelper.img"]["portal"]; WzSubProperty gameParent = (WzSubProperty)portalParent["game"]; //WzSubProperty editorParent = (WzSubProperty) portalParent["editor"]; foreach (PortalInstance portal in mapBoard.BoardItems.Portals) { PortalItem portalItem = MapSimulatorLoader.CreatePortalFromProperty(texturePool, gameParent, portal, _DxDeviceManager.GraphicsDevice, ref usedProps); if (portalItem != null) { mapObjects_Portal.Add(portalItem); } } }); // Tooltips Task t_tooltips = Task.Run(() => { WzSubProperty farmFrameParent = (WzSubProperty)UIWZFile["UIToolTip.img"]?["Item"]?["FarmFrame"]; foreach (ToolTipInstance tooltip in mapBoard.BoardItems.ToolTips) { TooltipItem item = MapSimulatorLoader.CreateTooltipFromProperty(texturePool, farmFrameParent, tooltip, _DxDeviceManager.GraphicsDevice); mapObjects_tooltips.Add(item); } }); // Cursor Task t_cursor = Task.Run(() => { WzImageProperty cursorImageProperty = (WzImageProperty)UIWZFile["Basic.img"]?["Cursor"]; this.mouseCursor = MapSimulatorLoader.CreateMouseCursorFromProperty(texturePool, cursorImageProperty, 0, 0, _DxDeviceManager.GraphicsDevice, ref usedProps, false); }); // Spine object Task t_spine = Task.Run(() => { skeletonMeshRenderer = new SkeletonMeshRenderer(GraphicsDevice) { PremultipliedAlpha = false }; }); // Minimap Task t_minimap = Task.Run(() => { if (!mapBoard.MapInfo.hideMinimap) { WzSubProperty minimapFrameProperty = (WzSubProperty)UIWZFile["UIWindow2.img"]?["MiniMap"]; if (minimapFrameProperty == null) // UIWindow2 not available pre-BB. { minimapFrameProperty = (WzSubProperty)UIWZFile["UIWindow.img"]?["MiniMap"]; } miniMap = MapSimulatorLoader.CreateMinimapFromProperty(minimapFrameProperty, mapBoard, GraphicsDevice, mapBoard.MapInfo.strMapName, mapBoard.MapInfo.strStreetName); } }); while (!t_tiles.IsCompleted || !t_Background.IsCompleted || !t_reactor.IsCompleted || !t_npc.IsCompleted || !t_mobs.IsCompleted || !t_portal.IsCompleted || !t_tooltips.IsCompleted || !t_cursor.IsCompleted || !t_spine.IsCompleted || !t_minimap.IsCompleted) { Thread.Sleep(50); } #if DEBUG // test benchmark watch.Stop(); Debug.WriteLine($"Map loaded. Execution Time: {watch.ElapsedMilliseconds} ms"); #endif // spriteBatch = new SpriteBatch(GraphicsDevice); // default positioning for character SetCameraMoveX(true, true, 0); SetCameraMoveY(true, true, 0); // Debug items System.Drawing.Bitmap bitmap_debug = new System.Drawing.Bitmap(1, 1); bitmap_debug.SetPixel(0, 0, System.Drawing.Color.White); texture_debugBoundaryRect = bitmap_debug.ToTexture2D(_DxDeviceManager.GraphicsDevice); // cleanup // clear used items foreach (WzObject obj in usedProps) { obj.MSTag = null; obj.MSTagSpine = null; // cleanup } usedProps.Clear(); }