public override World loadWorld(string str) { World w = new EditorWorld(this, str); w.Initialize(); w.LoadContent(); return(w); }
public override void Draw() { EditorWorld world = tileEngine.world as EditorWorld; Clear(); if (world != null) { world.sortActors(); BeginCamDraw(SpriteSortMode.Texture); DrawTiles(world); EndCamDraw(); BeginCamDraw(SpriteSortMode.Deferred); DrawSprites(world); EndCamDraw(); } guiComponent.Draw(); }
public override void Update(Microsoft.Xna.Framework.GameTime gameTime) { EditorWorld editorWorld = tileEngine.world as EditorWorld; base.Update(gameTime); if ((tileEngine as Editor).activeTool.active) { (tileEngine as Editor).activeTool.doMoveAction(); } // Move camera position to center of player position AxisBinding xaim, yaim, xmove, ymove; EditorInput input = tileEngine.inputComponent as EditorInput; AxisBinding.origin = (new Vector2(.5f * camera.screenWidth, .4f * camera.screenHeight)); //AxisBinding.origin = new Vector2(0,0); xaim = input[EditorInput.EditBindings.XAIM] as AxisBinding; yaim = input[EditorInput.EditBindings.YAIM] as AxisBinding; xmove = input[EditorInput.EditBindings.XMOVE] as AxisBinding; ymove = input[EditorInput.EditBindings.YMOVE] as AxisBinding; Debug.WriteLine(xaim.position + " " + yaim.position + "\n"); camera.velocity = Vector2.Zero; camera.velocity = new Vector2(xaim.position, -yaim.position); camera.velocity *= 20f; // scale by speed if (camera.velocity.Length() > 2.5 && !editorWorld.scrollLock) { if (camera.position.X + camera.velocity.X < 0 || camera.position.X + camera.velocity.X >= tileEngine.world.width * Tile.size) { camera.velocity = new Vector2(0, camera.velocity.Y); } if (camera.position.Y + camera.velocity.Y < 0 || camera.position.Y + camera.velocity.Y >= tileEngine.world.height * Tile.size) { camera.velocity = new Vector2(camera.velocity.X, 0); } if (fullscreen) { camera.position += camera.velocity * 5 / (camera.scale - camera.scaleChange); } if (!fullscreen) { camera.position += camera.velocity / (camera.scale - camera.scaleChange); } } else { if (editorWorld.scrollLock && !(guiComponent.focus is TextArea)) { camera.velocity = new Vector2(xmove.position, -ymove.position); if (camera.position.X + camera.velocity.X < 0 || camera.position.X + camera.velocity.X >= tileEngine.world.width * Tile.size) { camera.velocity = new Vector2(0, camera.velocity.Y); } if (camera.position.Y + camera.velocity.Y < 0 || camera.position.Y + camera.velocity.Y >= tileEngine.world.height * Tile.size) { camera.velocity = new Vector2(camera.velocity.X, 0); } if (fullscreen) { camera.position += camera.velocity * 15 / (camera.scale - camera.scaleChange); } if (!fullscreen) { camera.position += camera.velocity * 15 / (camera.scale - camera.scaleChange); } } } }