Beispiel #1
0
 public Inventory(int bagSize, int quickbarSize, int bankSize, int money, int bankedMoney)
 {
     Bag = new Bag(40);
     Quickbar = new Quickbar(quickbarSize);
     Bank = new Item[bankSize];
     Money = money;
     BankedMoney = bankedMoney;
 }
Beispiel #2
0
        public Quickbar Quickbar; // Just one quickbar

        #endregion Fields

        #region Constructors

        public Inventory()
        {
            Bag = new Bag(40);
            Quickbar = new Quickbar(10);
            Bank = new Item[80];
            Money = 99999;
            BankedMoney = 12345;
        }
Beispiel #3
0
        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
        }