/// <summary> /// Allows the game to run logic such as updating the world, /// checking for collisions, gathering input, and playing audio. /// </summary> /// <param name="gameTime">Provides a snapshot of timing values.</param> protected override void Update(GameTime gameTime) { // Allows the game to exit if(GamePad.GetState(PlayerIndex.One).Buttons.Back == ButtonState.Pressed || Keyboard.GetState().IsKeyDown(Keys.Escape)) this.Exit(); MouseState mState = Mouse.GetState(); mouseLoc = new Vector2(mState.X, mState.Y); left = (mState.LeftButton == ButtonState.Pressed); right = (mState.RightButton == ButtonState.Pressed); if(left) { foreach(Button alpha in buttons) { if(alpha.CheckClicked(mState.X, mState.Y)) { left = false; } } } else { foreach(Button alpha in buttons) { alpha.Last = false; } } if(left) { foreach(Area alpha in areas) { if(alpha.ButtonClicked(mState.X, mState.Y)) { currArea = alpha; editName = false; left = false; break; } } } IsMouseVisible = !left && !right; if(currArea != null && !IsMouseVisible) { int x = mState.X - (mState.X % 32) + 32; x /= 32; int y = mState.Y - (mState.Y % 32) - 60; y /= 32; if(left) { if(currType == TerrainType.PORTAL) { if(currArea.GetPortal(x, y) == null) { if(toLink == null) { currArea.AddTile(x, y, currType); toLink = currArea.GetPortal(x, y); } else { currArea.AddTile(x, y, currType); toLink.MakeLink(currArea.GetPortal(x, y)); toLink = null; } } else { if(currArea.GetPortal(x, y).Link == null) { if(toLink != null && toLink != currArea.GetPortal(x, y)) { toLink.MakeLink(currArea.GetPortal(x, y)); toLink = null; } else { toLink = currArea.GetPortal(x, y); } } } } else { currArea.AddTile(x, y, currType); } } else if(right) { if(currArea.GetPortal(x, y) != null) { if(toLink != null) { toLink = null; } Portal linkedPortal = currArea.GetPortal(x, y).Link; if(linkedPortal != null) { linkedPortal.MyArea.RemoveTile(linkedPortal.Location.X, linkedPortal.Location.Y); } } currArea.RemoveTile(x, y); } } if(editName && currArea != null) { ProcessEditName(); } // TODO: Add your update logic here base.Update(gameTime); }
/// <summary> /// LoadContent will be called once per game and is the place to load /// all of your content. /// </summary> protected override void LoadContent() { // Create a new SpriteBatch, which can be used to draw textures. spriteBatch = new SpriteBatch(GraphicsDevice); // TODO: use this.Content to load your game content here pencil = Content.Load<Texture2D>("Pencil32"); erase = Content.Load<Texture2D>("Erase32"); reticle = Content.Load<Texture2D>("Reticle8"); GlobalVars.courier = Content.Load<SpriteFont>("Courier"); GlobalVars.courierSmall = Content.Load<SpriteFont>("CourierSmall"); Area.cap = Content.Load<Texture2D>("areaCap"); Area.mid = Content.Load<Texture2D>("areaMid"); Area.tiles = Content.Load<Texture2D>("Tiles"); buttons.Add(new Button(Content.Load<Texture2D>("NewArea32"), false, 16, 16, delegate() { // New Area Function Area alpha = new Area(); currArea = alpha; areas.Add(alpha); editName = true; })); buttons.Add(new Button(Content.Load<Texture2D>("EditArea32"), false, 48, 16, delegate() { // Edit Area Name Function editName = true; })); buttons.Add(new Button(Content.Load<Texture2D>("DeleteArea32"), false, 80, 16, delegate() { // Delete Area Function if(currArea != null) { areas.Remove(currArea); currArea = null; } })); buttons.Add(new Button(Content.Load<Texture2D>("Save32"), false, 112, 16, Save)); buttons.Add(new Button(Content.Load<Texture2D>("ScrollLeft"), true, 0, GraphicsDevice.Viewport.Height - 32, delegate() { // Scroll Areas Left scrollX -= 5; })); buttons.Add(new Button(Content.Load<Texture2D>("ScrollRight"), true, GraphicsDevice.Viewport.Width - 16, GraphicsDevice.Viewport.Height - 32, delegate() { // Scroll Areas Right scrollX += 5; })); buttons.Add(new Button(Content.Load<Texture2D>("Brick32"), false, GraphicsDevice.Viewport.Width - 102, 16, delegate() { // Draw Platform Button currType = TerrainType.PLATFORM; })); buttons.Add(new Button(Content.Load<Texture2D>("Portal32"), false, GraphicsDevice.Viewport.Width - 70, 16, delegate() { // Place Portal Button currType = TerrainType.PORTAL; })); buttons.Add(new Button(Content.Load<Texture2D>("Decor32"), false, GraphicsDevice.Viewport.Width - 38, 16, delegate() { // Place Decor Button currType = TerrainType.DECOR; })); }
public Terrain(int x, int y, Area area) { loc = new Point(x, y); areaLoc = area; }
public Platform(int x, int y, Area area) : base(x, y, area) { }
public Portal(int x, int y, Area area) : base(x, y, area) { }