示例#1
0
    // 알임 뷰를 표시하는 static 메서드
    public static AlertViewController2 Show(
        string title, string message, AlertViewOptions2 options = null)
    {
        if (prefab == null)
        {
            // 프리팹을 읽어 들인다.
            prefab = Resources.Load("AlertView2") as GameObject;
        }

        GameObject           go        = Instantiate(prefab) as GameObject;
        AlertViewController2 alertView = go.GetComponent <AlertViewController2>();

        alertView.UpadateContent(title, message, options);

        return(alertView);
    }
示例#2
0
    // 읽어 들인 내용을 갱신하는 메서드
    public void UpadateContent(
        string title, string message, AlertViewOptions2 options = null)
    {
        if (options != null)
        {
            // 표시 옵션이 있을 때 옵션의 내용에 맞춰 버튼을 표시하거나 표시하지 않는다.
            cancelButton.transform.gameObject.SetActive(options.cancelButtonTitle != null);

            cancelButton.gameObject.SetActive(options.cancelButtonTitle != null);
            cancelButtonDelegate = options.cancelButtonDelegate;

            combinationButtonDelegate   = options.combinationButtonDelegate;
            decombinationButtonDelegate = options.decombinationButtonDelegate;

            combinationController = options.CombinationController;

            itemType = options.itemType;

            message += "아이템은";

            if (options.itemType == ItemType.Material)
            {
                combinatinoButton.interactable   = false;
                decombinationButton.interactable = false;

                message += " 조합 및 분해가 불가능한 아이템입니다. \n";
            }
            else
            {
                if (combinationController.getRecipe().checkRecipe(combinationController.selectedItemId))
                {
                    bool f1 = combinationController.checkCombination();
                    bool f2 = combinationController.checkDecombination();

                    if (f1 && f2)
                    {
                        message += " 조합 및 분해가 가능한 아이텝입니다. \n";
                    }

                    else if (!f1 && f2)
                    {
                        //combinatinoButton.interactable = false;
                        isFinishable = false;
                        combinatinoButton.interactable = true;
                        message += "재료의 수량이 부족하여 조합은 하지 못하지만 분해는 가능합니다.";
                    }
                    else if (f1 && !f2)
                    {
                        decombinationButton.interactable = false;
                        message += "수량이 1개 이하이기 때문에 분해는 못하지만 조합은 가능합니다.";
                    }
                    else
                    {
                        message += " 재료의 수량이 부족하거나 아이템의 개수가 1개 이하이기 때문에 조합 및 분해가 불가능합니다. \n";
                        //combinatinoButton.interactable = false;
                        isFinishable = false;
                        combinatinoButton.interactable   = true;
                        decombinationButton.interactable = false;
                    }

                    //if (!f1)
                    //{
                    //    combinatinoButton.interactable = false;
                    //    message += " 재료의 수량이 부족합니다. \n";
                    //}

                    //if (!f2)
                    //{
                    //    decombinationButton.interactable = false;
                    //    message += " 수량이 1개 이하이면 분해할 수 없습니다. \n";
                    //}
                }
                else
                {
                    message += " 조합 및 분해가 불가능한 아이템입니다. \n";
                    combinatinoButton.interactable   = false;
                    decombinationButton.interactable = false;
                }
            }
        }
        // options = null인 경우
        else
        {
            // 표시 옵션이 지정된 경우 기본 버튼을 표시한다.
            cancelButton.gameObject.SetActive(true);
            combinatinoButton.interactable   = false;
            decombinationButton.interactable = false;
        }

        //타이틀과 메시지를 설정
        titleLabel.text   = title;
        messageLabel.text = message.Replace("\\n", "\n");
    }