public void equipItem(int itemID, string type) { if (type == "Weapon") { equipWeapon(itemID); return; } if (type == "Shoe") { for (int i = 0; i < shoes.Length; i++) { Destroy(equips[i]); equips[i] = Instantiate(ResourceStructure.getGameObjectFromPath(ItemDataProvider.getInstance().getStats(itemID).getString("pathToModel"))); equips[i].transform.SetParent(this.character.transform.GetChild(1)); equips[i].GetComponent <SkinnedMeshRenderer>().rootBone = headTransform.transform; } return; } Debug.Log("EQUIPS LENGTH: " + type); int index = getIndex(type); Transform trans = equips[index].GetComponent <Transform>(); GameObject tempItem = Instantiate(ResourceStructure.getGameObjectFromPath(ItemDataProvider.getInstance().getStats(itemID).getString("pathToModel"))); equips[index].GetComponent <SkinnedMeshRenderer>().sharedMesh = tempItem.GetComponent <SkinnedMeshRenderer>().sharedMesh; equips[index].GetComponent <SkinnedMeshRenderer>().sharedMaterial = tempItem.GetComponent <SkinnedMeshRenderer>().sharedMaterial; Destroy(tempItem); }
public void setEquip(Equip equip) { int index = (equip.getID() / Tools.ITEM_INTERVAL) - 2; Equip item; foreach (Transform child in player.getEquipSlot(equip).transform.getAllChildren()) { Destroy(child.gameObject); } if ((item = equips[index]) != null) { item.setPosition(equip.getPosition()); player.getInventory().addItem(item); } equips[index] = equip; GameObject itemEquip = Instantiate(Resources.Load <GameObject>(ItemDataProvider.getInstance().getStats(equip.getID()).getString("pathToModel"))); itemEquip.transform.SetParent(player.getEquipSlot(equip).transform); itemEquip.transform.localScale = Vector3.one; itemEquip.transform.localPosition = Vector3.zero; itemEquip.transform.localRotation = Quaternion.identity; player.getNetwork().equipItem(equip); updateSlots(); }
void spawnDrop(Monster monster, Vector3 position) { for (int i = 0; i < monster.dropIds.Length; i++) { if (!isUnder(monster.dropChance[i])) { continue; } int itemID = monster.dropIds[i]; Debug.Log("item ID here!: " + itemID + " : " + i); GameObject prefab; prefab = (GameObject)Instantiate(ResourceStructure.getGameObjectFromPath(ItemDataProvider.getInstance().getStats(itemID).getString("pathToDropModel"))); //Drop drop = prefab.AddComponent<Drop>(); NetworkIdentity identity = prefab.GetComponent <NetworkIdentity>(); int itemQuantity = monster.dropQuantity[i]; Item item = new Item(itemID); item.setQuantity(itemQuantity); Drop drop = prefab.GetComponent <Drop>(); drop.initilize(item); //drop.initilize(item, this.targetNetwork); prefab.transform.position = position; NetworkServer.Spawn(prefab); ItemInfo packet = new ItemInfo(); packet.item = Tools.objectToByteArray(item); packet.netId = identity.netId; NetworkServer.SendToAll(PacketTypes.DROP_INIT, packet); } }
public void getItem(int position, bool hasEnded, string value) { string newValue = "<color=\"#6CB95DFF\">"; if (hasEnded) { int p = int.Parse(value); newValue = ItemDataProvider.getInstance().getStats(p).getString("name") + "</color>"; } tagValue += newValue; }
//förvandlar |i| till color. public void getItems(int position, bool hasEnded, string value) { string newValue = "<color=\"#6CB95DFF\">"; //kollar om den stötter på en stängd i. if (hasEnded) { int p = int.Parse(value); //hämtar item namnet beroende på vilket id det är mellan tagsen. newValue = ItemDataProvider.getInstance().getStats(p).getString("name") + "'s</color>"; } tagValue += newValue; }
public static void setEquipModel(Item item, GameObject[] origins) { int index = 0; if (item.getID().isItemType(e_itemTypes.WEAPON)) { index = 1; } GameObject itemEquip = Instantiate(Resources.Load <GameObject>(ItemDataProvider.getInstance().getStats(item.getID()).getString("pathToModel"))); itemEquip.transform.SetParent(origins[index].transform); itemEquip.transform.localScale = Vector3.one; itemEquip.transform.localPosition = Vector3.zero; itemEquip.transform.localRotation = Quaternion.identity; }
public static void setClothes(Item item, GameObject[] origins) { int index = 1; Debug.Log(item.getID()); if (item.getID().isItemType(e_itemTypes.BODY)) { index = 0; } Transform trans = origins[index].GetComponent <Transform>(); GameObject tempItem = Instantiate(ResourceStructure.getGameObjectFromPath(ItemDataProvider.getInstance().getStats(item.getID()).getString("pathToModel"))); origins[index].GetComponent <SkinnedMeshRenderer>().sharedMesh = tempItem.GetComponent <SkinnedMeshRenderer>().sharedMesh; origins[index].GetComponent <SkinnedMeshRenderer>().sharedMaterial = tempItem.GetComponent <SkinnedMeshRenderer>().sharedMaterial; Destroy(tempItem); }
public ItemVariables useItem(Item item) { //hämtar items variablar. ItemVariables pot = ItemDataProvider.getInstance().getStats(item.getID()); //kollar om det är en use så den läser in rätt variablar if (item.getID().isItemType(e_itemTypes.USE)) { //ökar hpet på spelare och manan. this.getPlayerStats().health = Mathf.Min(this.getPlayerStats().health + pot.getInt("health"), getPlayerStats().maxHealth); this.getPlayerStats().mana = Mathf.Min(this.getPlayerStats().mana + pot.getInt("mana"), getPlayerStats().maxMana); //gör så att mängden minskar med 1. item.setQuantity(item.getQuantity() - 1); } return(pot); }
private InventoryInformationString displayInfo() { int itemID = item.getID(); ItemVariables info = ItemDataProvider.getInstance().getStats(item.getID()); InventoryInformationString data = new InventoryInformationString(); data.setName(info.getString("name")); data.setDescription(info.getString("description")); if (itemID.isItemType(e_itemTypes.EQUIP)) { data.setString("Stats \n Watt: " + item.getDamage() + " \n Matt: " + item.getMagicAttack() + " \n Luk: " + item.getLuk() + ""); } else { data.addInformation(info); } return(data); }
public void setEquipCloth(Equip equip) { int index = (equip.getID() / Tools.ITEM_INTERVAL) - 2; Equip item; //equips[index]; GameObject itemEquip = Instantiate(Resources.Load <GameObject>(ItemDataProvider.getInstance().getStats(equip.getID()).getString("pathToModel"))); GameObject slot = player.getSkinSlot(equip); slot.GetComponent <SkinnedMeshRenderer>().sharedMesh = itemEquip.GetComponent <SkinnedMeshRenderer>().sharedMesh; slot.GetComponent <SkinnedMeshRenderer>().sharedMaterial = itemEquip.GetComponent <SkinnedMeshRenderer>().sharedMaterial; player.updateSkinSlot(equip, slot); Destroy(itemEquip); if ((item = equips[index]) != null) { item.setPosition(equip.getPosition()); player.getInventory().addItem(item); } equips[index] = equip; player.getNetwork().equipItem(equip); updateSlots(); }
public void equipWeapon(int itemID) { int index = getIndex("Weapon"); if (equips[index].transform.childCount == 1) { Destroy(equips[index].transform.GetChild(0).gameObject); } GameObject weapon = (GameObject)Instantiate(ResourceStructure.getGameObjectFromPath(ItemDataProvider.getInstance().getStats(itemID).getString("pathToModel"))); weapon.transform.SetParent(equips[index].transform); weapon.transform.localPosition = Vector3.zero; weapon.transform.localScale = Vector3.one; weapon.transform.localRotation = Quaternion.identity; }
public static Sprite getSprite(this int itemID) { ItemVariables vars = ItemDataProvider.getInstance().getStats(itemID); return((Sprite)sprites[vars.getInt("imageIndex")]); }
public Item(int id) { this.id = id; this.name = ItemDataProvider.getInstance().getStats(id).getString("name"); }