public void FunctionOnPointerClick(BaseEventData Basedata) { PointerEventData data = ( PointerEventData )Basedata; if (data.clickCount == 2 && character.Attacking == false && terrain.canvas.GetComponentInChildren <MainGUI>().timeElapsedProgressBar <= Time.time) { if (CurrentPointerButtonIndex >= 0 && CurrentPointerButtonIndex <= 24) { characterInventory.CurrentInventoryItemSlot = CurrentPointerButtonIndex; } for (int i = 0; i < characterInventory.InventoryManage.Count; i++) { if (characterInventory.InventoryManage[i].CurrentInventorySlot == characterInventory.CurrentInventoryItemSlot && characterInventory.InventoryManage[i].isASecondary == 0 && characterInventory.CurrentInventoryItemSlot == WepSwitch.CurrentWeaponItemSlot) // for weapons that are primary - clicking an already equipped item { CurrentPointerButtonIndex = 100; characterInventory.InventoryButtonRects[WepSwitch.CurrentWeaponItemSlot].transform.GetComponentInChildren <Image>().color = new Color(1, 1, 1, 0.66f); WepSwitch.DestroyObject(WepSwitch.CurrentObject, 0); if (WepSwitch.CurrentProjectileObject != null) { WepSwitch.DestroyObject(WepSwitch.CurrentProjectileObject, 1); } character.SendFloats("ArmJump", 0); return; } else if (characterInventory.InventoryManage[i].CurrentInventorySlot == characterInventory.CurrentInventoryItemSlot && (characterInventory.CurrentInventoryItemSlot == armorSwitch.CurrentChestplateIteration || characterInventory.CurrentInventoryItemSlot == armorSwitch.CurrentHelmetIteration || characterInventory.CurrentInventoryItemSlot == armorSwitch.CurrentLegsIteration)) // for armors - clicking an already equipped item { CurrentPointerButtonIndex = 100; characterInventory.InventoryButtonRects[characterInventory.CurrentInventoryItemSlot].transform.GetComponentInChildren <Image>().color = new Color(1, 1, 1, 0.66f); armorSwitch.DropObject(characterInventory.CurrentInventoryItemSlot); // unequip return; } } for (int x = 0; x < Potions.PotionList.Count; x++) { if (Potions.PotionList[x].PotionName == characterInventory.InventoryButtonRects[characterInventory.CurrentInventoryItemSlot].GetComponentInChildren <Text>().text) { skillbarGUI.UsePotions(Potions.PotionList[x].PotionName); return; } } characterInventory.SetWeaponValues(); characterInventory.SetArmorValues(); characterInventory.SetToolValues(); if (UpgradeItems.CurrentUpgradeIndex == characterInventory.CurrentInventoryItemSlot) // update upgrade icons when equipping an item { UpgradeItems.PreviousUpgradedIcon.transform.GetComponentInChildren <Image>().sprite = characterInventory.DefaultSprite; UpgradeItems.PreviousUpgradedIcon.transform.GetComponentInChildren <Mask>().showMaskGraphic = true; UpgradeItems.AfterUpgradedIcon.transform.GetComponentInChildren <Image>().sprite = characterInventory.DefaultSprite; UpgradeItems.AfterUpgradedIcon.transform.GetComponentInChildren <Mask>().showMaskGraphic = true; } } }
public void dropitem(GameObject PreviousButtonLocation) { for (int i = 0; i < InventoryManage.Count; i++) // misc and pots { if (InventoryManage[i].CurrentInventorySlot == int.Parse(PreviousButtonLocation.name) && InventoryManage[i].isASecondary == 1) { Image DropAmountImageRef = Instantiate(DropAmountImage, new Vector2(0, 0), transform.rotation) as Image; DropAmountImageRef.transform.SetParent(terrain.canvas.transform); DropAmountImageRef.transform.localScale = new Vector3(1, 1, 1); DropAmountImageRef.GetComponent <RectTransform>().localPosition = new Vector2(0, 0); DropAmountImageRef.transform.Find("Image").Find("ImageSprite").GetComponent <Image>().sprite = InventoryManage[i].tSprite; DropAmountImageRef.GetComponentInChildren <Button>().onClick.AddListener(() => DropStackAmounts(DropAmountImageRef, PreviousButtonLocation)); } else if (InventoryManage[i].CurrentInventorySlot == int.Parse(PreviousButtonLocation.name) && InventoryManage[i].isASecondary == 0) // for weapons/armors that are primary { if (InventoryManage[i].CurrentInventorySlot == SwitchWeapons.CurrentWeaponItemSlot) { InventoryButtonRects[SwitchWeapons.CurrentWeaponItemSlot].transform.GetComponent <Image>().color = new Color(1, 1, 1, 0.66f); SwitchWeapons.DropObject(InventoryManage[i].CurrentInventorySlot); SwitchWeapons.DestroyObject(SwitchWeapons.CurrentProjectileObject, 1); } else if (InventoryManage[i].CurrentInventorySlot == SwitchArmor.CurrentChestplateIteration || InventoryManage[i].CurrentInventorySlot == SwitchArmor.CurrentHelmetIteration || InventoryManage[i].CurrentInventorySlot == SwitchArmor.CurrentLegsIteration) // armor { if (InventoryManage[i].CurrentInventorySlot == SwitchArmor.CurrentChestplateIteration) { InventoryButtonRects[SwitchArmor.CurrentChestplateIteration].transform.GetComponent <Image>().color = new Color(1, 1, 1, 0.66f); } else if (InventoryManage[i].CurrentInventorySlot == SwitchArmor.CurrentHelmetIteration) { InventoryButtonRects[SwitchArmor.CurrentHelmetIteration].transform.GetComponent <Image>().color = new Color(1, 1, 1, 0.66f); } else if (InventoryManage[i].CurrentInventorySlot == SwitchArmor.CurrentLegsIteration) { InventoryButtonRects[SwitchArmor.CurrentLegsIteration].transform.GetComponent <Image>().color = new Color(1, 1, 1, 0.66f); } SwitchArmor.DropObject(InventoryManage[i].CurrentInventorySlot); } GameObject Item = PhotonNetwork.Instantiate(InventoryManage[i].SlotName, terrain.Player.transform.position + new Vector3(0, 2, 0) + terrain.Player.transform.forward, terrain.Player.transform.rotation, 0) as GameObject; terrain.canvas.GetPhotonView().RPC("AddandRemoveDropList", PhotonTargets.AllBufferedViaServer, InventoryManage[i].SlotName, InventoryManage[i].Rarity, Item.GetPhotonView().viewID, InventoryManage[i].DamageOrValue, InventoryManage[i].WeaponAttackSpeed, InventoryManage[i].CritRate, InventoryManage[i].ArmorPenetration, InventoryManage[i].Defense, InventoryManage[i].Health, InventoryManage[i].Stamina, -1, 1, 0, 1, DroppedItemList.Count); if (Item.GetComponentInChildren <SkinnedMeshRenderer>()) { Item.GetComponentInChildren <SkinnedMeshRenderer>().material = new Material(Item.GetComponentInChildren <SkinnedMeshRenderer>().material); // create new instance for material seperate from rocks/trees } else { Item.GetComponentInChildren <MeshRenderer>().material = new Material(Item.GetComponentInChildren <MeshRenderer>().material); // create new instance for material seperate from rocks/trees } Color color = Color.white; if (InventoryManage[i].Rarity == "Rare") { color = Color.blue; } if (InventoryManage[i].Rarity == "Epic") { color = Color.magenta; } if (InventoryManage[i].Rarity == "Unique") { color = Color.red; } if (InventoryManage[i].Rarity == "Legendary") { color = Color.green; } if (InventoryManage[i].Rarity == "Mythic") { color = Color.cyan; } SwitchArmor.gameObject.GetPhotonView().RPC("MultiplayerGlow", PhotonTargets.AllBufferedViaServer, Item.GetPhotonView().viewID, color.r, color.g, color.b); InventoryManage.RemoveAt(i); // remove from inventorymanage and add to droplist PreviousButtonLocation.transform.Find("ImageScript").GetComponent <Image>().sprite = DefaultSprite; PreviousButtonLocation.transform.GetComponentInChildren <Mask>().showMaskGraphic = false; } } }