void Awake() { upParticle = Resources.Load("Upgrade Particle System") as GameObject; int cardCount = GameManager.instance.AllCards.Count; for (int i = 0; i < cardCount; i++) { CardSet cardSet = GameManager.instance.AllCards[i]; if (cardSet.upgradeLevel > 4) { continue; } CardPicker picker = Instantiate(pickerPrefab); picker.transform.SetParent(layoutGroup.transform); picker.SetOption(cardSet.showCard, (cardPicker) => { WindowUI win = Instantiate(MainUIMnager.Instance.window); win.GetComponent <ChooseWindowUI>().SetWindow("카드 강화", "계속 하시겠습니까?\n\n" + string.Format("{0} -> {1}", cardSet.upgradeLevel, cardSet.upgradeLevel + 1), "네", "아니요", () => { int cost = cardSet.showCard.card.upgradeCostPerLevel; if (cardSet.showCard.card.upgradeCostPerLevel <= GameManager.instance.goldCount && cardSet.showCard.card.upgradeGemPerLevel <= GameManager.instance.GetGem(cardSet.showCard.card.type)) { GameManager.instance.AddGold(-cost); GameManager.instance.AddGem(cardSet.showCard.card.type, -cardSet.showCard.card.upgradeGemPerLevel); cardSet.upgradeLevel++; GameObject temp = Instantiate(upParticle, cardPicker.transform.position, Quaternion.identity); Destroy(temp, 3.0f); GameDataHandler.SaveCards(GameManager.instance.AllCards); Destroy(win.gameObject); if (cardSet.upgradeLevel > 4) { Destroy(picker.gameObject); } } else { Destroy(win.gameObject); win = Instantiate(MainUIMnager.Instance.window); win.GetComponent <ChooseWindowUI>().SetWindow("강화 실패", "재료가 부족합니다.", "확인", "취소", () => { }, () => Destroy(win.gameObject)); } }, () => Destroy(win.gameObject)); }); } Canvas cam = transform.GetChild(0).GetComponent <Canvas>(); cam.worldCamera = Camera.main; }
Vector3 GetWindowPosition(WindowUI window) { Vector3 position = Vector3.zero; WindowType windowType = window.GetWindowType(); BoxCollider2D collider = window.GetComponent <BoxCollider2D>(); Vector3 sizeOffset = new Vector3(-collider.size.x / 2, (collider.size.y / 2) + 2f, 0); int windowCount = GetWindowTypeCount(windowType); sizeOffset += new Vector3(NEW_WINDOW_OFFSET * (windowCount % 12), -NEW_WINDOW_OFFSET * ((windowCount % 12) + Mathf.Floor(windowCount / 12)), 0); switch (windowType) { case WindowType.OptionsBar: position = new Vector3(7.21875f, -5.875f - 0.75f, 0); break; case WindowType.InventoryWindow: position = new Vector3(7.03125f, 5.5f, 0); break; case WindowType.SpellsWindow: position = new Vector3(-8.21875f, 5.5f, 0); break; case WindowType.CommandBar: position = new Vector3(-5.5f, 7.5f + 0.75f, 0); break; case WindowType.BuffBar: position = new Vector3(-12.21875f, 7.5f + 0.75f, 0); break; case WindowType.FpsBar: position = new Vector3(10.65625f, 7.5f + 0.75f, 0); break; case WindowType.HealthBar: position = new Vector3(9.15625f, -2.75f, 0); break; case WindowType.ManaBar: position = new Vector3(9.15625f, -3.4375f, 0); break; case WindowType.SpiritBar: position = new Vector3(9.15625f, -4.125f, 0); break; case WindowType.ExperienceBar: position = new Vector3(9.15625f, -4.8125f, 0); break; case WindowType.CharacterWindow: position = new Vector3(-5.53125f, 6, 0); break; case WindowType.ChatWindow: position = new Vector3(-12.21875f, -2.5f - 0.75f, 0); break; case WindowType.VendorWindow: position = sizeOffset; break; case WindowType.PartyWindow: position = new Vector3(0.09375f, -1.1875f - 0.75f, 0); break; case WindowType.Combine2: position = sizeOffset; break; case WindowType.Combine4: position = sizeOffset; break; case WindowType.Combine6: position = sizeOffset; break; case WindowType.Combine8: position = sizeOffset; break; case WindowType.Combine10: position = sizeOffset; break; case WindowType.QuestWindow: position = sizeOffset; break; case WindowType.LargeQuestWindow: position = sizeOffset; break; case WindowType.TextWindow: position = sizeOffset; break; case WindowType.DiscardButton: position = new Vector3(4.65625f, -5.71875f - 0.75f, 0); break; case WindowType.LetterWindow: position = sizeOffset; break; case WindowType.TradeWindow: position = sizeOffset; break; } return(position); }