public void LevelSave(string filename) { levelIO.Save(filename); }
protected override void AD2Logic(int ms, KeyboardState keyboardState, SlimDX.DirectInput.JoystickState[] gamePadState) { mouseX = Mouse.GetState().X; mouseY = Mouse.GetState().Y; //Minus = object left if (keyboardState.IsKeyDown(Keys.OemMinus) && genericNewKey) { if (putPointer == 0) { putPointer = TextureList.Length - 1; } else { putPointer = putPointer - 1; } } //Plus = object forward if (keyboardState.IsKeyDown(Keys.OemPlus) && genericNewKey) { putPointer = (putPointer + 1) % TextureList.Length; } //Click = place or erase object. if (Mouse.GetState().LeftButton == ButtonState.Pressed && !newMouseLeft) { if (putMode) { AD2Object a = new AD2Object(); a.X = camX + mouseX; a.Y = camY + mouseY; a.t = TextureList[putPointer]; a.collide = CollideTextureList[putPointer]; a.name = TextureName[putPointer]; //Where is the bottom? if (collide(0, 0, baseMap.Width, baseMap.Height, a.X, a.Y)) { objectsList[a.Y + (a.t.Height - 1)].AddFirst(a); } } else { for (int i = 0; i != objectsList.Length; i++) { LinkedList <AD2Object> removeList = new LinkedList <AD2Object>(); foreach (AD2Object a in objectsList[i]) { if (collide(a.X, a.Y, a.t.Width, a.t.Height, camX + mouseX, camY + mouseY)) { removeList.AddFirst(a); } } foreach (AD2Object a in removeList) { objectsList[i].Remove(a); } } } } // mode switch if (Mouse.GetState().RightButton == ButtonState.Pressed && !newMouseRight) { putMode = !putMode; } if (keyboardState.IsKeyDown(Keys.F1) && genericNewKey) { generateNew(); } if (keyboardState.IsKeyDown(Keys.F2) && genericNewKey) { LevelIO.Save(this); } if (keyboardState.IsKeyDown(Keys.F3) && genericNewKey) { loadNew(); } if (keyboardState.IsKeyDown(Keys.C) && genericNewKey) { objectsCanCollide = !objectsCanCollide; } if (keyboardState.IsKeyDown(Keys.V) && genericNewKey) { switch (Viewmode) { case Viewmodes.Collide: Viewmode = Viewmodes.Object; break; case Viewmodes.FiftyPercent: Viewmode = Viewmodes.Collide; break; case Viewmodes.Object: Viewmode = Viewmodes.FiftyPercent; break; } } newMouseLeft = Mouse.GetState().LeftButton == ButtonState.Pressed; newMouseRight = Mouse.GetState().RightButton == ButtonState.Pressed; genericNewKey = keyboardState.GetPressedKeys().Length == 0; if (mouseX < BaseWidth * TRANSITION_AREA) { camX -= SCROLL_SPEED; } if (mouseX > BaseWidth * (1.0 - TRANSITION_AREA)) { camX += SCROLL_SPEED; } if (mouseY < BaseHeight * TRANSITION_AREA) { camY -= SCROLL_SPEED; } if (mouseY > BaseHeight * (1.0 - TRANSITION_AREA)) { camY += SCROLL_SPEED; } }