public Quickbar( int size ) { Size = size; Items = new ItemCollection(size); Locked = false; UsingItem = new ItemUse(); // Default Positioning Vertical = "bottom"; Horizontal = "center"; Layout = "horizontal"; Offset = new Vector2(0, 10); Scale = 1f; Margin = 2; // Default States Selected = 0; MouseOver = -1; MouseDown = -1; }
public void Update( Control control, Quickbar quickbar, Camera camera, Lighting lighting, Player player ) { Fluids.Update(this); Entities.Update(control, camera); #region Flora // Grow Flora GrowCounter++; if (GrowCounter > 1000) { Flora.Update(this); GrowCounter = 0; } #endregion #region Using Items // preview Entities.Preview = null; if (quickbar.CurrentItem != null && Geometry.Range(camera.FromRectangle(player.Movement.Area), control.MousePos) < 6) { ItemUse use = new ItemUse(quickbar.CurrentItem.Type.Use); if (use.Type == "placeentity" && CanPlaceEntity(Entities.getType(use.IntValue), control.AtTileX, control.AtTileY)) { Entities.Preview = new Entity(Entities.getType(int.Parse(use.Value)), control.AtTileX, control.AtTileY); } } if (quickbar.UsingItem.Type == "placeblock" && Geometry.Range(camera.FromRectangle(player.Movement.Area), control.MousePos) < 6) { if (placeBlock(control.AtTileX, control.AtTileY, GetBlockType(quickbar.UsingItem.IntValue))) { quickbar.useItem(quickbar.Selected); } } if (quickbar.UsingItem.Type == "placewall" && Geometry.Range(camera.FromRectangle(player.Movement.Area), control.MousePos) < 6) { if (placeWall(control.AtTileX, control.AtTileY, GetWallType(quickbar.UsingItem.IntValue))) { quickbar.useItem(quickbar.Selected); } } if (quickbar.UsingItem.Type == "mineblock" && Geometry.Range(camera.FromRectangle(player.Movement.Area), control.MousePos) < 6) { if (mineBlock(control.AtTileX, control.AtTileY)) { quickbar.useItem(quickbar.Selected); } } if (quickbar.UsingItem.Type == "removewall" && Geometry.Range(camera.FromRectangle(player.Movement.Area), control.MousePos) < 6) { if (RemoveWall(control.AtTileX, control.AtTileY)) { quickbar.useItem(quickbar.Selected); } } if (quickbar.UsingItem.Type == "placeentity" && Geometry.Range(camera.FromRectangle(player.Movement.Area), control.MousePos) < 6 && CanPlaceEntity(Entities.getType(quickbar.UsingItem.IntValue), control.AtTileX, control.AtTileY)) { if( Entities.Add(control.AtTileX, control.AtTileY, quickbar.UsingItem.IntValue) ) { quickbar.useItem(quickbar.Selected); } } if (quickbar.UsingItem.Type == "removeentity" && Geometry.Range(camera.FromRectangle(player.Movement.Area), control.MousePos) < 6) { if( Entities.Damage(control.AtTileX, control.AtTileY)) { quickbar.useItem(quickbar.Selected); } } #endregion #region Lighting lighting.ClearShadows(); int startx = (int)MathHelper.Clamp(camera.X * -1 / 24f, 0, this.SizeX); int endx = startx + camera.Width / 24; int starty = (int)MathHelper.Clamp(camera.Y * -1 / 24f, 0, this.SizeY); int endy = starty + camera.Height / 24; for (int x = startx; x <= endx + 2; x++) { for (int y = starty; y <= endy; y++) { if (Blocks[x, y] != null) { lighting.AddShadow(camera.FromRectangle(new Rectangle(x * 24, y * 24,24,24))); } if (Fluids.Water.Blocks[x, y] > 18) { lighting.AddShadow(camera.FromRectangle(new Rectangle(x * 24, y * 24, 24, 24))); } } } #endregion }