// 아이템 종류에 따른 부모 객체 public RectTransform GetRectTr(ItemManager.ItemKind kinds) { RectTransform parentTr; parentTr = new RectTransform(); switch (kinds) { case ItemManager.ItemKind.LHand: parentTr = lHand; break; case ItemManager.ItemKind.RHand: parentTr = rHand; break; case ItemManager.ItemKind.Hat: parentTr = hat; break; case ItemManager.ItemKind.Body: parentTr = body; break; case ItemManager.ItemKind.Pants: parentTr = pants; break; case ItemManager.ItemKind.Belt: parentTr = belt; break; case ItemManager.ItemKind.Foot: parentTr = foot; break; case ItemManager.ItemKind.Glove: parentTr = glove; break; case ItemManager.ItemKind.LRing: parentTr = lRing; break; } return(parentTr); }
private IEnumerator RandItem(Vector3 pos) { ItemManager.ItemKind tempKind = (ItemManager.ItemKind)Random.Range(0, (int)ItemManager.ItemKind.ALL); if (tempKind == ItemManager.ItemKind.use) { DropItem dorps; //체력 포션 GameObject temp = Instantiate(hpPotionPF, pos, Quaternion.identity); dorps = temp.GetComponent <DropItem>(); dorps.isHpPotion = true; yield break; } ItemManager.Rarity tempRearity = (ItemManager.Rarity)Random.Range(0, (int)ItemManager.Rarity.ALL); GameObject tempPF = null; int tempLevel = MonkSkill._instance.Level; string tempName = null; float amplify = 0; //레벨은 현제 레벨보다 크거나 작거나 같도록 해야함 tempLevel = Random.Range(0, 2) > 0 ? tempLevel + 5 : tempLevel; //템 레벨은 5렙단위로 끊어지도록 tempLevel -= tempLevel % 5; //템 레벨의 최대치 70 tempLevel = tempLevel > 70 ? 70 : tempLevel; //아이템 등급에 따른 배율 + -10% ~ +10간의 랜덤한 스텟 switch (tempRearity) { case ItemManager.Rarity.normal: amplify = 1f + ((Random.Range(0, 21) - 10) / 100f); tempName = "커먼 "; break; case ItemManager.Rarity.magic: amplify = 1.1f + ((Random.Range(0, 21) - 10) / 100f); tempName = "언커먼 "; break; case ItemManager.Rarity.unique: amplify = 1.3f + ((Random.Range(0, 21) - 10) / 100f); tempName = "희귀 "; break; case ItemManager.Rarity.legendary: amplify = 1.5f + ((Random.Range(0, 21) - 10) / 100f); tempName = "전설 "; break; } switch (tempKind) { case ItemManager.ItemKind.LHand: case ItemManager.ItemKind.RHand: tempKind = ItemManager.ItemKind.LHand; //무기 생성 switch (Random.Range(0, 4)) { case 0: tempPF = weapon0; break; case 1: tempPF = weapon1; break; case 2: tempPF = weapon2; break; case 3: tempPF = weapon3; break; //case 4: // tempPF = weapon5; // break; } tempName += "한손 무기"; break; case ItemManager.ItemKind.Hat: tempPF = hatPF; tempName += "모자"; break; case ItemManager.ItemKind.Body: tempPF = bodyPF; tempName += "갑옷"; break; case ItemManager.ItemKind.Belt: tempPF = beltPF; tempName += "벨트"; break; case ItemManager.ItemKind.Pants: tempPF = pantsPF; tempName += "바지"; break; case ItemManager.ItemKind.Foot: tempPF = footPF; tempName += "신발"; break; case ItemManager.ItemKind.Glove: tempPF = glovePF; tempName += "장갑"; break; case ItemManager.ItemKind.LRing: tempPF = ringPF; tempName += "반지"; break; } DropItem drop = Instantiate(tempPF, pos + (Vector3.up * 2.0f), Quaternion.identity).GetComponent <DropItem>(); drop.needLevel = tempLevel; drop.rarity = tempRearity; if (tempKind == ItemManager.ItemKind.LHand) { drop.damage = Mathf.RoundToInt(tempLevel * 20 * amplify); } else { drop.defense = Mathf.RoundToInt(tempLevel * 10 * amplify); } drop.itemName = tempName; yield return(null); }