private void CreateIcons(sCraftSingleLayer layerData, GameObject layer) { // Add one to account for Back button int btnLength = layerData.buttonsInfo.Length; GameObject[] newIconButtons = new GameObject[btnLength]; //float angle = 360f / (float)btnLength; for (int i = 0; i < btnLength; i++) { // Reverse the indices int btnIndex = btnLength - 1 - i; Vector3 iconPosition; Quaternion iconRotation; CraftWheelUtils.GetCraftBtnPosition(btnLength, i, iconRotations[0], menuCenterPos, iconDistributionRadius, out iconPosition, out iconRotation); Vector3 btnPosition; Quaternion btnRotation; CraftWheelUtils.GetCraftBtnPosition(btnLength, i, iconRotations[1], menuCenterPos, iconDistributionRadius, out btnPosition, out btnRotation); Image separator = Instantiate(separatorIcon, iconPosition, iconRotation *= iconLocalRotOffset); separator.name = "MenuSeparatorIcon"; separator.transform.SetParent(layer.transform, false); GameObject curIcon = new GameObject(layerData.buttonsInfo[btnIndex].name + "Icon", typeof(Image)); MenuCreateButton curMBC = curIcon.AddComponent <MenuCreateButton>(); curMBC.SetInfo(layerData.buttonsInfo[btnIndex].name, layerData.buttonsInfo[btnIndex].icon); layerData.buttonsInfo[btnIndex].associatedButton = curIcon; curIcon.transform.position = btnPosition; curIcon.transform.SetParent(layer.transform, false); } }
/// <summary> /// /// </summary> /// <param name="buttonsInfo"></param> /// <param name="newLayer"></param> private void SetupLayerIcons(sButtonsInfo buttonsInfo, GameObject newLayer) { int btnAmt = GetAmtOfMaterials(buttonsInfo.itemIfCraftType.craftMaterialInfo); iconRotations = CraftWheelUtils.SetIconOffsets(btnAmt + 1); CreateIcons(btnAmt, buttonsInfo, newLayer); }
void Update() { if (!isCraftMenuOpen) { // Always set the selection angle based on angle from center (0,0) while open selectionAngle = craftMenuMainLayer.GetAngleFromCenter(); int btnIndexToSelect = CraftWheelUtils.GetHighlightedButton(amountOfIcons, selectionAngle); SetSelectedIconIndex(btnIndexToSelect); } }
/// <summary> /// /// </summary> void Update() { // Always set the selection angle based on angle from center (0,0) while open selectionAngle = craftMenuMainLayer.GetAngleFromCenter(); int btnIndexToSelect = CraftWheelUtils.GetHighlightedButton(amountOfIcons, selectionAngle); SetSelectedIconIndex(btnIndexToSelect); if (Input.GetKeyDown(KeyCode.E) && canCraft) { print("Crafted " + itemToCreate.itemName); try { Inventory.Instance.InsertItem(new ItemInstance(itemToCreate)); print("ITEMS Index: " + item1FoundIndex + " - " + item2FoundIndex + " - " + item3FoundIndex); List <int> items = ReverseOrder(item1FoundIndex, item2FoundIndex, item3FoundIndex); items.ForEach(item => { try{ Inventory.Instance.RemoveItem(item); }catch { print("couldnt remove item"); } }); print("ITEMTOCREATE: " + itemToCreate.itemName); try{ textInfoPopup.PlayItemCreatedInfoText(itemToCreate.itemName); }catch { print("popup didn't work!"); } }catch { print("[CraftMenuCraftLayer] - Something Went wrong"); } SetMaterialsNeededInfo(); } if (Input.GetKeyDown(KeyCode.L)) { textInfoPopup.PlayItemCreatedInfoText("Something"); } }
private void SetupLayerIcons(sCraftSingleLayer foundLayerData, GameObject newLayer) { iconRotations = CraftWheelUtils.SetIconOffsets(foundLayerData.buttonsInfo.Length); CreateIcons(foundLayerData, newLayer); }
/// <summary> /// /// </summary> /// <param name="btnAmt"></param> /// <param name="buttonsInfo"></param> /// <param name="layer"></param> private void CreateIcons(int btnAmt, sButtonsInfo buttonsInfo, GameObject layer) { // Add one to account for Back button int btnLength = btnAmt + 1; GameObject[] newIconButtons = new GameObject[btnLength]; for (int i = 0; i < btnLength; i++) { // Reverse the indices int btnIndex = btnLength - 1 - i; Vector3 iconPosition; Quaternion iconRotation; CraftWheelUtils.GetCraftBtnPosition(btnLength, btnIndex, iconRotations[0], menuCenterPos, iconDistributionRadius, out iconPosition, out iconRotation); Vector3 btnPosition; Quaternion btnRotation; CraftWheelUtils.GetCraftBtnPosition(btnLength, btnIndex, iconRotations[1], menuCenterPos, iconDistributionRadius, out btnPosition, out btnRotation); Image separator = Instantiate(separatorIcon, iconPosition, iconRotation *= iconLocalRotOffset); separator.name = "MenuSeparatorIcon"; separator.transform.SetParent(layer.transform, false); GameObject tmpIcon = new GameObject("tmpIcon", typeof(Image)); // GameObject curIcon; // MenuCreateButton curMBC; Item tmpMaterial; switch (i) { case 0: tmpIcon.GetComponent <Image>().sprite = backIcon; tmpIcon.name = "BackIcon"; tmpIcon.transform.position = btnPosition; tmpIcon.transform.SetParent(layer.transform, false); backButton = tmpIcon; break; case 1: tmpMaterial = buttonsInfo.itemIfCraftType.craftMaterialInfo.firstMaterial; tmpIcon.GetComponent <Image>().sprite = tmpMaterial.icon; tmpIcon.name = tmpMaterial.itemName; tmpIcon.transform.position = btnPosition; tmpIcon.transform.SetParent(layer.transform, false); break; case 2: tmpMaterial = buttonsInfo.itemIfCraftType.craftMaterialInfo.secondMaterial; tmpIcon.GetComponent <Image>().sprite = tmpMaterial.icon; tmpIcon.name = tmpMaterial.itemName; tmpIcon.transform.position = btnPosition; tmpIcon.transform.SetParent(layer.transform, false); break; case 3: tmpMaterial = buttonsInfo.itemIfCraftType.craftMaterialInfo.thirdMaterial; tmpIcon.GetComponent <Image>().sprite = tmpMaterial.icon; tmpIcon.name = tmpMaterial.itemName; tmpIcon.transform.position = btnPosition; tmpIcon.transform.SetParent(layer.transform, false); break; } } }