public bool Update() { if (Math.Abs(Peach.Location.X - GoalLocation.X) < 5) { Peach.IdleTransition(); foreach (IEntity entity in Collections.Instance.GetLevelRef().Entities) // explode all remaining brick blocks on ceiling { if (entity is GlassBlock glassBlock) { int count = glassBlock.ContainedItems.Count; glassBlock.ExplodeBrickBlockTransition(); for (int i = Constants.ZERO; i < count; i++) { ExplodingBlock child = (ExplodingBlock)glassBlock.ContainedItems[i]; // must do following for all four exploding blocks child.Visible = true; if (i == 1) { child.Sprite.Velocity = new Vector2(-300, -300); // make the blocks go in different directions } else if (i == 2) { child.Sprite.Velocity = new Vector2(300, 300); } else if (i == 3) { child.Sprite.Velocity = new Vector2(300, -300); } else if (i == 4) { child.Sprite.Velocity = new Vector2(-300, 300); } child.ExplodingBlockTransition(); } } } return(true); } else { if (Peach.Location.X > GoalLocation.X) { ICommand moveLeft = new MoveLeftCommand(Peach); moveLeft.Execute(); } else { ICommand moveRight = new MoveRightCommand(Peach); moveRight.Execute(); } } return(false); }
public Sprite BuildSprite(BlockType sprite, Vector2 loc) { Sprite toReturn = null; switch (sprite) { case BlockType.exploded: { toReturn = new ExplodingBlock(loc); break; } case BlockType.question: { toReturn = new QuestionBlock(loc); break; } case BlockType.used: { toReturn = new UsedBlock(loc); break; } case BlockType.brick: { toReturn = new BrickBlock(loc); break; } case BlockType.hidden: { toReturn = new HiddenBlock(loc); break; } case BlockType.pipe: { toReturn = new PipeBlock(loc); break; } case BlockType.bridge: { toReturn = new BridgeBlock(loc); break; } } return(toReturn); }