public override void OnCollected(Player collectedBy) { // make sure box is active and player is below it if (collectedBy.Position.Y > this.Position.Y + texture.Height && collectedBy.Position.X + Tile.Width / 2 < this.Position.X + Tile.Width && collectedBy.Position.X + Tile.Width / 2 > this.Position.X) { if (isActive) { isActive = false; if (collectedBy.Size == 0) { Level.AddCollectable(new Champ(Level, new Vector2(Position.X - origin.X, Position.Y - origin.Y), X, Y)); } else { Level.AddCollectable(new Flower(Level, new Vector2(Position.X - origin.X, Position.Y - origin.Y), X, Y)); } base.OnCollected(collectedBy); } else if (!bounce) { bounce = true; sprite.PlayAnimation(bounceAnimation); } } }
public override void OnCollected(Player collectedBy) { // make sure box is active and player is below it if (isActive && collectedBy.Position.Y > this.Position.Y + texture.Height && collectedBy.Position.X + Tile.Width / 2 < this.Position.X + Tile.Width && collectedBy.Position.X + Tile.Width / 2 > this.Position.X) { isActive = false; Level.AddCollectable(new Star(Level, new Vector2(Position.X - origin.X, Position.Y - origin.Y), X, Y)); base.OnCollected(collectedBy); } }