public override void UpdateInput() { hasChanged = false; if (!_inLine.Contains(HMouse.Position)) return; if (_scrollDown.Contains(HMouse.Position) && HMouse.IsClickedLeft) { if (_scrollIndex < _rowList.Count-1) { _camera.Position += new Vector2(0, -200); _scrollIndex++; _selectedSprite = null; return; } } if (_scrollUp.Contains(HMouse.Position) && HMouse.IsClickedLeft) { if (_scrollIndex > 0) { _camera.Position += new Vector2(0, 200); _scrollIndex--; _selectedSprite = null; return; } } Point p = new Point((int)(HMouse.Position.X), (int)(HMouse.Position.Y)); if(HMouse.IsClickedLeft) if (HMouse.IsClickedLeft && this._inLine.Contains(p)) { p = new Point((int)(HMouse.Position.X - this._position.X), (int)(HMouse.Position.Y - this._position.Y + _scrollIndex * 200)); for (int i = _rowList[_scrollIndex]; i < _spriteList.Count; i++) { if (_spriteList[i].Hitbox.Contains(p)) { _selectedSprite = _spriteList[i]; _selectedId = i; hasChanged = true; } } } }
public void DivideElements() { _spriteList.Clear(); _rowList.Clear(); int y = 10; int x = 10; _rowList.Add(0); for (int i = 0; i < _sourceRectangle.Count; i++) { HSprite tmpSprite = new HSprite(new Vector2(x, y), _sourceRectangle[i]); if (tmpSprite.Position.X + tmpSprite.SourceRectangle.Width < this._width -30) x += _sourceRectangle[i].Width + 10; else { _rowList.Add(i); x = 10; y += 200; tmpSprite.Position = new Vector2(x, y); x += tmpSprite.SourceRectangle.Width + 10; } _spriteList.Add(tmpSprite); } _spriteList.Add(new HSprite(new Vector2(x,y),new Rectangle(x,y,96,96),"pixel")); x += 106; _spriteList.Add(new HSprite(new Vector2(x,y), new Rectangle(x,y,96,96),"pixel")); x += 106; _spriteList.Add(new HSprite(new Vector2(x, y), new Rectangle(x, y, 96, 96), "enemy")); }