コード例 #1
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);
    }
コード例 #2
0
    private static void EnsureInit()
    {
        if (dm == null)
        {
            dm = Resources.Load("DmObjectData") as DmObjectData;
        }

        if (dmi == null)
        {
            dmi = Resources.Load("DmiIconData") as DmiIconData;
        }
    }
コード例 #3
0
//    Enum test:
//
//    private void OnEnable()
//    {
//        if (hierarchy == null || hierarchy.Equals(""))
//        {
//            hierarchy = cloth.GetDescription();
//        }
//        ConstructItem(hierarchy);
//    }

    public void ConstructItem(string hierString)
    {
        //randomize clothing! uncomment only if you spawn without any clothes on!
        //        randomizeClothHierIfEmpty();

        //don't do anything if hierarchy string is empty
        hier = hierString.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");

        //custom inventory(?) icon, if present
        icon = tryGetAttr("icon");

        //			states
        icon_state = tryGetAttr("icon_state");
        item_color = tryGetAttr("item_color"); //also a state
        item_state = tryGetAttr("item_state");
        var states = new[] { icon_state, item_color, item_state };

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

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

        //inventory item sprite
        Sprite stateSprite = tryGetStateSprite(inventoryIcon, icon_state);

        //finally setting things
        inHandReferenceLeft  = inHandLeft;
        inHandReferenceRight = inHandRight;
        clothingReference    = clothingOffset;
        type            = itemType;
        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"));
    }
コード例 #4
0
    public void ConstructItem(string hierString)
    {
        //randomize clothing!
        randomizeClothHierIfEmpty();

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

        //init datafiles
        if (!dmi)
        {
            //				Logger.Log("Item DMI data loading...");
            dmi = Resources.Load("DmiIconData") as DmiIconData;
        }
        if (!dm)
        {
            //				Logger.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");

        //custom inventory(?) icon, if present
        icon = tryGetAttr("icon");

        //			states
        icon_state = tryGetAttr("icon_state");
        item_color = tryGetAttr("item_color");         //also a state
        item_state = tryGetAttr("item_state");
        string[] states = { icon_state, item_color, item_state };

        throwDamage = TryParseFloat("throwforce") ?? throwDamage;
        throwSpeed  = TryParseFloat("throw_speed") ?? throwSpeed;
        throwRange  = TryParseFloat("throw_range") ?? throwRange;
        hitDamage   = TryParseFloat("force") ?? hitDamage;
        attackVerb  = TryParseList("attack_verb") ?? attackVerb;

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

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

        //inventory item sprite
        Sprite stateSprite = tryGetStateSprite(inventoryIcon, icon_state);

        //finally setting things
        inHandReferenceLeft  = inHandLeft;
        inHandReferenceRight = inHandRight;
        clothingReference    = clothingOffset;
        type            = itemType;
        itemName        = name;
        itemDescription = desc;
        spriteType      = masterType;
        GetComponentInChildren <SpriteRenderer>().sprite = stateSprite;
        //assign an order in layer so we don't have arbitrary ordering
        GetComponentInChildren <SpriteRenderer>().sortingOrder = clothingOffset;

        //			Logger.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"));
        CheckEvaCapatibility();
    }
コード例 #5
0
    public void ConstructItem(string hierString)
    {
        //randomize clothing!
        RandomizeClothHierIfEmpty();

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

        //init datafiles
        if (!dmi)
        {
            dmi = Resources.Load("DmiIconData") as DmiIconData;
        }
        if (!dm)
        {
            dm = Resources.Load("DmObjectData") as DmObjectData;
        }

        dmDic = dm.getObject(hier);

        //basic attributes
        itemName        = TryGetAttr("name");
        itemDescription = TryGetAttr("desc");

        icon = TryGetAttr("icon");

        //states
        icon_state = TryGetAttr("icon_state");
        item_color = TryGetAttr("item_color");         //also a state
        item_state = TryGetAttr("item_state");
        string[] states = { icon_state, item_color, item_state };

        throwDamage = TryParseFloat("throwforce") ?? throwDamage;
        throwSpeed  = TryParseFloat("throw_speed") ?? throwSpeed;
        throwRange  = TryParseFloat("throw_range") ?? throwRange;
        hitDamage   = TryParseFloat("force") ?? hitDamage;
        attackVerb  = TryParseList("attack_verb") ?? attackVerb;

        spriteType    = UniItemUtils.GetMasterType(hier);
        itemType      = UniItemUtils.GetItemType(hier);
        invSheetPaths = UniItemUtils.GetItemClothSheetHier(itemType);

        int[] inHandOffsets = TryGetInHand();
        inHandReferenceLeft  = inHandOffsets[0];
        inHandReferenceRight = inHandOffsets[1];

        inventoryIcon = UniItemUtils.GetInventoryIcon(hier, invSheetPaths, icon, icon_state);

        clothingReference = TryGetClothingOffset(states);

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

        CanConnectToTank = TryGetConnectedToTank();

        //inventory item sprite
        Sprite stateSprite = UniItemUtils.TryGetStateSprite(inventoryIcon, icon_state);

        var childSpriteRenderer = GetComponentInChildren <SpriteRenderer>();

        childSpriteRenderer.sprite = stateSprite;
        //assign an order in layer so we don't have arbitrary ordering
        childSpriteRenderer.sortingOrder = clothingReference;

        CheckEvaCapatibility();
    }
コード例 #6
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"));
        }