Esempio n. 1
0
 public ItemRepairEvent(RepairBench repairBench, BaseEntity.RPCMessage msg)
 {
     _repairBench = repairBench;
     _player = Server.GetPlayer(msg.player);
     _item = new InvItem(repairBench.inventory.GetSlot(0));
     _msg = msg;
 }
Esempio n. 2
0
 public ItemPickupEvent(CollectibleEntity ce, BaseEntity.RPCMessage msg, Item i)
 {
     _entity = ce;
     _msg = msg;
     _player = Server.GetPlayer(msg.player);
     _item = new InvItem(i);
 }
Esempio n. 3
0
 public ItemPickupEvent(CollectibleEntity collectibleEntity, BaseEntity.RPCMessage msg, Item item)
 {
     Entity = collectibleEntity;
     RPCMessage = msg;
     Player = Server.GetPlayer(msg.player);
     Item = new InvItem(item);
 }
Esempio n. 4
0
 public Inventory(int size)
 {
     inv = new InvItem[size];
     for (int k = 0; k < size; k++)
     {
         inv[k] = new InvItem();
     }
     protectsuction = false;
 }
Esempio n. 5
0
        public InventoryModEvent(ItemContainer ic, Item i)
        {
            _item = new InvItem(i);
            _itemContainer = ic;

            if (ic.entityOwner != null)
                _entity = new Entity(ic.entityOwner);
            if (ic.playerOwner != null)
                _owner = Server.GetPlayer(ic.playerOwner);
        }
Esempio n. 6
0
 /// <summary>
 /// Start dragging the item.
 /// </summary>
 void OnDrag(Vector2 delta)
 {
     if (DraggedItem == null && DataContent != null)
     {
         UICamera.currentTouch.clickNotification = UICamera.ClickNotification.BasedOnDelta;
         DraggedItem = DataContent;
         DataContent = null;
         NGUITools.PlaySound(grabSound);
         UpdateCursor();
     }
 }
Esempio n. 7
0
        public InventoryModEvent(ItemContainer itemContainer, Item item)
        {
            ItemContainer = itemContainer;
            Item = new InvItem(item);

            if (itemContainer.playerOwner != null)
                Player = Server.GetPlayer(itemContainer.playerOwner);

            if (itemContainer.entityOwner != null)
                Entity = new Entity(itemContainer.entityOwner);
        }
Esempio n. 8
0
 protected override void OnDettach(InvItem inv)
 {
     foreach (var item in SceneManager.Instance.AttachPoints)
     {
         if (item.Value.Slot == Slot.Fan)
         {
             FanAttachPoint fap = item.Value as FanAttachPoint;
             fap.Stop();
         }
     }
 }
Esempio n. 9
0
        public ItemConditionEvent(Item item, float amount)
        {
            Item = new InvItem(item);
            Amount = amount;

            BasePlayer ownerPlayer = item.GetOwnerPlayer();

            if (ownerPlayer != null) {
                Player = Server.GetPlayer(ownerPlayer);
            }
        }
Esempio n. 10
0
        public override List <MapItem> GenerateItems(BaseMapGenContext map, SpawnList <MapItem> specialItems)
        {
            int            itemCount = Amount.Pick(map.Rand);
            List <MapItem> spawners  = new List <MapItem>();

            SpawnList <MapItem> subList = new SpawnList <MapItem>();

            if (UseSpecialItems)
            {
                for (int ii = 0; ii < specialItems.Count; ii++)
                {
                    MapItem spawn = specialItems.GetSpawn(ii);
                    if (!spawn.IsMoney)
                    {
                        if (Range.Min <= spawn.Value && spawn.Value < Range.Max)
                        {
                            subList.Add(spawn, specialItems.GetSpawnRate(ii));
                        }
                    }
                }
            }

            if (UseMapItems)
            {
                foreach (string key in map.ItemSpawns.Spawns.GetKeys())
                {
                    SpawnList <InvItem> spawns = map.ItemSpawns.Spawns.GetSpawn(key);
                    for (int ii = 0; ii < spawns.Count; ii++)
                    {
                        //TODO: spawn rate is somewhat distorted here
                        InvItem spawn = spawns.GetSpawn(ii);
                        //ItemData data = DataManager.Instance.GetItem(spawn.ID);
                        if (Range.Min <= spawn.ID && spawn.ID < Range.Max)
                        {
                            subList.Add(new MapItem(spawn), spawns.GetSpawnRate(ii));
                        }
                    }
                }
            }

            if (subList.Count == 0)
            {
                return(spawners);
            }

            for (int ii = 0; ii < itemCount; ii++)
            {
                spawners.Add(subList.Pick(map.Rand));
            }

            return(spawners);
        }
Esempio n. 11
0
        public void AddInvItem(InvItem I)
        {
            InvItem FoundInvItem = InvItem.FindInvItem(I.ToString());

            if (FoundInvItem.ToString().Equals("inventory-item"))
            {
                Inventory.Add(I);
            }
            else
            {
                ++FoundInvItem.Amount;
            }
        }
Esempio n. 12
0
        protected static void ItemFunctions_UseItem(InvItem item, Agent agent)
        {
            CustomItem citem = RogueLibs.Instance.Items.Find(i => i.Id == item.invItemName);

            if (citem?.TargetObject != null)
            {
                item.invInterface.ShowOrHideTarget(item);
            }
            else if (citem != null)
            {
                citem.UseItem?.Invoke(item, agent);
            }
        }
Esempio n. 13
0
 private void UpdateTotalValue()
 {
     totalValue = 0;
     for (int i = 0; i < slots.Length; i++)
     {
         InvItem item = slots[i].Get();
         if (item.item != null)
         {
             totalValue += item.GetValue();
         }
     }
     goldText.text = totalValue + " Gold";
 }
Esempio n. 14
0
        public bool CombineItems(InvItem other)
        {
            if (!CombineFilter(other))
            {
                return(false);
            }

            other.contents[0] = invertDictionary[other.contents[0]];

            Count--;
            gc.audioHandler.Play(Owner, VanillaAudio.CombineItem);
            return(true);
        }
Esempio n. 15
0
        public ActionResult Create([Bind(Include = "ItemID,Item,RegisterTypeID")] InvItem invItem)
        {
            if (ModelState.IsValid)
            {
                db.InvItems.Add(invItem);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            ViewBag.RegisterTypeID = new SelectList(db.RegisterTypes, "RegisterTypeID", "RegisterType1", invItem.RegisterTypeID);
            ViewBag.ItemID         = new SelectList(db.Inventories, "ItemID", "ItemID", invItem.ItemID);
            return(View(invItem));
        }
Esempio n. 16
0
        /// <summary>
        /// Removes the character from the team, placing its item back in the inventory.
        /// </summary>
        /// <param name="slot"></param>
        public void RemovePlayerTeam(int slot)
        {
            Character player = DataManager.Instance.Save.ActiveTeam.Players[slot];

            if (player.EquippedItem.ID > -1)
            {
                InvItem heldItem = player.EquippedItem;
                player.DequipItem();
                DataManager.Instance.Save.ActiveTeam.AddToInv(heldItem);
            }

            DataManager.Instance.Save.ActiveTeam.Players.RemoveAt(slot);
        }
Esempio n. 17
0
 public void ClearSlot()
 {
     invItem = null;
     if (defaultIcon)
     {
         icon.sprite = defaultIcon;
     }
     else
     {
         icon.enabled = false;
     }
     stackDisplay.enabled = false;
 }
Esempio n. 18
0
        public static void SetupDetails_Postfix(bool notNew, InvItem __instance)
        {
            string name = __instance.invItemName;

            if (__instance.Categories.Count == 0)
            {
                __instance.Categories.Add("NullCatcher");
            }

            if (__instance.Categories.Contains("Alcohol"))
            {
            }

            if (__instance.Categories.Contains("Drugs"))
            {
            }

            if (__instance.Categories.Contains("Food"))
            {
                if (vItem.nonVegetarian.Contains(name))
                {
                    __instance.Categories.Add("NonVegetarian");
                }
                else if (vItem.vegetarian.Contains(name))
                {
                    __instance.Categories.Add("Vegetarian");
                }
            }

            if (__instance.Categories.Contains("Weapons"))
            {
                if (vItem.blunt.Contains(name))
                {
                    __instance.Categories.Add("Blunt");
                }
                if (vItem.explosive.Contains(name))
                {
                    __instance.Categories.Add("Explosive");
                }
                if (vItem.loud.Contains(name) && !__instance.contents.Contains("Silencer"))
                {
                    __instance.Categories.Add("Loud");
                }
                if (vItem.piercing.Contains(name))
                {
                    __instance.Categories.Add("Piercing");
                }
            }

            return;
        }
Esempio n. 19
0
    public void DragEvent()
    {
        InvItem draggedItem = _dragItem.Value;

        _imageComponent.enabled = draggedItem != null;
        _dragging = draggedItem != null;

        if (draggedItem != null)
        {
            UpdateSprite();

            MoveToMouse();
        }
    }
Esempio n. 20
0
    // Add an amount of an item type to the list.
    // Assuming that items will only be added by pickups.
    public static int Add(PickUp pickup, int quantity)
    {
        // If item is already in list.
        if (items.ContainsKey(pickup.pickupName))
        {
            return(items[pickup.pickupName].Add(quantity));
        }

        // If item is not already in list.
        InvItem added = new InvItem(pickup.pickupName, pickup.pickupDesc, quantity, pickup.gameObject);

        items.Add(pickup.pickupName, added);
        return(quantity);
    }
Esempio n. 21
0
        /// <summary>
        ///   <para>Adds the specified <paramref name="amount"/> of the <typeparamref name="TItem"/> item to the current <paramref name="inventory"/>.</para>
        /// </summary>
        /// <typeparam name="TItem">The type of the item to add to the <paramref name="inventory"/>.</typeparam>
        /// <param name="inventory">The current inventory.</param>
        /// <param name="amount">The amount of the item to add.</param>
        /// <returns>The added item, if found in the inventory; otherwise, <see langword="null"/>.</returns>
        /// <exception cref="ArgumentNullException"><paramref name="inventory"/> is <see langword="null"/>.</exception>
        /// <exception cref="ArgumentOutOfRangeException"><paramref name="amount"/> is less than or equal to 0.</exception>
        public static TItem AddItem <TItem>(this InvDatabase inventory, int amount) where TItem : CustomItem
        {
            if (inventory is null)
            {
                throw new ArgumentNullException(nameof(inventory));
            }
            if (amount <= 0)
            {
                throw new ArgumentOutOfRangeException(nameof(amount), amount, $"{nameof(amount)} is less than or equal to 0.");
            }
            InvItem item = inventory.AddItem(ItemInfo.Get <TItem>().Name, amount);

            return(item?.GetHook <TItem>());
        }
Esempio n. 22
0
        // GET: InvItems/Delete/5
        public ActionResult Delete(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            InvItem invItem = db.InvItems.Find(id);

            if (invItem == null)
            {
                return(HttpNotFound());
            }
            return(View(invItem));
        }
Esempio n. 23
0
    public InvItem(InvItem assetItem)
    {
        // Duplicates Asset to Runtime instance
        // (Do it the long way to ensure no connections remain to the asset file)

        count             = assetItem.count;
        tex               = assetItem.tex;
        id                = assetItem.id;
        label             = assetItem.label;
        useActionList     = assetItem.useActionList;
        lookActionList    = assetItem.lookActionList;
        combineActionList = assetItem.combineActionList;
        combineID         = assetItem.combineID;
    }
Esempio n. 24
0
        /// <summary>
        /// Sends a team member home without affecting the ground map.
        /// </summary>
        /// <param name="index">Index of team member.</param>
        /// <param name="front">Whether to put the team member in front or in back of the assembly list.</param>
        public void SilentSendHome(int index)
        {
            Character player = DataManager.Instance.Save.ActiveTeam.Players[index];

            if (player.EquippedItem.ID > -1)
            {
                InvItem heldItem = player.EquippedItem;
                player.DequipItem();
                DataManager.Instance.Save.ActiveTeam.AddToInv(heldItem);
            }

            DataManager.Instance.Save.ActiveTeam.AddToSortedAssembly(player);
            RemoveChar(index);
        }
Esempio n. 25
0
        public static void update()
        {
            List <InvItem> removal = new List <InvItem>();
            Dictionary <InvItem, float> newDictionary = new Dictionary <InvItem, float>();

            foreach (KeyValuePair <InvItem, float> pair in SoulCooldowns)
            {
                newDictionary.Add(pair.Key, Mathf.Max(pair.Value - Time.fixedDeltaTime, 0f));
            }
            SoulCooldowns = newDictionary;

            /*if(thisAgent != null && thisAgent.dead && recoverItem)
             * {
             *                  recoverItem = false;
             *                  thisAgent.inventory.AddItem("EmptySoulStone", 1);
             *          }*/
            foreach (KeyValuePair <InvItem, Agent> pair in SoulUpdateList)
            {
                InvItem item = pair.Key;
                if (pair.Key == null || pair.Value == null)
                {
                    removal.Add(item);
                    continue;
                }
                if (pair.Value.dead)
                {
                    item.database.DestroyItem(item);
                    item.database.AddItem("EmptySoulStone", 1);
                    removal.Add(item);
                    if (SoulBreakerItem != null)
                    {
                        SoulBreakerItem.database.DestroyItem(SoulBreakerItem);
                        SoulBreakerItem = null;
                    }

                    item.agent.mainGUI.invInterface.HideDraggedItem();
                    item.agent.mainGUI.invInterface.HideTarget();
                }
            }
            foreach (InvItem item in removal)
            {
                SoulUpdateList.Remove(item);
                SoulCooldowns.Remove(item);
                if (SoulBreakerItem != null)
                {
                    SoulBreakerItem.database.DestroyItem(SoulBreakerItem);
                    SoulBreakerItem = null;
                }
            }
        }
Esempio n. 26
0
        public IEnumerator <YieldInstruction> ProcessTakeItem(GroundChar character, int teamSlot)
        {
            ExplorerTeam memberTeam = DataManager.Instance.Save.ActiveTeam;
            Character    itemChar   = memberTeam.Players[teamSlot];

            //no curse check in ground mode

            InvItem item = itemChar.EquippedItem;

            memberTeam.AddToInv(item);
            itemChar.DequipItem();
            GameManager.Instance.SE(DataManager.Instance.EquipSE);
            yield return(CoroutineManager.Instance.StartCoroutine(MenuManager.Instance.SetDialogue(false, Text.FormatKey("MSG_ITEM_DEQUIP", itemChar.Name, item.GetName()))));
        }
Esempio n. 27
0
 private void UnequipItem(InvItem item)
 {
     item.PlayerClicked.AddListener(EquipItem);
     GetComponent <Inventory>().GiveItem(item);
     if ((int)item.ItemType <= 3)// it armor
     {
         VisibleArmor.SetActive(false);
         GetComponent <Health>().IncomingDamageMultiplier = 1.0f;
     }
     else
     {
         VisibleWeapon.SetActive(false);
     }
 }
Esempio n. 28
0
        public InventoryModEvent(ItemContainer ic, Item i)
        {
            _item          = new InvItem(i);
            _itemContainer = ic;

            if (ic.entityOwner != null)
            {
                _entity = new Entity(ic.entityOwner);
            }
            if (ic.playerOwner != null)
            {
                _owner = Server.GetPlayer(ic.playerOwner);
            }
        }
Esempio n. 29
0
        public static bool UseItem_Prefix(InvItem item, Agent agent, ItemFunctions __instance)
        {
            if (item.itemType == "Consumable")
            {
                if (vItem.alcohol.Contains(item.invItemName) &&
                    ((agent.statusEffects.hasTrait(cTrait.FriendOfBill) || agent.statusEffects.hasTrait(cTrait.Teetotaller))))
                {
                    BMHeaderTools.SayDialogue(agent, cDialogue.CantDrinkAlcohol, vNameType.Dialogue);
                    goto terminus;
                }
                else if (vItem.drugs.Contains(item.invItemName) &&
                         (agent.statusEffects.hasTrait(cTrait.DAREdevil) || agent.statusEffects.hasTrait(cTrait.Teetotaller)))
                {
                    BMHeaderTools.SayDialogue(agent, cDialogue.CantUseDrug, vNameType.Dialogue);
                    goto terminus;
                }
                else if (vItem.nonVegetarian.Contains(item.invItemName) && agent.statusEffects.hasTrait(cTrait.Vegetarian))
                {
                    BMHeaderTools.SayDialogue(agent, cDialogue.CantEatMeat, vNameType.Dialogue);
                    goto terminus;
                }
                else if (vItem.vegetarian.Contains(item.invItemName) && agent.statusEffects.hasTrait(cTrait.Carnivore))
                {
                    BMHeaderTools.SayDialogue(agent, cDialogue.CantEatNonvegetarian, vNameType.Dialogue);
                    goto terminus;
                }
            }
            else
            {
                if (vItem.loud.Contains(item.invItemName) && agent.statusEffects.hasTrait(cTrait.AfraidOfLoudNoises))
                {
                    BMHeaderTools.SayDialogue(agent, cDialogue.CantUseLoud, "Dialogue");
                    goto terminus;
                }

                if (vItem.piercing.Contains(item.invItemName) && agent.statusEffects.hasTrait(cTrait.DrawNoBlood))
                {
                    BMHeaderTools.SayDialogue(agent, cDialogue.CantUseSharp_2, vNameType.Dialogue);
                    goto terminus;
                }
            }

            return(true);

terminus:

            GC.audioHandler.Play(agent, "CantDo");

            return(false);
        }
Esempio n. 30
0
    public void Add(int _id, int amount)
    {
        // Raise "count" by 1 for appropriate ID

        if (localItems.Count == 0)
        {
            isLocked = false;
        }

        bool isCarrying = false;

        foreach (InvItem item in localItems)
        {
            if (item.id == _id)
            {
                isCarrying = true;

                if (!item.canCarryMultiple)
                {
                    amount = 1;
                }

                break;
            }
        }

        if (!isCarrying)
        {
            GetReferences();

            if (inventoryManager)
            {
                foreach (InvItem assetItem in inventoryManager.items)
                {
                    if (assetItem.id == _id)
                    {
                        InvItem newItem = assetItem;

                        if (!newItem.canCarryMultiple)
                        {
                            amount = 1;
                        }

                        newItem.count = amount;
                        localItems.Add(newItem);
                    }
                }
            }
        }
    }
Esempio n. 31
0
        //public IEnumerator<YieldInstruction> ArriveOnTile(Character character)

        //public IEnumerator<YieldInstruction> ArriveOnTile(Character character, bool checkItem, bool wantItem, bool noTrap)



        private IEnumerator <YieldInstruction> ProcessUseItem(GroundChar character, int invSlot, bool held)
        {
            InvItem invItem = null;

            if (held)
            {
                Character activeChar = DataManager.Instance.Save.ActiveTeam.Players[invSlot];
                invItem = activeChar.EquippedItem;
            }
            else
            {
                invItem = DataManager.Instance.Save.ActiveTeam.GetInv(invSlot);
            }

            ItemData itemEntry = (ItemData)invItem.GetData();

            switch (itemEntry.UsageType)
            {
            case ItemData.UseType.Learn:
            {
                ItemIndexState effect = itemEntry.ItemStates.GetWithDefault <ItemIndexState>();
                int            skill  = effect.Index;

                Character player = (Character)character.Data;
                int       learn  = -1;
                yield return(CoroutineManager.Instance.StartCoroutine(DungeonScene.TryLearnSkill(player, skill, (int slot) => { learn = slot; }, () => { })));

                if (learn > -1)
                {
                    yield return(CoroutineManager.Instance.StartCoroutine(DungeonScene.LearnSkillWithFanfare(player, skill, learn)));
                }
                else
                {
                    yield break;
                }
            }
            break;
            }

            if (held)
            {
                Character activeChar = DataManager.Instance.Save.ActiveTeam.Players[invSlot];
                activeChar.EquippedItem = new InvItem();
            }
            else
            {
                DataManager.Instance.Save.ActiveTeam.RemoveFromInv(invSlot);
            }
        }
Esempio n. 32
0
        public static void EquipReinforcement(Agent agent)
        {
            InvItem item = new InvItem
            {
                invItemName = gc.Choose(vItem.Pistol, vItem.Knife)
            };

            item.ItemSetup(false);
            item.invItemCount = item.rewardCount;

            agent.inventory.AddItemAtEmptySlot(item, true, false);
            agent.inventory.equippedWeapon = item;

            agent.inventory.startingHeadPiece = vArmorHead.HardHat;
        }
Esempio n. 33
0
        // GET: InvItems/Edit/5
        public ActionResult Edit(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            InvItem invItem = db.InvItems.Find(id);

            if (invItem == null)
            {
                return(HttpNotFound());
            }
            ViewBag.InvTableId = new SelectList(db.InvTables, "Id", "Letter", invItem.InvTableId);
            return(View(invItem));
        }
Esempio n. 34
0
        public AttachInvSeriesBatch(InvTrans trans) : base(trans)
        {
            InitializeComponent();
            this.invTrans = trans;
            var cache = api.CompanyEntity.GetCache(typeof(InvItem));

            invItemMaster            = cache.Get(trans._Item) as InvItem;
            dgInvSeriesBatchGrid.api = api;
            dgInvSeriesBatchGrid.UpdateMaster(invItemMaster);
            SetRibbonControl(localMenu, dgInvSeriesBatchGrid);
            dgInvSeriesBatchGrid.BusyIndicator = busyIndicator;
            localMenu.OnItemClicked           += LocalMenu_OnItemClicked;

            txtQty.Text = Math.Abs(this.invTrans._Qty).ToString();
        }
Esempio n. 35
0
 public void AddItem(InvItem _item)
 {
     invItem      = _item;
     icon.enabled = true;
     icon.sprite  = invItem.item.icon;
     if (invItem.stackCount == 1)
     {
         stackDisplay.enabled = false;
     }
     else
     {
         stackDisplay.enabled = true;
         stackDisplay.text    = invItem.stackCount.ToString();
     }
 }
        public void PreviewApply(InventoryOperationState state)
        {
            InvItem i = null;

            if (!Applied)
            {
                i    = new InvItem(DefaultHelper.CreateRef(ItemID, Type, Location), Location);
                item = i.Item;
            }

            if (i != null)
            {
                state.Inventory.Add(i);
            }
        }
Esempio n. 37
0
        public bool CombineItems(InvItem other)
        {
            if (!CombineFilter(other))
            {
                return(false);
            }

            SpicedHook hook = other.GetHook <SpicedHook>() ?? other.AddHook <SpicedHook>();

            hook.IncreaseSpiciness();

            Count--;
            gc.audioHandler.Play(Owner, VanillaAudio.CombineItem);
            return(true);
        }
Esempio n. 38
0
        public static void EquipReinforcement(Agent agent)
        {
            InvItem item = new InvItem
            {
                invItemName = gc.Choose(vItem.Revolver, vItem.MachineGun)
            };

            item.ItemSetup(false);
            item.invItemCount = item.rewardCount;

            agent.inventory.AddItemAtEmptySlot(item, true, false);
            agent.inventory.equippedWeapon = item;

            agent.inventory.startingHeadPiece = vArmorHead.SoldierHelmet;
        }
Esempio n. 39
0
        public InvUpdate(WorldPacket data)
        {
            Items = new List <InvItem>();
            int size = data.ReadBits <int>(2);

            for (int i = 0; i < size; ++i)
            {
                var item = new InvItem
                {
                    ContainerSlot = data.ReadUInt8(),
                    Slot          = data.ReadUInt8()
                };
                Items.Add(item);
            }
        }
Esempio n. 40
0
 /// <summary>
 /// Allow to move objects around via drag & drop.
 /// </summary>
 void OnClick()
 {
     if (DraggedItem != null)
     {
         OnDrop(null);
     }
     else
     {
         if (DataContent != null)
         {
             DraggedItem = DataContent;
             DataContent = null;
             NGUITools.PlaySound(grabSound);
             UpdateCursor();
         }
     }
 }
Esempio n. 41
0
    public void add(string aname, int quant)
    {
        int i = -1;
        for (int k = 0; k < inv.Length; k++)
        {
            if (inv[k].socket.asock.name == aname)
            {
                inv[k].num += quant;
                return;
            }
            if (i == -1 && inv[k].num == 0)
            {
                i = k;
            }
        }

        if (i != -1)
        {
            inv[i] = new InvItem(aname, quant);
        }
    }
Esempio n. 42
0
 public PlayerClothingEvent(PlayerInventory playerInventory, Item item)
 {
     Player = Server.GetPlayer(playerInventory.containerMain.playerOwner);
     Item = new InvItem(item);
 }
Esempio n. 43
0
		private static void AddInv(object o)
		{

			// Handle contained objects (iterative ;)

			if (o is BaseContainer)
			{
				foreach (Item item in ((BaseContainer)o).Items)
				{
					if (m_ItemType == null)
					{
						AddInv(item);
						continue;
					}

					Type it = item.GetType();

					if (it.IsSubclassOf(m_ItemType) || it == m_ItemType || item is BaseContainer)
						AddInv(item);
				}

				// Do we want to inventory this container, or return?
				Type ct = o.GetType();

				if (!(m_ItemType == null) && !ct.IsSubclassOf(m_ItemType) && ct != m_ItemType)
					return;
			}

			// Handle this object

			InvItem ir = new InvItem(o.GetType());

			// Determine and set inv item properties

			if (o is BaseWeapon)
			{
				BaseWeapon bw = (BaseWeapon)o;

				ir.m_accuracy = bw.AccuracyLevel.ToString();
				ir.m_damage = bw.DamageLevel.ToString();
				ir.m_durability = bw.DurabilityLevel.ToString();
				ir.m_slayer = bw.Slayer.ToString();

			}
			else if (o is BaseArmor)
			{
				BaseArmor ba = (BaseArmor)o;

				ir.m_durability = ba.Durability.ToString();
				ir.m_damage = ba.ProtectionLevel.ToString();

			}
			else if (o is EnchantedScroll)
			{
				EnchantedItem ei = (EnchantedItem)o;

				// ProtectionLevel, Durability

				if (ei.ItemType.IsSubclassOf(typeof(BaseArmor)))
				{
					ir.m_durability = ((ArmorDurabilityLevel)ei.iProps[1]).ToString();
					ir.m_damage = ((ArmorProtectionLevel)(ei.iProps[0])).ToString();
				}
				else if (ei.ItemType.IsSubclassOf(typeof(BaseWeapon)))
				{
					ir.m_accuracy = ((WeaponAccuracyLevel)ei.iProps[2]).ToString();
					ir.m_damage = ((WeaponDamageLevel)ei.iProps[0]).ToString();
					ir.m_durability = ((WeaponDurabilityLevel)ei.iProps[1]).ToString();
					ir.m_slayer = ((SlayerName)ei.iProps[3]).ToString();
				}
			}

			if (o is Item)
			{

				Item it = (Item)o;

				if (it.PlayerCrafted == true)
				{
					// It's playercrafted, so check for 'Quality' property
					string strVal = Properties.GetValue(m_from, o, "Quality");

					if (strVal == "Quality = Exceptional")
						ir.m_quality = "Exceptional";
				}

				if (it.Amount > 0)
					ir.m_count = it.Amount;

				ir.m_serial = it.Serial;

				// adam: Find the best name we can
				if (o is EnchantedScroll)
				{
					EnchantedItem ei = (EnchantedItem)o;
					ir.m_description = ei.ItemType.Name + ".scroll";
				}
				else
				{
					if (valid(it.Name))
						ir.m_description = it.Name;
					else if (valid(it.ItemData.Name) && (it.GetType().Name == null || it.GetType().Name == "Item" || it.GetType().Name == "Static"))
						ir.m_description = it.ItemData.Name;
					else
						ir.m_description = it.GetType().Name;
				}
			}

			// Make sure there are no others like this

			foreach (InvItem ii in m_Inv)
			{

				if (ii.m_type == ir.m_type &&
					ii.m_accuracy == ir.m_accuracy &&
					ii.m_damage == ir.m_damage &&
					ii.m_quality == ir.m_quality &&
					ii.m_durability == ir.m_durability &&
					ii.m_slayer == ir.m_slayer &&
					ii.m_description == ir.m_description) //pla: include new field in this check
				{

					// It exists, so increment and return
					ii.m_count += ir.m_count;

					return;
				}
			}

			// It doesn't exist, so add it
			m_Inv.Add(ir);
		}
Esempio n. 44
0
 public ItemConditionEvent(Item item, float amount)
 {
     _item = new InvItem(item);
     _amount = amount;
 }
Esempio n. 45
0
 public InvItem InteractItem(InvItem MouseInvHeld, Inventory theinv, int k)
 {
     if (Event.current.button == 1)
     {
         if (MouseInvHeld.num == 0)
         {
             if (socket.asock.name == "")
             {
                 //nil
             }
             else
             {
                 int taken = num / 2;
                 MouseInvHeld = new Inventory.InvItem(socket, taken);
                 theinv.inv[k] = new Inventory.InvItem(socket, num - taken);
             }
         }
         else
         {
             if (socket.asock.name == "")
             {
                 int taken = MouseInvHeld.num / 2;
                 theinv.inv[k] = new Inventory.InvItem(MouseInvHeld.socket, taken);
                 MouseInvHeld = new Inventory.InvItem(MouseInvHeld.socket, MouseInvHeld.num - taken);
             }
             else
             {
                 if (MouseInvHeld.socket.asock.name == socket.asock.name)
                 {
                     theinv.inv[k] = new Inventory.InvItem(MouseInvHeld.socket, num + MouseInvHeld.num);
                     MouseInvHeld = new Inventory.InvItem();
                 }
                 else
                 {
                     Inventory.InvItem BUFF = new Inventory.InvItem(MouseInvHeld.socket, MouseInvHeld.num);
                     MouseInvHeld = new Inventory.InvItem(socket, num);
                     theinv.inv[k] = new Inventory.InvItem(BUFF.socket, BUFF.num);
                 }
             }
         }
     }
     else
     {
         if (MouseInvHeld.num == 0)
         {
             if (socket.asock.name == "")
             {
                 //nil
             }
             else
             {
                 MouseInvHeld = new Inventory.InvItem(socket, num);
                 theinv.inv[k] = new Inventory.InvItem();
             }
         }
         else
         {
             if (socket.asock.name == "")
             {
                 theinv.inv[k] = new Inventory.InvItem(MouseInvHeld.socket, MouseInvHeld.num);
                 MouseInvHeld = new Inventory.InvItem();
             }
             else
             {
                 if (MouseInvHeld.socket.asock.name == socket.asock.name)
                 {
                     theinv.inv[k] = new Inventory.InvItem(MouseInvHeld.socket, num + MouseInvHeld.num);
                     MouseInvHeld = new Inventory.InvItem();
                 }
                 else
                 {
                     Inventory.InvItem BUFF = new Inventory.InvItem(MouseInvHeld.socket, MouseInvHeld.num);
                     MouseInvHeld = new Inventory.InvItem(socket, num);
                     theinv.inv[k] = new Inventory.InvItem(BUFF.socket, BUFF.num);
                 }
             }
         }
     }
     return MouseInvHeld;
 }
Esempio n. 46
0
 public PlayerClothingEvent(PlayerInventory playerInventory, Item item)
 {
     _item = new InvItem(item);
     _player = Server.GetPlayer(playerInventory.GetComponent<BasePlayer>());
 }
Esempio n. 47
0
    /// <summary>
    /// Stop dragging the item.
    /// </summary>
    void OnDrop(GameObject go)
    {
        if (DataContent == null)
        {
            DataContent = DraggedItem;
            DraggedItem = null;
            if (DataContent != null)
            {
                NGUITools.PlaySound(placeSound);
            }
        }
        else
        {
            //if (DataContent != null && )
            // {
            InvItem tmp = DraggedItem;
            DraggedItem = DataContent;
            DataContent = tmp;
            if (DraggedItem != null)
            {
                NGUITools.PlaySound(grabSound);
            }

            //}
        }

        UpdateCursor();
    }
Esempio n. 48
0
 protected override void OnDettach(InvItem inv)
 {
 }
Esempio n. 49
0
 public ConsumeFuelEvent(BaseOven bo, Item fuel, ItemModBurnable burn)
 {
     _baseOven = bo;
     _item = new InvItem(fuel);
     _burn = burn;
 }
Esempio n. 50
0
 public ItemUsedEvent(Item item, int amount)
 {
     Item = new InvItem(item);
     Amount = amount;
 }
Esempio n. 51
0
 /// <summary>
 /// 物件从挂载点拖走时候的回调
 /// </summary>
 /// <param name="inv"></param>
 protected virtual void OnDettach(InvItem inv)
 {
 }
Esempio n. 52
0
 public ItemConditionEvent(Item item, float amount)
 {
     _item = new InvItem(item);
     _amount = amount;
     Player = Server.GetPlayer(item.GetOwnerPlayer());
 }
Esempio n. 53
0
 public ItemUsedEvent(Item item, int amountToConsume)
 {
     _item = new InvItem(item);
     _amount = amountToConsume;
 }
Esempio n. 54
0
 public ConsumeFuelEvent(BaseOven baseOven, Item fuel, ItemModBurnable burnable)
 {
     BaseOven = baseOven;
     Item = new InvItem(fuel);
     Burnable = burnable;
 }