示例#1
0
        public void AddToInventory(WorldItem item)
        {
            var itemCount = item.Count;
            for (var i = 0; i < _worldItems.Count; i++)
            {
                WorldItem currentItem = _worldItems[i];
                if (currentItem.MyType == item.MyType && currentItem.Count != maxCollectionSize)
                {
                    if (currentItem.Count + itemCount > maxCollectionSize)
                    {
                        var addon = (byte)(maxCollectionSize - currentItem.Count);
                        currentItem.Count += addon;
                    }
                    else
                    {
                        currentItem.Count += itemCount;
                        item.Count = 0;
                    }
                    break;
                }

            }

            if (item.Count == 0)
            {
                item.InInventory = false;
            }
            else
            {
                item.InventoryPosition = _worldItems.Count;
                System.Diagnostics.Debug.WriteLine("pos:"+item.InventoryPosition);
                item.InInventory = true;
                if (item.InventoryPosition < 10)
                    _quickItems.Add(item);
                _worldItems.Add(item);
            }
        }
示例#2
0
        public void FollowMouse(int index)
        {
            if(_quickItems.Count == 0)
            return;

            MovingItem = true;
            itemFollowMouse = _quickItems[index];
        }
示例#3
0
        public WorldItem RemoveFromInventory()
        {
            MovingItem = false;
            const int limit = 120;
            var gotoX = Inputs.MousePointerRect.X - _hero.HitRect.X;
            var gotoY = Inputs.MousePointerRect.Y - _hero.HitRect.Y;
            var xneg = gotoX < 0;
            var yneg = gotoY < 0;
            gotoX = xneg ? -gotoX : gotoX;
            gotoY = yneg ? -gotoY : gotoY;

            var percX = gotoX/((float) gotoX + gotoY);
            var percY = gotoY/((float) gotoX + gotoY);
            gotoX = (int) (percX*(xneg ? -limit : limit));
            gotoY = (int) (percY*(yneg ? -limit : limit));

            var outputX = (float) (_hero.HitRect.X + gotoX);
            var outputY = (float) (_hero.HitRect.Y + gotoY);
            itemFollowMouse.PutOnGround(outputX, outputY);
            itemFollowMouse.InInventory = false;
            _quickItems.Remove(itemFollowMouse);
            _worldItems.Remove(itemFollowMouse);
            var output = itemFollowMouse;
            itemFollowMouse = null;
            return output;
        }
示例#4
0
 internal void RemoveWorldItem(WorldItem worldItem)
 {
     _itemsOnTile.Remove(worldItem);
 }
示例#5
0
 public void AddWorldItem(WorldItem wi, bool goBlue = false)
 {
     ItemsOnTile.Add(wi);
     #if DEBUG
     if (goBlue)
     {
         ShowHitBox = true;
         _drawHitBoxColor = Color.Blue;
     }
     #endif
 }
示例#6
0
文件: ItemPool.cs 项目: Choochoo/Ship
        private void SetItems(ref byte item, ref TileCollection tile, ref WorldItem worldItem)
        {
            var tileXPos = _random.Next(-1, 1);
            var tileYPos = _random.Next(-1, 1);
            var offsetx = _random.Next(TileManager.Sprite2XWidth);
            var offsety = _random.Next(TileManager.Sprite2XWidth);
            var newTileX = tileXPos < 0 ? tile.LeftVectorX : tileXPos > 0 ? tile.RightVectorX : tile.MyVectorSpotX;
            var newTileY = tileYPos < 0 ? tile.TopVectorY : tileYPos > 0 ? tile.BottomVectorY : tile.MyVectorSpotY;
            var newTile = TileManager.TileColls[newTileX, newTileY];

            worldItem.SetType(ref newTile, item, newTile.HitRect.X + offsetx, newTile.HitRect.Y + offsety);
        }
示例#7
0
文件: ItemPool.cs 项目: Choochoo/Ship
 internal void AddToInactive(WorldItem wic)
 {
     System.Diagnostics.Debug.WriteLine("hit here");
     _itemCollectionsActive.Remove(wic);
     _itemCollectionsInActive.Enqueue(wic);
 }
示例#8
0
文件: ItemPool.cs 项目: Choochoo/Ship
 internal void AddToActiveDropped(ref WorldItem item)
 {
     _itemCollectionsActive.Add(item);
     //find where item is at and add it to the tile.
     var startTile = Hero.MyHero.MyTile;
     while (
         !(item.HitRect.X >= startTile.HitRect.X &&
           item.HitRect.X <= startTile.HitRect.X + TileManager.Sprite2XWidth))
     {
         if (item.HitRect.X > startTile.HitRect.X)
             startTile = TileManager.TileColls[startTile.RightVectorX, startTile.MyVectorSpotY];
         else
             startTile = TileManager.TileColls[startTile.LeftVectorX, startTile.MyVectorSpotY];
     }
     while (
         !(item.HitRect.Y >= startTile.HitRect.Y &&
           item.HitRect.Y <= startTile.HitRect.Y + TileManager.Sprite2XWidth))
     {
         if (item.HitRect.Y > startTile.HitRect.Y)
             startTile = TileManager.TileColls[startTile.MyVectorSpotX, startTile.BottomVectorY];
         else
             startTile = TileManager.TileColls[startTile.MyVectorSpotX, startTile.TopVectorY];
     }
     item.SetTile(ref startTile);
 }