@Override
  public void Update(GameTime gameTime) {
    _delayTime = TimeSpan.Add(_delayTime, gameTime.ElapsedGameTime());

    if (_delayTime.miliseconds() <= 100) return;
    _delayTime = TimeSpan.Zero();
    if (_isClicked) {
      _sprites.get(0).Update();

      if (_sprites.get(0).FrameIndex() == 0) {
        Clicked.Add(DoClick.GetInstance(this));
        _isClicked = false;
      }
    }

    super.Update(gameTime);
  }
public class Chest extends DrawableGameComponent implements ITappedInner {

  private List<Sprite> _sprites = new ArrayList<Sprite>();
  private String _path;
  private boolean _isClicked;
  private Vector2 _position;
  private TimeSpan _delayTime = TimeSpan.Zero();
  private PanelButton _itemPanel;
  private boolean _isPanelButtonAdded;
  private GameScreen _owner;
  public event Clicked;
  public event ShopOpened;
  public event ShopClosed;
  public event ItemBought;

  public Chest(Game game, GameScreen owner, String fullPath, Vector2 position) {
    super(game);
    _path = fullPath;

    _isClicked = false;

    _position = position;

    _owner = owner;

    Clicked = new event(this);
    ShopOpened = new event(this);
    ShopClosed = new event(this);
    ItemBought = new event(this);

    ShopOpened.Add(ShopOpenProcessing.GetInstance());

    ShopClosed.Add(ShopCloseProcessing.GetInstance());

    ItemBought.Add(ItemBoughtProcessing.GetInstance());

    _isPanelButtonAdded = false;

    Initialize();

    LoadContent();
  }

  public PanelButton ItemPanel() {
    return _itemPanel;
  }

  public void ItemPanel(PanelButton value) {
    _itemPanel = value;
  }

  public boolean IsPanelButtonAdded() {
    return _isPanelButtonAdded;
  }

  public void IsPanelButtonAdded(boolean value) {
    _isPanelButtonAdded = value;
  }

  @Override
  public void Initialize() {
    int id = Factory.getResourceID(_path, ResourceType.xml);
    XmlResourceParser xrp = _game.Resource().getXml(id);
    String tagName = "";
    String value = "";
    int numFrame;
    int frameWidth;
    int frameHeight;
    int xCenterPoint;
    int yCenterPoint;
    int bitmapResID;
    boolean isVertical;
    try {
      while (xrp.getEventType() != XmlResourceParser.END_DOCUMENT) {
        if (xrp.getEventType() == XmlResourceParser.START_TAG) {
          tagName = xrp.getName();

          if (tagName.equals("Definition")) {
            numFrame = xrp.getAttributeIntValue(null, "NumFrame", 0);

            frameWidth = xrp.getAttributeIntValue(null, "FrameWidth", 0);

            frameHeight = xrp.getAttributeIntValue(null, "FrameHeight", 0);

            xCenterPoint = xrp.getAttributeIntValue(null, "XCenterPoint", 0);

            yCenterPoint = xrp.getAttributeIntValue(null, "YCenterPoint", 0);

            bitmapResID = xrp.getAttributeResourceValue(null, "SheetName", 0);

            isVertical = xrp.getAttributeBooleanValue(null, "IsVertical", false);

            Bitmap bmp = BitmapFactory.decodeResource(Game().Resource(), bitmapResID);
            _sprites.add(
                new Sprite(
                    null,
                    bmp,
                    numFrame,
                    new Vector2(frameWidth, frameHeight),
                    new Vector2(xCenterPoint, yCenterPoint),
                    isVertical));
          }
        }

        if (xrp.getEventType() == XmlResourceParser.TEXT) {
          if (tagName.equals("Panel")) {
            value = xrp.getText();
            if (value != "") {
              _itemPanel = new PanelButton(_game, _owner, value);
            }
          }
        }
        xrp.next();
      }
      xrp.close();
    } catch (XmlPullParserException e) {
      e.printStackTrace();
    } catch (IOException e) {
      e.printStackTrace();
    }

    super.Initialize();
  }

  @Override
  public void LoadContent() {
    for (int i = 0; i < _itemPanel.Grid().get(0).Rows(); i++)
      for (int j = 0; j < _itemPanel.Grid().get(0).Cols(); j++) {
        _itemPanel
            .Grid()
            .get(0)
            .Blanks()[i][j]
            .Clicked
            .Add(PushalbeBlankAdditionFuncEvent.GetInstance(this));
      }
  }

  @Override
  public void Update(GameTime gameTime) {
    _delayTime = TimeSpan.Add(_delayTime, gameTime.ElapsedGameTime());

    if (_delayTime.miliseconds() <= 100) return;
    _delayTime = TimeSpan.Zero();
    if (_isClicked) {
      _sprites.get(0).Update();

      if (_sprites.get(0).FrameIndex() == 0) {
        Clicked.Add(DoClick.GetInstance(this));
        _isClicked = false;
      }
    }

    super.Update(gameTime);
  }

  @Override
  public void Draw(GameTime gameTime) {
    _sprites.get(0).Draw((SpriteBatch) Game().GetService("SpriteBatch"), _position, Color.WHITE);
    Clicked.occur(!_isPanelButtonAdded);
    if (_isPanelButtonAdded) {
      _itemPanel.Draw(gameTime);
    }
    super.Draw(gameTime);
  }

  public boolean CheckTapped(Point p) {
    Rect rect =
        new Rect(
            (int) _position.x,
            (int) _position.y,
            (int) _sprites.get(0).size().x + (int) _position.x,
            (int) _sprites.get(0).size().y + (int) _position.y);

    boolean isTapped = rect.contains(p.x, p.y);
    if (isTapped) {
      _isClicked = true;
    }
    return isTapped;
  }
}