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(); }
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 = UniItemUtils.GetMasterType(hier); // aka SpriteType itemType = UniItemUtils.GetItemType(hier); invSheetPaths = UniItemUtils.GetItemClothSheetHier(itemType); // size = getItemSize(tryGetAttr("w_class")); int[] inHandOffsets = tryGetInHand(); inHandLeft = inHandOffsets[0]; inHandRight = inHandOffsets[1]; inventoryIcon = UniItemUtils.GetInventoryIcon(hier, invSheetPaths, icon, icon_state); clothingOffset = tryGetClothingOffset(states); //determine item type via sheet name if hier name failed if (itemType == ItemType.None) { itemType = UniItemUtils.GetItemType(inventoryIcon.getName()); } //determine if this is a mask that can connect to a tank CanConnectToTank = tryGetConnectedToTank(); //inventory item sprite Sprite stateSprite = UniItemUtils.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(); }