public static void SpawnLadderPart(SosEngine.Level level) { int y = 8; while (level.GetBlock("Block", 32, y) != 0) { y--; } level.PutBlock("Block", 32, y, 284); level.PutBlock("Block", 33, y, 285); }
public override void Update(GameTime gameTime) { if (!Visible) { return; } currentMouseState = Mouse.GetState(); mouseX = (int)(SosEngine.Core.RenderWidth / (float)Game.GraphicsDevice.Viewport.Bounds.Width * currentMouseState.X); mouseY = (int)(SosEngine.Core.RenderHeight / (float)Game.GraphicsDevice.Viewport.Bounds.Height * currentMouseState.Y); mouseCursor.Position = new Vector2(mouseX, mouseY); mouseCursor.SetState(currentMouseState.LeftButton == ButtonState.Pressed); leftMouseButtonClicked = currentMouseState.LeftButton == ButtonState.Released && lastMouseState.LeftButton == ButtonState.Pressed; rightMouseButtonClicked = currentMouseState.RightButton == ButtonState.Released && lastMouseState.RightButton == ButtonState.Pressed; middleMouseButtonClicked = currentMouseState.MiddleButton == ButtonState.Released && lastMouseState.MiddleButton == ButtonState.Pressed; leftMouseButtonJustPressed = currentMouseState.LeftButton == ButtonState.Pressed && lastMouseState.LeftButton == ButtonState.Released; dragging = currentMouseState.LeftButton == ButtonState.Pressed && lastMouseState.LeftButton == ButtonState.Pressed; mouseDelta = new Vector2(mouseX, mouseY) - new Vector2(lastMouseX, lastMouseY); lastMouseX = mouseX; lastMouseY = mouseY; lastMouseState = currentMouseState; level.GetBlockAtPixel("Block", MouseX + 4, mouseY + 4, out mouseBx, out mouseBy); if (leftMouseButtonJustPressed) { level.PutBlock("Block", mouseBx, mouseBy, 64); } base.Update(gameTime); }
/// <summary> /// Handles block hitting. /// </summary> /// <returns></returns> protected bool HandleHitBlock() { var stopJumping = false; int x = BoundingBox.X + (BoundingBox.Width / 2); int y = BoundingBox.Y + 4; var bx = 0; var by = 0; var block = level.GetBlockAtPixel("Block", x - 2, y, out bx, out by); if (block == 0) { block = level.GetBlockAtPixel("Block", x + 2, y, out bx, out by); } var item = level.GetBlock("Items", bx, by); if (Helpers.LevelHelper.IsWall(block)) { if (Helpers.LevelHelper.IsQuestionBlock(block)) { level.StopTileAnimationAt("Block", bx, by); level.PutBlock("Block", bx, by, 67); level.BounceBlock("Block", bx, by); } else if (Helpers.LevelHelper.IsBreakableBlock(block)) { if (item != 0) { level.PutBlock("Block", bx, by, 67); level.BounceBlock("Block", bx, by); } else { if (isTiny) { level.BounceBlock("Block", bx, by); } else { level.RemoveBlock("Block", bx, by); EntityManager.AddEntity(new BreakBlockEffect(this.Game, "break_block_1", (bx * 16), (by * 16), BreakBlockEffect.Placement.UpperLeft)); EntityManager.AddEntity(new BreakBlockEffect(this.Game, "break_block_1", (bx * 16), (by * 16), BreakBlockEffect.Placement.UpperRight)); EntityManager.AddEntity(new BreakBlockEffect(this.Game, "break_block_1", (bx * 16), (by * 16), BreakBlockEffect.Placement.LowerLeft)); EntityManager.AddEntity(new BreakBlockEffect(this.Game, "break_block_1", (bx * 16), (by * 16), BreakBlockEffect.Placement.LowerRight)); SosEngine.Core.PlaySound("BrickShatter"); } } } stopJumping = true; } if (item > 0) { level.RemoveBlock("Items", bx, by); switch (item) { case 1: if (isTiny) { EntityManager.AddEntity(new Mushroom(this.Game, "mushroom", Mushroom.MushroomTypes.Mushroom, bx * 16, (by * 16), level)); } else { EntityManager.AddEntity(new Flower(this.Game, bx * 16, (by * 16), level)); } break; case 2: EntityManager.AddEntity(new Mushroom(this.Game, "1up_mushroom", Mushroom.MushroomTypes.OneUp, bx * 16, (by * 16), level)); break; case 3: EntityManager.AddEntity(new Mushroom(this.Game, "deadly_mushroom", Mushroom.MushroomTypes.Deadly, bx * 16, (by * 16), level)); break; case 4: EntityManager.AddEntity(new CoinEffect(this.Game, bx * 16, (by - 1) * 16)); AddScore(200, true, (bx * 16) + 8, (by - 1) * 16); level.PutBlock("Block", bx, by, 67); level.BounceBlock("Block", bx, by); break; } if (block == 0) { level.PutBlock("Block", bx, by, 67); level.BounceBlock("Block", bx, by); } stopJumping = true; } return(stopJumping); }