Beispiel #1
0
        /// <summary>
        /// Spanws gold for given player.
        /// </summary>
        /// <param name="player">The player.</param>
        /// <param name="position">The position for drop.</param>
        public void SpawnGold(Actor source, Player player)
        {
            // TODO: Gold should be spawned for all players in range. /raist.
            var item = ItemGenerator.CreateGold(player, RandomHelper.Next(1000, 3000)); // somehow the actual ammount is not shown on ground /raist.

            DropItem(source, player, item);
        }
Beispiel #2
0
        /// <summary>
        /// Spanws gold for given player.
        /// </summary>
        /// <param name="player">The player.</param>
        /// <param name="position">The position for drop.</param>
        public void SpawnGold(Actor source, Player player)
        {
            // TODO: Gold should be spawned for all players in range. /raist.
            var item = ItemGenerator.CreateGold(player, RandomHelper.Next(1, 300) * (int)Mooege.Net.GS.Config.Instance.GoldRate);// somehow the actual ammount is not shown on ground /raist.

            if (RandomHelper.NextDouble() < Mooege.Net.GS.Config.Instance.GoldDropRate / 100)
            {
                DropItem(source, player, item);
            }
        }
Beispiel #3
0
        private uint[] _equipment;      // array of equiped items_id  (not item)

        public Equipment(Player owner)
        {
            this._equipment     = new uint[17];
            this._owner         = owner;
            this.Items          = new Dictionary <uint, Item>();
            this._inventoryGold = ItemGenerator.CreateGold(_owner, 0);
            this._inventoryGold.Attributes[GameAttribute.ItemStackQuantityLo] = 0;
            this._inventoryGold.SetInventoryLocation(16, 0, 0);
            this._inventoryGold.Owner = _owner;
            this.Items.Add(_inventoryGold.DynamicID, _inventoryGold);
        }
Beispiel #4
0
        public void LoadFromDB()
        {
            //load everything and make a switch on slot_id
            Item item       = null;
            int  goldAmount = _owner.Toon.GameAccount.DBGameAccount.Gold;

            // Clear already present items
            // LoadFromDB is called every time World is changed, even entering a dungeon
            _stashGrid.Clear();
            _inventoryGrid.Clear();



            // first of all load stash size

            var slots = this._owner.Toon.GameAccount.DBGameAccount.StashSize;

            if (slots > 0)
            {
                _owner.Attributes[GameAttribute.Shared_Stash_Slots] = slots;
                _owner.Attributes.BroadcastChangedIfRevealed();
                // To be applied before loading items, to have all the space needed
                _stashGrid.ResizeGrid(_owner.Attributes[GameAttribute.Shared_Stash_Slots] / 7, 7);
            }

            // next load all stash items
            var stashInventoryItems =
                _dbInventories.Where(
                    dbi =>
                    dbi.DBGameAccount.Id == _owner.Toon.GameAccount.PersistentID && dbi.DBToon == null &&
                    dbi.DBItemInstance != null).ToList();

            foreach (var inv in stashInventoryItems)
            {
                var slot = inv.EquipmentSlot;

                if (slot == (int)EquipmentSlotId.Stash)
                {
                    // load stash
                    item                = ItemGenerator.LoadFromDBInstance(_owner, inv.DBItemInstance);
                    item.DBInventory    = inv;
                    item.DBItemInstance = inv.DBItemInstance;
                    this._stashGrid.AddItem(item, inv.LocationY, inv.LocationX);
                }
            }

            // next read all items
            var allInventoryItems = _dbInventories.Where(
                dbi =>
                dbi.DBToon != null && dbi.DBToon.Id == _owner.Toon.PersistentID && dbi.DBItemInstance != null).ToList();


            foreach (var inv in allInventoryItems)
            {
                var slot = inv.EquipmentSlot;
                if (slot >= (int)EquipmentSlotId.Inventory && slot <= (int)EquipmentSlotId.Neck)
                {
                    item                = ItemGenerator.LoadFromDBInstance(_owner, inv.DBItemInstance);
                    item.DBInventory    = inv;
                    item.DBItemInstance = inv.DBItemInstance;
                    if (slot == (int)EquipmentSlotId.Inventory)
                    {
                        this._inventoryGrid.AddItem(item, inv.LocationY, inv.LocationX);
                    }
                    else
                    {
                        _equipment.EquipItem(item, (int)slot);
                    }
                }
            }


            this._inventoryGold = ItemGenerator.CreateGold(this._owner, goldAmount);
            this._inventoryGold.Attributes[GameAttribute.ItemStackQuantityLo] = goldAmount; // This is the attribute that makes the gold visible in game
            this._inventoryGold.Owner = _owner;
            this._inventoryGold.SetInventoryLocation((int)EquipmentSlotId.Gold, 0, 0);
            this.Loaded = true;
        }
Beispiel #5
0
 public override Item CreateDrop(Player player)
 {
     return(ItemGenerator.CreateGold(player, RandomHelper.Next(1000, 3000)));
 }