public void MouseDrop() // スロットの上にアイテムがドロップされた時に実行 { if (FindObjectOfType <DragSlot>() == null || panelParam) { return; } foreach (Transform child in customslot_c) { child.gameObject.transform.GetComponent <CustomSlot>().BatsuEnd(); } AudioManager.Instance.PlaySE("closing-wooden-door-1"); transform.GetChild(0).GetComponent <Image>().sprite = null; myItemData = null; dragSlot = FindObjectOfType <DragSlot>(); // DragItemUIに設定しているDragItemDataスクリプトからアイテムデータを取得 myItemData = dragSlot.GetItem(); int id = myItemData.GetItemId(); if (id > 2 && panelParam == false) { itemSlot = dragSlot.GetSlotData(); //ドラッグしてきた持ち物パネルを取得持ち物 //Debug.Log(itemSlot); ShowInformation(); //カスタムパネルに装備 panelParam = true; pocketStatus.SetItemData(myItemData, slotNum); switch (dragSlot.GetDeleteNum()) { case 1: myItemStatus.SetItemCount(id, -1); ProcessingSlot processingSlot = itemSlot.GetComponent <ProcessingSlot>(); StartCoroutine(processingSlot.displayCount()); if (myItemStatus.GetItemCount(id) <= 0) { myItemStatus.SetItemFlag(id, false); itemSlot.GetComponent <ProcessingSlot>().PanelDelete(); } break; case 3: itemSlot.GetComponent <PocketItem>().PanelDelete(); break; default: break; } } dragSlot.DeleteDragItem(); // ドラッグしているアイテムデータの削除 //pocketStatus.SetItemData(myItemData, slotNum); }
public IEnumerator displayCount() { myItemStatus = gameObject.transform.root.GetComponent <PlayerUIController>().GetMyItemStatus(); countText = transform.Find("Count").GetChild(0).GetComponent <Text>(); if (myItemStatus.GetItemCount(myItemData.GetItemId()) > 1) { transform.Find("Count").gameObject.SetActive(true); countText.text = "×" + myItemStatus.GetItemCount(myItemData.GetItemId()).ToString(); } else if (myItemStatus.GetItemCount(myItemData.GetItemId()) <= 1) { transform.Find("Count").gameObject.SetActive(false); } yield break; }
public void CreateSlot(ItemData[] itemLists) { switch (callNum) { case 0: foreach (var item in itemLists) { if (myItemStatus.GetItemFlag(item.GetItemType())) { var instanceSlot = Instantiate(slot) as GameObject; instanceSlot.name = item.GetItemName(); instanceSlot.transform.SetParent(transform); instanceSlot.transform.localScale = new Vector3(1f, 1f, 1f); instanceSlot.GetComponent <ProcessingSlot>().SetItemData(item); } } break; case 1: if (myItemStatus.GetItemCount(myItemData.GetItemId()) <= 1) { var instanceSlot = Instantiate(slot) as GameObject; instanceSlot.name = myItemData.GetItemName(); instanceSlot.transform.SetParent(transform); instanceSlot.transform.localScale = new Vector3(1f, 1f, 1f); var display = instanceSlot.GetComponent <ProcessingSlot>(); display.SetItemData(myItemData); } var itemSlot = transform.Find(myItemData.GetItemName()).GetComponent <ProcessingSlot>(); StartCoroutine(itemSlot.displayCount()); break; default: break; } }
public void MouseDrop() // スロットの上にアイテムがドロップされた時に実行 { if (FindObjectOfType <DragSlot>() == null || panelParam) { return; } foreach (Transform child in itemslot_c) { child.gameObject.transform.GetComponent <PocketItem>().BatsuEnd(); } AudioManager.Instance.PlaySE("closing-wooden-door-1"); dragSlot = FindObjectOfType <DragSlot>(); // DragItemUIに設定しているDragItemDataスクリプトからアイテムデータを取得 myItemData = dragSlot.GetItem(); id = myItemData.GetItemId(); dataName = dragSlot.GetSlotData(); //ドラッグしてきた持ち物パネルを取得 switch (panelParam) { case false: if (myItemData.GetItemSet() == PocketStatus.Pocket.none) { switch (id) { default: case 0: plusPower = myItemData.GetItemPower(); break; case 1: plusPower = myItemData.GetItemSpeed(); break; case 2: plusPower = myItemData.GetItemDefence(); break; } wm.AttachParts(plusPower, id); ShowInformation(); panelParam = true; } break; default: dataName = null; break; } if (myItemData.GetItemSet() != PocketStatus.Pocket.none) { return; } switch (dragSlot.GetDeleteNum()) { case 1: myItemStatus.SetItemCount(id, -1); var processingSlot = dataName.GetComponent <ProcessingSlot>(); processingSlot.StartCoroutine("displayCount"); if (myItemStatus.GetItemCount(id) <= 0) { myItemStatus.SetItemFlag(id, false); processingSlot.PanelDelete(); } break; case 2: dataName.GetComponent <CustomSlot>().PanelDelete(); break; case 3: break; default: break; } dragSlot.DeleteDragItem(); // ドラッグしているアイテムデータの削除 }
public void DropDragItem() //捨てるアイテムのアイテムデータ取得 { if (FindObjectOfType <DragSlot>() == null) { return; } var dragSlot = FindObjectOfType <DragSlot>(); //アイテムがドロップされた時に、どのようなアイテムかを取得 myItemData = dragSlot.GetItem(); var id = myItemData.GetItemId(); if (dragSlot.GetSlotData() != null) { deleteSlot = dragSlot.GetSlotData(); } // Vector3 p_pos = GameObject.Find("Sphere").transform.position; // Vector3 p_pos = new Vector3 // ( // myPlayer.transform.position.x, // myPlayer.transform.position.y + 1.0f, // myPlayer.transform.position.z + 0.8f // ); switch (dragSlot.GetDeleteNum()) { case 1: myItemStatus.SetItemCount(id, -1); var processingSlot = deleteSlot.GetComponent <ProcessingSlot>(); processingSlot.StartCoroutine("displayCount"); if (myItemStatus.GetItemCount(id) <= 0) { myItemStatus.SetItemFlag(id, false); deleteSlot.GetComponent <ProcessingSlot>().PanelDelete(); } break; case 2: myItemStatus.SetItemCount(id, 0); deleteSlot.GetComponent <CustomSlot>().PanelDelete(); break; case 3: myItemStatus.SetItemCount(id, 0); deleteSlot.GetComponent <PocketItem>().PanelDelete(); break; default: break; } // ドロップされたアイテムのタイプを取得し、プレイヤーの場所にオブジェクトを生成 itemSpawner.CallItemSpawn(this.gameObject, myPlayer.gameObject.transform.position, id); dragSlot.DeleteDragItem(); }