void ItemDrop() { if (_ItemCount == 0) { int _RandNum = Random.Range(0, 3); //노말등급 초기화 if (_RandNum >= 0 && _RandNum < 3) { GameObject _DropNode = null; _DropNode = (GameObject)Instantiate(Resources.Load("Prefabs/Item/DropNode")); _DropNode.transform.position = this.transform.position; Item _ItemValue = cDataBaseManager.GetInstance._ItemList[_RandNum]; ItemDrop a_RefItemInfo = _DropNode.GetComponent <ItemDrop>(); if (a_RefItemInfo != null) { a_RefItemInfo.SetItem(_ItemValue); if (_ItemValue._Type == ItemType.Spear || _ItemValue._Type == ItemType.Sword) { a_RefItemInfo.transform.Rotate(new Vector3(0, 0, 90)); } else { a_RefItemInfo._ButtonF.transform.rotation = Quaternion.identity; } } // 동적으로 텍스쳐 이미지 바꾸기 SpriteRenderer a_RefRender = _DropNode.GetComponent <SpriteRenderer>(); a_RefRender.sprite = _ItemValue._ItemIcon; } _ItemCount += 1; _isOpen = true; _ButtonF.SetActive(false); _Renderer.sprite = Resources.Load <Sprite>("Itemp/BasicTresureOpened"); } }
//아이템 드랍 void ItemDrop() { int _RandNum = Random.Range(0, 6); // 0 ~ 6 랜덤값 초기화 if (_RandNum >= 0 && _RandNum < 6) { GameObject _DropNode = null; _DropNode = (GameObject)Instantiate(Resources.Load("Prefabs/Item/DropNode")); _DropNode.transform.position = this.transform.position; Item _ItemValue = cDataBaseManager.GetInstance._ItemList[_RandNum]; ItemDrop a_RefItemInfo = _DropNode.GetComponent <ItemDrop>(); if (a_RefItemInfo != null) { a_RefItemInfo.SetItem(_ItemValue); a_RefItemInfo.transform.Rotate(new Vector3(0, 0, 90)); //a_RefItemInfo.StartItem(); } // 동적으로 텍스쳐 이미지 바꾸기 SpriteRenderer a_RefRender = _DropNode.GetComponent <SpriteRenderer>(); a_RefRender.sprite = _ItemValue._ItemIcon; _ItemCount = 1; } }
private void CreateItemDrop(ItemRef item) { Vector3 position = lootSpawnPosition.position + Random.insideUnitSphere; position.y = lootSpawnPosition.position.y; GameObject itemDropObject = Instantiate <GameObject>(itemDropPrefab.gameObject, position, Quaternion.identity); ItemDrop itemDrop = itemDropObject.GetComponent <ItemDrop>(); itemDrop.SetItem(item); ForceRigidbody forceRigidbody = itemDropObject.GetComponent <ForceRigidbody>(); if (forceRigidbody) { Vector3 forward = position - transform.position; forceRigidbody.ApplyForce(forward.normalized); } }