Exemple #1
0
    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;
    }
Exemple #2
0
    public void SetOption(int goldCount, int topazCount, int rubyCount, int sapphireCount, int diamondCount)
    {
        GoldText.text     = goldCount.ToString();
        TopazText.text    = topazCount.ToString();
        RubyText.text     = rubyCount.ToString();
        SapphireText.text = sapphireCount.ToString();
        DiamondText.text  = diamondCount.ToString();

        GameManager.instance.goldCount     += goldCount;
        GameManager.instance.topazCount    += topazCount;
        GameManager.instance.rubyCount     += rubyCount;
        GameManager.instance.sapphireCount += sapphireCount;
        GameManager.instance.diamondCount  += diamondCount;

        if (cardLayout == null)
        {
            Debug.LogError("cardLayout이 없어 보상창에 추가카드를 표시할 수 없습니다.");
            return;
        }

        if (cardPrefabList.Count == 0)
        {
            Debug.LogError("추가로 제공할 카드가 없습니다.");
            return;
        }

        // 일단은 추가카드 선택은 랜덤으로 해뒀음 나중에 수정할 예정
        for (int i = 0; i < 3; i++)
        {
            int randomIndex = Random.Range(0, cardPrefabList.Count);

            ShowCard   additionalCard = cardPrefabList[randomIndex];
            CardPicker picker         = Instantiate(cardPicker);

            picker.SetOption(additionalCard, (cardpicker) => {
                if (!this.isSelected)
                {
                    GameManager.instance.AllCards.Add(new CardSet(additionalCard, 0));
                    cardpicker.image.sprite = null;
                    this.isSelected         = true;
                    GameDataHandler.SaveCards(GameManager.instance.AllCards);
                }
            });

            picker.transform.SetParent(cardLayout.transform);
        }
    }