コード例 #1
0
    public void HitBySwing(GameObject hit, GameObject item)
    {
        //Script Reference
        ItemAttributes ia = item.GetComponent <ItemAttributes>();

        if (ic.selectedSlot != null)
        {
            if (ic.selectedSlot.childCount > 0)
            {
                string weapon = ic.selectedSlot.GetChild(0).gameObject.name;                 //The equipped weapon
                float  swingSpeed;                                                           //The weapon's swing speed
                float  efficiency = ia.killingEfficiency;                                    //The weapon's strength
                string actionType = "Combat";                                                //To let the coroutine know the next function to call

                //If player is fatigued slow down the swing speed
                if (pat.isFatigued)
                {
                    swingSpeed = ia.swingSpeed * pat.fatiguedResult;
                }
                else                 //otherwise, take the regular swing speed
                {
                    swingSpeed = ia.swingSpeed;
                }

                if (stillSwinging == false)                 // The previous swing time must have been past
                {
                    Debug.Log("Swinging at AI [PlayerActions: 113]");
                    StartCoroutine(SwingTimer(swingSpeed, actionType, efficiency, hit));                     //Start the Timer
                }
            }
        }
    }
コード例 #2
0
 public void cloneAttributesFrom(ItemAttributes attributes)
 {
     Strength     = attributes.Strength;
     Dexterity    = attributes.Dexterity;
     Intelligence = attributes.Intelligence;
     Damage       = attributes.Damage;
 }
コード例 #3
0
    //reads everything from file at once, populating dictionary
    public static void InitializeData()
    {
        allData = new Dictionary <string, ItemAttributes>();
        //split into items
        string[] data = File.ReadAllText("Assets/Scripts/ScriptResources/itemdata.txt").Split(new[] { "\r\n\r\n" }, StringSplitOptions.None);

        foreach (string bigstr in data)
        {
            ItemAttributes newAtt = null;
            //split item into lines
            string[] args = bigstr.Split('\n');
            string[] arg0 = args[0].Split('~');
            if (arg0.Length > 1)
            {
                newAtt = new ItemAttributes(allData[arg0[1].Trim()]);//inheritance
            }
            else
            {
                newAtt = new ItemAttributes(Default);//inherit from default
            }
            for (int i = 1; i < args.Length; i++)
            {
                ParseField(args[i], newAtt);
            }

            allData.Add(arg0[0].Trim(), newAtt);
        }
    }
コード例 #4
0
 public ItemAttributes(ItemAttributes clone)
 {
     Text         = clone.Text;
     TextApparent = clone.TextApparent;
     Grabbable    = clone.Grabbable;
     Memorable    = clone.Memorable;
 }
コード例 #5
0
    //We toss the item that we have in our hand away!
    private void ThrowHeldItem()
    {
        //First, we make sure that an item is, in fact, in our hand(s).
        if (!itemIsSelected)
        {
            return;             //If we are holding no item, we return.
        }

        //First, we unparent the object. Then, we make it solid and affected by physics.
        heldItem.GetComponent <Transform> ().parent      = null;
        heldItem.GetComponent <Collider> ().enabled      = true;
        heldItem.GetComponent <Rigidbody> ().isKinematic = false;

        ItemAttributes thrownItemAttributes = heldItem.GetComponent <ItemAttributes> ();

        thrownItemAttributes.setIsThrown(true);

        //Get the direction we want to throw it towards.
        Vector3 throwDirection = fpsCam.transform.forward * heldItem.GetComponent <ItemAttributes>().GetThrowForce();

        //..And add some force, to send it flying.
        heldItem.GetComponent <Rigidbody>().AddForce(throwDirection);

        int tempItemNum = selectedItem;

        //And finally, remove that item from our inventory.
        RemoveItem(selectedItem);

        itemIsSelected = false;
        selectedItem   = -1;

        StartCoroutine(WaitThenSelect(tempItemNum));
    }
コード例 #6
0
    private bool ValidateMicrowaveInteraction(GameObject originator, Vector3 position, string hand)
    {
        PlayerScript ps = originator.GetComponent <PlayerScript>();

        if (ps.canNotInteract() || !ps.IsInReach(position, true))
        {
            return(false);
        }

        GameObject item = ps.playerNetworkActions.Inventory[hand].Item;

        if (item == null)
        {
            return(false);
        }
        ItemAttributes attr = item.GetComponent <ItemAttributes>();

        Ingredient ingredient = new Ingredient(attr.itemName);

        GameObject meal = CraftingManager.Meals.FindRecipe(new List <Ingredient> {
            ingredient
        });

        if (meal)
        {
            ps.playerNetworkActions.CmdStartMicrowave(hand, gameObject, meal.name);
            item.BroadcastMessage("OnRemoveFromInventory", null, SendMessageOptions.DontRequireReceiver);
        }


        return(true);
    }
コード例 #7
0
    public void SetInventorySlot(string slotName, GameObject obj)
    {
        _inventory[slotName] = obj;
        ItemAttributes att = obj.GetComponent <ItemAttributes>();

        if (slotName == "leftHand" || slotName == "rightHand")
        {
            equipment.SetHandItemSprite(slotName, att);
        }
        else
        {
            if (slotName == "id" || slotName == "storage01" ||
                slotName == "storage02" || slotName == "suitStorage")
            {
                //Not setting onPlayer sprites for these as they don't have any
            }
            else
            {
                if (att.spriteType == SpriteType.Clothing)
                {
                    // Debug.Log("slotName = " + slotName);
                    Epos enumA = (Epos)Enum.Parse(typeof(Epos), slotName);
                    equipment.syncEquipSprites[(int)enumA] = att.clothingReference;
                }
            }
        }
    }
コード例 #8
0
ファイル: ObjectHelper.cs プロジェクト: hdgardner/ECF
        /// <summary>
        /// Gets the meta field values.
        /// </summary>
        /// <param name="row">The row.</param>
        /// <returns></returns>
        public static Hashtable GetMetaFieldValues(DataRow row)
        {
            // Get meta class id
            int metaClassId = (int)row["MetaClassId"];

            if (metaClassId == 0)
            {
                return(null);
            }

            ItemAttributes attr      = new ItemAttributes();
            MetaClass      metaClass = MetaHelper.LoadMetaClassCached(CatalogContext.MetaDataContext, metaClassId);

            if (metaClass == null)
            {
                return(null);
            }

            MetaFieldCollection mfs = metaClass.MetaFields;

            if (mfs == null)
            {
                return(null);
            }

            return(GetMetaFieldValues(row, metaClass, ref attr));
        }
コード例 #9
0
    public void CmdSetUISlot(string eventName, GameObject obj)
    {
        ServerCache[eventName] = obj;
        ItemAttributes att = obj.GetComponent <ItemAttributes>();

        if (eventName == "leftHand" || eventName == "rightHand")
        {
            equipment.SetHandItemSprite(eventName, att);
        }
        else
        {
            if (eventName == "id" || eventName == "storage01" || eventName == "storage02" || eventName == "suitStorage")
            {
            }
            else
            {
                if (att.spriteType == UI.SpriteType.Clothing)
                {
                    // Debug.Log("eventName = " + eventName);
                    Epos enumA = (Epos)Enum.Parse(typeof(Epos), eventName);
                    equipment.syncEquipSprites[(int)enumA] = att.clothingReference;
                }
            }
        }
    }
コード例 #10
0
    void OnTriggerEnter(Collider other)
    {
        if (other.gameObject.tag == "Player")
        {
            // add item to inventory (backpack)
            GameObject     imageObject       = Instantiate(Resources.Load(NameOfSlotImage)) as GameObject;
            ItemAttributes attributes        = imageObject.AddComponent <ItemAttributes> ();
            ItemAttributes attributesToClone = GetComponent <ItemAttributes> ();
            attributes.cloneAttributesFrom(attributesToClone);

            //  we need to clone the value from the item on the ground to the item image
            GameObject        manager = GameObject.FindGameObjectWithTag("Manager");
            ManagerReferences refs    = manager.GetComponent <ManagerReferences> ();

            if (other.GetComponent <PlayerBehaviorScript> ().isLocalPlayer)
            {
                GameObject backpack = refs.backpack;
                backpack.GetComponent <BackpackManager> ().AddItem(imageObject);

                if (isServer)
                {
                    Destroy(this.gameObject);
                }
                else
                {
                    refs.localPlayer.GetComponent <PlayerBehaviorScript> ().CmdDestroyObject(this.gameObject);
                }
            }
        }
    }
コード例 #11
0
        public void Next(int celt, out IntPtr ppItemArray, out int pceltFetched)
        {
            EnumOPCItemAttributes attributes2;

            Monitor.Enter(attributes2 = this);
            try
            {
                pceltFetched = 0;
                ppItemArray  = IntPtr.Zero;
                if (this.m_index < this.m_items.Count)
                {
                    pceltFetched = this.m_items.Count - this.m_index;
                    if (pceltFetched > celt)
                    {
                        pceltFetched = celt;
                    }
                    ppItemArray = Marshal.AllocCoTaskMem(Marshal.SizeOf(typeof(OPCITEMATTRIBUTES)) * pceltFetched);
                    IntPtr ptr = ppItemArray;
                    for (int i = 0; i < pceltFetched; i++)
                    {
                        ItemAttributes    attributes = (ItemAttributes)this.m_items[this.m_index + i];
                        OPCITEMATTRIBUTES structure  = new OPCITEMATTRIBUTES {
                            szItemID            = attributes.ItemID,
                            szAccessPath        = attributes.AccessPath,
                            hClient             = attributes.ClientHandle,
                            hServer             = attributes.ServerHandle,
                            bActive             = attributes.Active ? 1 : 0,
                            vtCanonicalDataType = (short)OpcCom.Interop.GetType(attributes.CanonicalDataType),
                            vtRequestedDataType = (short)OpcCom.Interop.GetType(attributes.RequestedDataType),
                            dwAccessRights      = (int)OpcCom.Da.Interop.MarshalPropertyValue(Property.ACCESSRIGHTS, attributes.AccessRights),
                            dwBlobSize          = 0,
                            pBlob    = IntPtr.Zero,
                            dwEUType = (OPCEUTYPE)OpcCom.Da.Interop.MarshalPropertyValue(Property.EUTYPE, attributes.EuType),
                            vEUInfo  = null
                        };
                        switch (attributes.EuType)
                        {
                        case euType.analog:
                            structure.vEUInfo = new double[] { attributes.MinValue, attributes.MaxValue };
                            break;

                        case euType.enumerated:
                            structure.vEUInfo = attributes.EuInfo;
                            break;
                        }
                        Marshal.StructureToPtr(structure, ptr, false);
                        ptr = (IntPtr)(ptr.ToInt32() + Marshal.SizeOf(typeof(OPCITEMATTRIBUTES)));
                    }
                    this.m_index += pceltFetched;
                }
            }
            catch (Exception exception)
            {
                throw OpcCom.Da.Wrapper.Server.CreateException(exception);
            }
            finally
            {
                Monitor.Exit(attributes2);
            }
        }
コード例 #12
0
 public void addItemToItemsToPickUp(ItemAttributes item)
 {
     if (!itemsToPickUp.Contains(item))
     {
         itemsToPickUp.Add(item);
     }
 }
コード例 #13
0
    public IEnumerator pickUpItem()
    {
        if (!pickingUpItem)
        {
            pickingUpItem = true;
            ItemAttributes itemtoPickUp = itemsToPickUp.First();
            //Debug.Log("picking up items");

            while (pickingUpItem && itemsToPickUp.Count > 0)
            {
                if (itemsToPickUp.Contains(itemtoPickUp))
                {
                    StartCoroutine(itemsToPickUp.First().walkingToItem(this));
                }
                else
                {
                    break;
                }

                yield return(null);
            }
            yield return(new WaitForSeconds(1.5f));

            pickingUpItem = false;
            //Debug.Log("donw picking up item");
        }
    }
コード例 #14
0
        /// <summary>
        /// Computes the <see cref="ItemAttributes"/> brought by the set bonuses.
        /// </summary>
        /// <param name="items"></param>
        /// <returns></returns>
        public static ItemAttributes GetActivatedSetBonus(this List <Item> items)
        {
            if (items == null)
            {
                throw new ArgumentNullException("items");
            }

            var attributeSetItemDiscount = items
                                           .Select(i => i.AttributesRaw.AttributeSetItemDiscount)
                                           .Where(asid => asid != null)
                                           .Aggregate(ItemValueRange.Zero, (asid, current) => current + asid);

            var result = new ItemAttributes();

            foreach (var set in items.GetActivatedSets())
            {
                var setItemsCount = set.CountItemsOfSet(items);
                if (setItemsCount >= 2)
                {
                    setItemsCount += (int)Math.Round(attributeSetItemDiscount.Min);
                }
                result += set.GetBonus(setItemsCount);
            }

            return(result);
        }
コード例 #15
0
        public virtual ItemAttribute GetValue(ItemAttributes list, ItemAttribute ia)
        {
            ItemAttributes list2 = new ItemAttributes(ia.Cxt, ia.TableName, ia.ItemID, ia.AttributeID);

            foreach (ListItem li in Items)
            {
                bool contains = list2.Contains(ia.AttributeID, li.Value);

                if (li.Selected && !contains) // selected but no in db
                {
                    ItemAttribute.AddToList(list, ia.ItemID, ia.AttributeID, li.Value);
                }
                else if (!li.Selected && contains) // not selected but in db
                {
                    ItemAttribute iax = list2.Get(ia.AttributeID, li.Value);

                    list.DataTable.ImportRow(iax.DataRow);

                    DataRow row = list.DataTable.Rows[list.DataTable.Rows.Count - 1];

                    row.AcceptChanges();

                    row.Delete(); // mark deleted
                }
            }

            return null;
        }
コード例 #16
0
        public InventoryViewModel(
            IExtendedDialogCoordinator dialogCoordinator,
            ItemAttributes itemAttributes,
            IEnumerable <ushort> jewelPassiveNodes)
        {
            _dialogCoordinator = dialogCoordinator;
            _itemAttributes    = itemAttributes;

            Armor    = CreateSlotVm(ItemSlot.BodyArmour);
            MainHand = CreateSlotVm(ItemSlot.MainHand);
            OffHand  = CreateSlotVm(ItemSlot.OffHand);
            Ring     = CreateSlotVm(ItemSlot.Ring);
            Ring2    = CreateSlotVm(ItemSlot.Ring2);
            Amulet   = CreateSlotVm(ItemSlot.Amulet);
            Helm     = CreateSlotVm(ItemSlot.Helm);
            Gloves   = CreateSlotVm(ItemSlot.Gloves);
            Boots    = CreateSlotVm(ItemSlot.Boots);
            Belt     = CreateSlotVm(ItemSlot.Belt);

            Flasks = ItemSlotExtensions.Flasks.Select(s => CreateSlotVm(s)).ToList();

            TreeJewels = jewelPassiveNodes.Select(i => CreateSlotVm(ItemSlot.SkillTree, i)).ToList();
            ItemJewels = new Dictionary <ItemSlot, IReadOnlyList <InventoryItemViewModel> >
            {
                [ItemSlot.BodyArmour] = CreateItemJewelVms(ItemSlot.BodyArmour, 1),
                [ItemSlot.Helm]       = CreateItemJewelVms(ItemSlot.Helm, 2),
                [ItemSlot.Gloves]     = CreateItemJewelVms(ItemSlot.Gloves, 2),
                [ItemSlot.Boots]      = CreateItemJewelVms(ItemSlot.Boots, 2),
                [ItemSlot.Belt]       = CreateItemJewelVms(ItemSlot.Belt, 2),
            };
        }
コード例 #17
0
        private void SetModuleForItem(Item item)
        {
            ItemAttributes attrs = ItemUtils.GetItemAttributes(item.ItemID);
            // decide and create item module accordingly.
            Type itemType = ItemControllers.FirstOrDefault(
                x => item.ItemID == (x.GetCustomAttribute(typeof(ItemAttribute)) as ItemAttribute).ItemID);

            if (itemType != null)
            {
                if (ItemModules[item.Slot] == null || !(ItemModules[item.Slot].GetType().IsAssignableFrom(itemType)))
                {
                    ItemModules[item.Slot]?.Dispose();
                    ItemModules[item.Slot] = itemType.GetMethod("Create")
                                             .Invoke(null, new object[] { this.leds.Length, this.gameState, item.Slot, this.lightingMode, this.preferredCastMode })
                                             as ItemModule;
                    ItemModules[item.Slot].RequestActivation += OnItemActivated;
                    ItemModules[item.Slot].NewFrameReady     += OnNewFrameReceived;
                    ItemCooldownController.AssignItemIdToSlot(item.Slot, item.ItemID);
                    if (item.ItemID == WardingTotemModule.ITEM_ID)
                    {
                        WardingTotemModule.Current = ItemModules[item.Slot] as WardingTotemModule; // HACK to make it accessible to HUDModule
                    }
                    // TODO: Show an item buy animation here?
                }
                ItemModules[item.Slot].UpdateGameState(gameState);
            }
            else
            {
                ItemModules[item.Slot]?.Dispose();
                ItemModules[item.Slot] = null;
            }
        }
コード例 #18
0
    private static Dictionary <string, string> prepareObjects()
    {
        Dictionary <string, string> tmpDic = new Dictionary <string, string>();
        DmObjectData dm = Resources.Load("DmObjectData") as DmObjectData;

        foreach (Dictionary <string, string> dic in dm.ObjectList)
        {
            string hier = ItemAttributes.tryGetAttr(dic, "hierarchy");
            if (!hier.Equals("") && hier.StartsWith("/obj/item/clothing/")) // these might require fine-tunung
            {
                //                                var name = ItemAttributes.tryGetAttr(dic, "name").Trim()
                //                                        .Replace('-', '_').Replace("\'","")
                //                                        .Replace(' ', '_').Replace("\\","")
                //                                        .Replace("`", "").Replace(".","")
                //                                        .Replace("(", "").Replace("!","")
                //                                        .ToLower();
                string[] hierz = hier.Split('/');
                string   name  = Regex.Replace(
                    ItemAttributes.tryGetAttr(dic, "name")
                    .Trim().Replace('-', '_').Replace(' ', '_')
                    , @"[^a-zA-Z0-9_]", "")
                                 + "__" + hierz[hierz.GetUpperBound(0) - 2]
                                 + "_" + hierz[hierz.GetUpperBound(0) - 1]
                                 + "_" + hierz[hierz.GetUpperBound(0)]
                ;

                tmpDic.Add(
                    hier,
                    name
                    );
            }
        }
        Debug.LogFormat("Prepared objects, tmpDic.size={0}", tmpDic.Count);
        return(tmpDic);
    }
コード例 #19
0
        public ItemValueRange GetHeroDps(IEnumerable <ID3SkillModifier> passives, IEnumerable <ID3SkillModifier> actives)
        {
            var itemAttributes = new ItemAttributes();

            HeroStatsItem.SetLevelBonus(levelAttributes);
            HeroStatsItem.SetParagonLevelBonus(paragonLevelAttributes);

            Update();

            // Build passive bonuses
            foreach (var modifier in passives)
            {
                itemAttributes += modifier.GetBonus(this);
            }

            // Compute the new unique item state with passives
            Update();

            // Build active bonuses
            foreach (var modifier in actives)
            {
                itemAttributes += modifier.GetBonus(this);
            }

            // Finally, return the dps
            return(GetHeroDps(itemAttributes));
        }
コード例 #20
0
 /// <summary>
 /// Computes max damage of the weapon.
 /// </summary>
 /// <param name="weaponAttr">Attributes of a weapon.</param>
 /// <returns></returns>
 public static ItemValueRange GetRawWeaponDamageMax(this ItemAttributes weaponAttr)
 {
     return(weaponAttr.GetRawWeaponDamageMax("Arcane") + weaponAttr.GetRawWeaponDamageMax("Cold")
            + weaponAttr.GetRawWeaponDamageMax("Fire") + weaponAttr.GetRawWeaponDamageMax("Holy")
            + weaponAttr.GetRawWeaponDamageMax("Lightning") + weaponAttr.GetRawWeaponDamageMax("Physical")
            + weaponAttr.GetRawWeaponDamageMax("Poison"));
 }
コード例 #21
0
        public List <AmazonItem> searchFormAmazone(String keyword, out string searchMoreUrl)
        {
            searchMoreUrl = String.Empty;
            List <AmazonItem> amazoneItems = new List <AmazonItem>();
            // Arvutan välja mitu lehekülge on vaja.
            int searchRequestPageCounts = 1;

            if (Settings.SEARCH_RESULTS_PER_PAGE > AMAZON_REQUST_ITEM_LIMIT)
            {
                double neededItems = Convert.ToDouble(Settings.SEARCH_RESULTS_PER_PAGE * Settings.PRELOAD_PAGE_COUNT);
                searchRequestPageCounts = Convert.ToInt32(Math.Ceiling((double)(neededItems / AMAZON_REQUST_ITEM_LIMIT)));
                if (searchRequestPageCounts > AMAZON_REQUST_PAGE_LIMIT)
                {
                    searchRequestPageCounts = AMAZON_REQUST_PAGE_LIMIT;
                }
            }

            // Arvutan mitu päringut ma Amazon'i serveri teen
            int differentRequests = Convert.ToInt32(Math.Ceiling((double)searchRequestPageCounts / (double)AMAZON_MAX_BATCH_REQUEST));

            for (int i = 0; i < differentRequests; i++)
            {
                int startPage = i * AMAZON_MAX_BATCH_REQUEST + 1;
                int endPage   = i * AMAZON_MAX_BATCH_REQUEST + AMAZON_MAX_BATCH_REQUEST;
                if (endPage > searchRequestPageCounts)
                {
                    endPage = endPage - (endPage % searchRequestPageCounts);
                }
                Items[] searchedItems = searchAmazonItems(keyword, startPage, endPage);
                if (searchedItems != null)
                {
                    for (int j = 0; j < searchedItems.Length; j++)
                    {
                        foreach (Item result in searchedItems[j].Item)
                        {
                            ItemAttributes itemAttributes = result.ItemAttributes;
                            Decimal        amount         = Decimal.MinValue;
                            String         currencyCode   = "";
                            if (itemAttributes.ListPrice != null)
                            {
                                Decimal.TryParse(itemAttributes.ListPrice.Amount, out amount);
                                currencyCode = itemAttributes.ListPrice.CurrencyCode;
                                if (amount != Decimal.MinValue)
                                {
                                    amount = amount / 100;
                                }
                            }

                            AmazonItem amazoneItem = new AmazonItem(itemAttributes.Title, amount, currencyCode);
                            amazoneItem.Index      = amazoneItems.Count + 1;
                            amazoneItem.PageNumber = Convert.ToInt32(Math.Ceiling((double)amazoneItem.Index / (double)Settings.SEARCH_RESULTS_PER_PAGE));
                            amazoneItems.Add(amazoneItem);
                        }
                        searchMoreUrl = searchedItems[j].MoreSearchResultsUrl;
                    }
                }
            }

            return(amazoneItems);
        }
コード例 #22
0
    public void SplitItemSingle(GameObject item)
    {
        ItemAttributes ia = item.GetComponent <ItemAttributes>();

        for (int k = 1; k < bag.transform.childCount; k++)
        {
            if (bag.transform.GetChild(k).childCount == 0)
            {
                Debug.Log("Split the Item by 1 [IC: 577]");
                ia.amount -= 1;

                Image icon = Instantiate(ia.icon, transform.position, Quaternion.identity);
                icon.GetComponent <ItemAttributes>().amount = 1;
                icon.name = item.name;

                icon.transform.SetParent(bag.transform.GetChild(k));
                icon.transform.localPosition = new Vector2(0, 0);
                icon.transform.localScale    = new Vector2(1, 1);

                //Change the visible amount integer
                item.GetComponent <ItemStacks>().ChangeAmount(ia.amount);
                icon.GetComponent <ItemStacks>().ChangeAmount(1);
                return;
            }
        }
    }
コード例 #23
0
    public void UseItem(GameObject item)
    {
        ItemAttributes ia = item.GetComponent <ItemAttributes>();

        canUse = false;

        //If the item is a useable
        if (ia.isUseable)
        {
            //Run the Use Timer
            bool  isDepletable = ia.isDepletable;
            bool  ranOnce      = false;
            float useTime      = ia.useTime;

            StartCoroutine(UseTimer(ranOnce, useTime, isDepletable, item));
        }

        //If the item is equippable
        else if (ia.isEquippable)
        {
            string type = ia.equipmentType;
            EquipItem(item, type);
            return;
        }
    }
コード例 #24
0
 /// <summary>
 /// Computes min damage of the item.
 /// </summary>
 /// <param name="itemAttr">Attributes of an item.</param>
 /// <returns></returns>
 public static ItemValueRange GetRawBonusDamageMin(this ItemAttributes itemAttr)
 {
     return(itemAttr.GetRawBonusDamageMin("Arcane") + itemAttr.GetRawBonusDamageMin("Cold")
            + itemAttr.GetRawBonusDamageMin("Fire") + itemAttr.GetRawBonusDamageMin("Holy")
            + itemAttr.GetRawBonusDamageMin("Lightning") + itemAttr.GetRawBonusDamageMin("Physical")
            + itemAttr.GetRawBonusDamageMin("Poison"));
 }
コード例 #25
0
    private GasContainer GetInternalGasMix()
    {
        if (playerScript != null)
        {
            Dictionary <EquipSlot, InventorySlot> inventory = playerScript.playerNetworkActions.Inventory;

            // Check if internals exist
            ItemAttributes mask = inventory.ContainsKey(EquipSlot.mask) ? inventory[EquipSlot.mask]?.ItemAttributes : null;

            bool internalsEnabled = equipment.IsInternalsEnabled;

            //todo: devise a convenient method to get item/script from top level of inventory instead of this
            if (mask != null && mask.CanConnectToTank && internalsEnabled)
            {
                foreach (var gasSlot in GasContainer.GasSlots)
                {
                    if (!inventory.ContainsKey(gasSlot) || inventory[gasSlot] == null || !inventory[gasSlot].Item)
                    {
                        continue;
                    }

                    var gasContainer = inventory[gasSlot].Item.GetComponent <GasContainer>();
                    if (gasContainer)
                    {
                        return(gasContainer);
                    }
                }
            }
        }

        return(null);
    }
コード例 #26
0
ファイル: UI_ItemSlot.cs プロジェクト: grigb/unitystation
    public bool CheckItemFit(GameObject item)
    {
        ItemAttributes attributes = item.GetComponent <ItemAttributes>();

        if (!allowAllItems)
        {
            if (!allowedItemTypes.Contains(attributes.type))
            {
                return(false);
            }
        }
        else if (attributes.size > maxItemSize)
        {
            Logger.LogWarning($"{attributes.size} {item} is too big for {maxItemSize} {eventName}!", Category.UI);
            return(false);
        }

        bool allowed = false;

        if (allowAllItems || allowedItemTypes.Contains(attributes.type))
        {
            allowed = true;
        }
        if (!inventorySlot.IsUISlot && UIManager.StorageHandler.storageCache?.gameObject == item)
        {
            allowed = false;
        }
        return(allowed);
    }
コード例 #27
0
        public virtual string GetLibFmFeatureVector(Feedback feedback)
        {
            string featVector;

            if (feedback is Rating)
            {
                featVector = ((Rating)feedback).Value + " " + GetLibFmFeatureVector(feedback.User.Id, feedback.Item.Id);
            }
            else
            {
                featVector = (feedback.FeedbackType == FeedbackType.Positive ? "1 " : "-1 ") + GetLibFmFeatureVector(feedback.User.Id, feedback.Item.Id);
            }

            _numValues += 2;

            var feedbackAttrs = feedback.Attributes.Values.Where(a => FeedbackAttributes.Contains("all") || FeedbackAttributes.Contains(a.Name));
            var itemAttrs     = feedback.Item.Attributes.Values.Where(a => ItemAttributes.Contains("all") || ItemAttributes.Contains(a.Name));
            var userAttrs     = feedback.User.Attributes.Values.Where(a => UserAttributes.Contains("all") || UserAttributes.Contains(a.Name));

            foreach (var attr in feedbackAttrs.Union(userAttrs).Union(itemAttrs))
            {
                var feat = TranslateAttribute(attr);
                if (feat != null)
                {
                    featVector += string.Format(" {0}:{1}", feat.Item1, feat.Item2);
                    _numValues++;
                }
            }

            return(featVector);
        }
コード例 #28
0
    private void getEncryptionTypeFromHier()
    {
        ItemAttributes attr = GetComponent <ItemAttributes>();

        //switch (attr.hierarchy)
        //{
        //	case "/obj/item/device/radio/headset":
        //		EncryptionKey = EncryptionKeyType.Common;
        //		break;
        //	case "/obj/item/device/radio/headset/heads/captain":
        //	case "/obj/item/device/radio/headset/heads/captain/alt":
        //		EncryptionKey = EncryptionKeyType.Captain;
        //		break;
        //	case "/obj/item/device/radio/headset/heads/ce":
        //		EncryptionKey = EncryptionKeyType.ChiefEngineer;
        //		break;
        //	case "/obj/item/device/radio/headset/heads/cmo":
        //		EncryptionKey = EncryptionKeyType.ChiefMedicalOfficer;
        //		break;
        //	case "/obj/item/device/radio/headset/heads/hop":
        //		EncryptionKey = EncryptionKeyType.HeadOfPersonnel;
        //		break;
        //	case "/obj/item/device/radio/headset/heads/hos":
        //	case "/obj/item/device/radio/headset/heads/hos/alt":
        //		EncryptionKey = EncryptionKeyType.HeadOfSecurity;
        //		break;
        //	case "/obj/item/device/radio/headset/heads/rd":
        //		EncryptionKey = EncryptionKeyType.ResearchDirector;
        //		break;
        //	case "/obj/item/device/radio/headset/headset_cargo":
        //		EncryptionKey = EncryptionKeyType.Supply;
        //		break;
        //	case "/obj/item/device/radio/headset/headset_cent":
        //	case "/obj/item/device/radio/headset/headset_cent/alt":
        //		EncryptionKey = EncryptionKeyType.CentComm;
        //		break;
        //	case "/obj/item/device/radio/headset/headset_eng":
        //		EncryptionKey = EncryptionKeyType.Engineering;
        //		break;
        //	case "/obj/item/device/radio/headset/headset_med":
        //		EncryptionKey = EncryptionKeyType.Medical;
        //		break;
        //	case "/obj/item/device/radio/headset/headset_sci":
        //		EncryptionKey = EncryptionKeyType.Science;
        //		break;
        //	case "/obj/item/device/radio/headset/headset_sec":
        //	case "/obj/item/device/radio/headset/headset_sec/alt":
        //		EncryptionKey = EncryptionKeyType.Security;
        //		break;
        //	case "/obj/item/device/radio/headset/headset_srv":
        //		EncryptionKey = EncryptionKeyType.Service;
        //		break;
        //	case "/obj/item/device/radio/headset/syndicate/alt":
        //		EncryptionKey = EncryptionKeyType.Syndicate;
        //		break;
        //	default:
        //		EncryptionKey = EncryptionKeyType.Common;
        //		break;
        //}
    }
コード例 #29
0
    //Temp solution (move to playerinventory when its completed):
    private bool IsEvaCompatible()
    {
        var headItem = playerScript.playerNetworkActions.Inventory["head"].Item;
        var suitItem = playerScript.playerNetworkActions.Inventory["suit"].Item;

        if (headItem == null || suitItem == null)
        {
            return(false);
        }

        if (headObjCache != headItem)
        {
            headObjCache = headItem;
            if (headObjCache != null)
            {
                headItemAtt = headObjCache.GetComponent <ItemAttributes>();
            }
        }
        if (suitObjCache != suitItem)
        {
            suitObjCache = suitItem;
            if (suitObjCache != null)
            {
                suitItemAtt = suitObjCache.GetComponent <ItemAttributes>();
            }
        }

        return(headItemAtt.evaCapable && suitItemAtt.evaCapable);
    }
コード例 #30
0
 /// <summary>
 /// Computes min damage of the weapon without taking account of "+% weapon damage".
 /// </summary>
 /// <param name="itemAttr">Attributes of a weapon.</param>
 /// <param name="resist"></param>
 /// <returns></returns>
 public static ItemValueRange GetBaseWeaponDamageMin(this ItemAttributes itemAttr, String resist)
 {
     return(itemAttr.GetAttributeByName("damageWeaponMin_" + resist) +
            itemAttr.GetAttributeByName("damageWeaponBonusMin_" + resist) +
            itemAttr.GetAttributeByName("damageWeaponBonusMinX1_" + resist) +
            itemAttr.GetAttributeByName("damageWeaponBonusFlat_" + resist));
 }
コード例 #31
0
    private void ConsumeItem(bool ranOnce, bool isDepletable, GameObject item)
    {
        ItemAttributes ia = item.GetComponent <ItemAttributes>();


        if (ranOnce)
        {
            //If the item is depletable, destroy it
            if (isDepletable)
            {
                if (ia.amount > 1)
                {
                    ia.amount -= 1;
                    item.GetComponent <ItemStacks>().ChangeAmount(ia.amount);
                }

                else
                {
                    Destroy(item);
                }
            }
            //For holder items
            else
            {
            }

            //Go to the Player Actions script to handle the exact usage
            player.GetComponent <PlayerActions>().UseItem(item);
        }
    }
コード例 #32
0
        public ItemAttribute GetValue(ItemAttributes list, ItemAttribute ia)
        {
            ia.Value1 = Value;

            list.Add(ia);

            return ia;
        }
コード例 #33
0
        public virtual ItemAttribute GetValue(ItemAttributes list, ItemAttribute ia)
        {
            ia.Value1 = Text;

            list.Add(ia);
            
            return ia;
        }
コード例 #34
0
        public virtual void SetValue(LayoutE layout, ItemAttribute ia)
        {
            if (!Page.IsPostBack)
            {
                InitControl(layout, ia);
            }

            ItemAttributes list = new ItemAttributes(ia.Cxt, ia.TableName, ia.ItemID, ia.AttributeID);

            for (int i = 0; i < list.Count; i++)
            {
                ItemAttribute iax = new ItemAttribute(ia.Cxt, list[i]);

                ListItem li = Items.FindByValue(iax.Value1);

                if (li != null)
                {
                    li.Selected = true;
                }
            }
        }
コード例 #35
0
 public override ItemAttribute GetValue(ItemAttributes list, ItemAttribute ia)
 {
     return base.GetValue(list, ia);
 }
コード例 #36
0
ファイル: CloudItem.cs プロジェクト: AIBrain/mega-client
		private CloudItem(MegaClient client)
		{
			_client = client;

			Attributes = new ItemAttributes();
			Children = ImmutableHashSet.Create<CloudItem>();
			EncryptedKeys = ImmutableHashSet.Create<EncryptedItemKey>();
		}
コード例 #37
0
        public virtual string GetText(ItemAttribute ia)
        {
            StringBuilder s = new StringBuilder();

            if (!Page.IsPostBack)
            {
                InitControl(LayoutE.Edit, ia);
            }

            ItemAttributes list = new ItemAttributes(ia.Cxt, ia.TableName, ia.ItemID, ia.AttributeID);

            for (int i = 0; i < list.Count; i++)
            {
                ItemAttribute iax = new ItemAttribute(ia.Cxt, list[i]);

                ListItem li = Items.FindByValue(iax.Value1); // TODO: don't use ListItem here

                s.AppendLine("[" + (li != null ? "√" : " ") + "] " + li.Text);
            }

            return s.ToString();
        }
コード例 #38
0
    private ItemAttributes GetItemAttributes()
    {
        if (list != null)
        {
            return list;
        }

        list = new ItemAttributes();
        list.Cxt = Cxt;
        list.ItemID = Uc.ItemID;

        foreach (GridViewRow row in gv1.Rows)
        {
            AttributeUc auc1 = row.Cells[0].FindControl("auc1") as AttributeUc;
            Label laid = row.Cells[0].FindControl("laid") as Label;

            auc1.GetValue(list);
        }

        return list;
    }
コード例 #39
0
 public void GetValue(ItemAttributes list)
 {
     RsCtrl.GetValue(list, ItemAttribute);
 }
コード例 #40
0
        public virtual ItemAttribute GetValue(ItemAttributes list, ItemAttribute ia)
        {
            SaveAs(ia.FilePath());

            list.Add(ia);

            return ia;
        }
コード例 #41
0
        public static ItemAttribute AddToList(ItemAttributes list, int itemID, int attributeID, object value)
        {
            ItemAttribute ia = new ItemAttribute();

            ia.Cxt = list.Cxt;
            ia.ItemID = itemID;
            ia.AttributeID = attributeID;

            if (value != null)
            {
                ia.Value1 = value.ToString();
            }

            list.Add(ia);

            return ia;
        }