예제 #1
0
    public override void OnAwake(params object[] paraList)
    {
        m_MainPanel = GameObject.GetComponent <ChapterPanel>();


        AddButtonClickListener(m_MainPanel.back_Btn, OnClickBack);
    }
    /// <summary> StoryModePanel에서 사용해준다. 초기화 함수 최초 1회만 호출함. </summary>
    public void PopupInit(ChapterPanel panel)
    {
        CharInven = NetData.instance.GetUserInfo();
        Chapter   = panel;

        Transform infoTf = PopupObj[(int)POPUP_TYPE.STAGE_INFO].transform;

        EventDelegate.Set(infoTf.FindChild("BtnReady").GetComponent <UIButton>().onClick, delegate() {
            if (0 < CurrentData._StageLowData.DailyEntercount)
            {
                int clearCount = CurrentData._StageLowData.DailyEntercount - CurrentData.DailyClearCount;
                if (clearCount <= 0)//더이상 진행 불가능
                {
                    UIMgr.instance.AddErrorPopup((int)Sw.ErrorCode.ER_StageStartS_Daily_Time_Error);
                    return;
                }
            }


            UIMgr.OpenReadyPopup(GAME_MODE.SINGLE, UIMgr.GetUIBasePanel("UIPanel/ChapterPanel"), CurrentData.NeedEnerge, 0);
            DisablePopup();
        });

        EventDelegate.Set(infoTf.FindChild("BtnStart").GetComponent <UIButton>().onClick, delegate() {
            panel.GotoInGame();
        });

        EventDelegate.Set(transform.FindChild("StageInfoView/BtnClose").GetComponent <UIButton>().onClick, () => {
            OnClosePopup();
        });

        EventDelegate.Set(transform.FindChild("SweepPopup/BtnClose").GetComponent <UIButton>().onClick, () => {
            OnClosePopup();
        });

        EventDelegate.Set(BtnSweep.GetComponent <UIButton>().onClick, OnClickSweep);
        EventDelegate.Set(SweepCardToggle.onChange, OnToggleAutoFlop);

        DisablePopup();

        Transform sweepTf = PopupObj[(int)POPUP_TYPE.SWEEP].transform;

        EventDelegate.Set(sweepTf.FindChild("Info/BtnOneSweep").GetComponent <UIButton>().onClick, delegate() { OnClickBtnSweep(1); });
        EventDelegate.Set(sweepTf.FindChild("Info/BtnFiveSweep").GetComponent <UIButton>().onClick, delegate() { OnClickBtnSweep(5); });

        EventDelegate.Set(MoveStage[0].GetComponent <UIButton>().onClick, delegate() { OnClickMoveState(-1); });
        EventDelegate.Set(MoveStage[1].GetComponent <UIButton>().onClick, delegate() { OnClickMoveState(1); });

        Transform slotParentTf = infoTf.FindChild("Left/DropItem");

        InvenSlot = new InvenItemSlotObject[4];
        for (int i = 0; i < 4; i++)
        {
            GameObject go = UIHelper.CreateInvenSlot(slotParentTf.FindChild(string.Format("{0}", i)));
            InvenSlot[i] = go.GetComponent <InvenItemSlotObject>();
        }


        sweepTf.FindChild("Info/BtnOneSweep/label").GetComponent <UILabel>().text  = string.Format(_LowDataMgr.instance.GetStringCommon(297), 1);
        sweepTf.FindChild("Info/BtnFiveSweep/label").GetComponent <UILabel>().text = string.Format(_LowDataMgr.instance.GetStringCommon(297), 10);

        Transform[] root = new Transform[] {
            SweepItemPrefab.transform.FindChild("ItemRoot_0"),
            SweepItemPrefab.transform.FindChild("ItemRoot_1"),
            SweepItemPrefab.transform.FindChild("ItemRoot_2"),
            SweepItemPrefab.transform.FindChild("ItemRoot_3"),
            SweepItemPrefab.transform.FindChild("CardItemRoot_0"),
            SweepItemPrefab.transform.FindChild("CardItemRoot_1")
        };

        for (int i = 0; i < root.Length; i++)
        {
            GameObject go = Instantiate(InvenSlotPrefab) as GameObject;
            go.transform.parent        = root[i];
            go.transform.localScale    = Vector3.one;
            go.transform.localPosition = Vector3.zero;

            go.collider.enabled = false;
        }

        Transform scrollTf = transform.FindChild("SweepPopup/ScrollParent/Scroll");

        SweepPaging = ObjectPaging.CreatePagingPanel(scrollTf.gameObject, scrollTf.GetChild(0).gameObject, SweepItemPrefab, 1, 4, 4, 0, OnCallBackSweepSlot);
        SweepItemPrefab.SetActive(false);

        //StageActionPanel.clipOffset = new Vector2(ActionFromIdx, 0);
        StageActions            = transform.FindChild("StageInfoView").GetComponents <TweenScale>();
        StageActions[0].enabled = false;
        StageActions[1].enabled = false;

        SweepActions            = transform.FindChild("SweepPopup").GetComponents <TweenScale>();
        SweepActions[0].enabled = false;
        SweepActions[1].enabled = false;

        if (SceneManager.instance.testData.bQuestTestStart)
        {
            TempCoroutine.instance.FrameDelay(2.0f, () => {
                panel.GotoInGame();
            });
        }
    }