Ejemplo n.º 1
0
    private static Sprite tryGetStateSprite(DmiIcon dmiIcon, string icon_state)
    {
        if (dmiIcon == null || dmiIcon.getName().Equals(""))
        {
            Debug.LogErrorFormat("DmiIcon '{0}' is null, unable to get state '{1}'", dmiIcon, icon_state);
            return(new Sprite());
        }

        DmiState iState = dmiIcon.getState(icon_state);

        if (!iState.state.Equals(""))
        {
            return(dmiIcon.spriteSheet[iState.offset]);
        }
        Debug.LogErrorFormat("Failed to find inventory sprite '{1}' in icon '{0}'", dmiIcon.icon, icon_state);
        return(new Sprite());
    }
Ejemplo n.º 2
0
    private static Sprite tryGetStateSprite(DmiIcon dmiIcon, string icon_state)
    {
        if (dmiIcon == null || dmiIcon.getName().Equals(""))
        {
            Logger.Log($"DmiIcon '{dmiIcon}' is null, unable to get state '{icon_state}'", Category.DmMetadata);
            return(new Sprite());
        }

        DmiState iState = dmiIcon.getState(icon_state);

        if (!iState.state.Equals(""))
        {
            return(dmiIcon.spriteSheet[iState.offset]);
        }

        Logger.Log($"Failed to find inventory sprite '{icon_state}' in icon '{dmiIcon.icon}'", Category.DmMetadata);
        return(new Sprite());
    }
Ejemplo n.º 3
0
        private void OnEnable()
        {
            //todo: make more methods static

            //randomize clothing! uncomment only if you spawn without any clothes on!
            randomizeClothHierIfEmpty();

            //don't do anything if hierarchy string is empty
            hier = hierarchy.Trim();
            if (hier.Length == 0)
            {
                return;
            }

            //init datafiles
            if (!dmi)
            {
                Debug.Log("Item DMI data loading...");
                dmi = Resources.Load("DmiIconData") as DmiIconData;
            }
            if (!dm)
            {
                Debug.Log("Item DM data loading...");
                dm = Resources.Load("DmObjectData") as DmObjectData;
            }

            //raw dictionary of attributes
            dmDic = dm.getObject(hier);

            //basic attributes
            name       = tryGetAttr("name");
            desc       = tryGetAttr("desc");
            icon_state = tryGetAttr("icon_state");
            item_state = tryGetAttr("item_state");
            icon       = tryGetAttr("icon");

            masterType    = getMasterType(hier);
            iType         = getItemType(hier, getInvIconPrefix(masterType));
            invSheetPaths = getItemClothSheetHier(iType);
//			size = getItemSize(tryGetAttr("w_class"));
            int[] inHandOffsets = tryGetInHand();
            inHandLeft     = inHandOffsets[0];
            inHandRight    = inHandOffsets[1];
            inventoryIcon  = tryGetInventoryIcon();
            clothingOffset = tryGetClothingOffset();

            //determine item type via sheet name if hier name failed
            if (iType == ItemType.None)
            {
                iType = getItemType(inventoryIcon.getName());
            }

            //inventory item sprite
            DmiState iState      = inventoryIcon.getState(icon_state);
            Sprite   stateSprite = inventoryIcon.spriteSheet[iState.offset];

            //finally setting things
            inHandReferenceLeft  = inHandLeft;
            inHandReferenceRight = inHandRight;
            clothingReference    = clothingOffset;
            type            = iType;
            itemName        = name;
            itemDescription = desc;
            GetComponentInChildren <SpriteRenderer>().sprite = stateSprite;

            Debug.Log(name + " size=" + size + " type=" + type + " spriteType="
                      + spriteType + " (" + desc + ") : "
                      + icon_state + " / " + item_state + " / C: " + clothingReference
                      + ", L: " + inHandReferenceLeft + ", R: " + inHandReferenceRight + ", I: " + inventoryIcon.icon + '\n'
                      + dmDic.Keys.Aggregate("", (current, key) => current + (key + ": ") + dmDic[key] + "\n"));
        }