Пример #1
0
    public override void LateInit()
    {
        base.LateInit();

        GameMode  = (GAME_MODE)parameters[0];
        BasePanel = (UIBasePanel)parameters[1];
        int   energe = (int)parameters[2];
        int   max    = (int)parameters[3];
        float scale  = PartnerModelRoot[0].localScale.x;//파트너는 이값으로

        bool   isNetwork   = false;
        string startBtnLbl = null;

        switch (GameMode)
        {
        case GAME_MODE.SINGLE:
        {
            //모험모드일때만 체력표시되게해주세요
            UIMgr.instance.TopMenu.MenuType[3].transform.parent.gameObject.SetActive(true);
            startBtnLbl = string.Format("{0} ({1} {2})", _LowDataMgr.instance.GetStringCommon(66), energe, _LowDataMgr.instance.GetStringCommon(1));        //("시작"), ("에너지")
            break;
        }


        case GAME_MODE.SPECIAL_EXP:
        case GAME_MODE.SPECIAL_GOLD:
        case GAME_MODE.RAID:
        case GAME_MODE.TOWER:
            startBtnLbl = string.Format("{0}/{1} {2}", max - energe, max, _LowDataMgr.instance.GetStringCommon(66));
            break;

        case GAME_MODE.COLOSSEUM:
        case GAME_MODE.MULTI_RAID:
            isNetwork   = true;
            startBtnLbl = string.Format("{0}/{1} {2}", max - energe, max, _LowDataMgr.instance.GetStringCommon(66));
            scale       = 0.8f;//플레이어는 이값으로
            break;

        case GAME_MODE.ARENA:
            startBtnLbl = string.Format("{0}", _LowDataMgr.instance.GetStringCommon(1053));
            //transform.FindChild("BtnStartGame").collider.enabled = false;
            break;

        default:
            startBtnLbl = "unDefined 0";
            break;
        }

        NetInfoTf.gameObject.SetActive(isNetwork);
        transform.FindChild("Partner").gameObject.SetActive(!isNetwork);
        transform.FindChild("BtnStartGame").gameObject.SetActive(!isNetwork);//상황따라 꺼놓는다.

        PartnerModelRoot[0].localScale = new Vector3(scale, scale, scale);
        PartnerModelRoot[1].localScale = new Vector3(scale, scale, scale);

        IsRoom = isNetwork;
        if (isNetwork)
        {
            InitNetworkDungeon(startBtnLbl);
        }
        else
        {
            transform.FindChild("BtnStartGame/need_food").GetComponent <UILabel>().text = startBtnLbl;

            //캐릭터 닉네임, 레벨 셋팅
            string nickName = NetData.instance.Nickname;
            string lvStr    = string.Format(_LowDataMgr.instance.GetStringCommon(453), NetData.instance.UserLevel);
            transform.FindChild("Character/CharView/CharSlot/player_name").GetComponent <UILabel>().text =
                string.Format("{0} {1}", lvStr, nickName);

            //플레이어 생성
            NetData._CostumeData equipCostumeData = CharInven.GetEquipCostume();
            uint weaponId = 0, clothId = 0, headId = 0;
            if (CharInven.isHideCostum)
            {
                NetData._ItemData head   = CharInven.GetEquipParts(ePartType.HELMET);
                NetData._ItemData cloth  = CharInven.GetEquipParts(ePartType.CLOTH);
                NetData._ItemData weapon = CharInven.GetEquipParts(ePartType.WEAPON);

                if (head != null)
                {
                    headId = head._equipitemDataIndex;
                }

                if (cloth != null)
                {
                    clothId = cloth._equipitemDataIndex;
                }

                if (weapon != null)
                {
                    weaponId = weapon._equipitemDataIndex;
                }
            }

            UIHelper.CreatePcUIModel("ReadyPopup", PlayCharRoot, CharInven.GetCharIdx(), headId, equipCostumeData._costmeDataIndex, clothId, weaponId, CharInven.GetEquipSKillSet().SkillSetId, 0, CharInven.isHideCostum, false);
        }

        if (GameMode != GAME_MODE.COLOSSEUM && GameMode != GAME_MODE.MULTI_RAID)//파트너못대려가는 지역.
        {
            Transform parBtnTf = transform.FindChild("Character/CharView");
            EventDelegate.Set(parBtnTf.FindChild("BtnPartnerSlot_0").GetComponent <UIEventTrigger>().onClick, delegate() { OnClickPartnerRoot(0); });
            EventDelegate.Set(parBtnTf.FindChild("BtnPartnerSlot_1").GetComponent <UIEventTrigger>().onClick, delegate() { OnClickPartnerRoot(1); });
            //CanNotTakePartner.SetActive(false);

            //슬롯 셋팅
            int ownCount = 0;
            List <NetData._PartnerData> dataList = CharInven.GetPartnerList();
            if (PartnerGrid.childCount < dataList.Count)
            {
                int loopCount = dataList.Count;
                for (int i = 0; i < loopCount; i++)
                {
                    Transform slotTf = null;
                    if (i < PartnerGrid.childCount)
                    {
                        slotTf = PartnerGrid.GetChild(i);
                    }
                    else
                    {
                        GameObject slotGo = Instantiate(PartnerSlotPrefab) as GameObject;
                        slotTf               = slotGo.transform;
                        slotTf.parent        = PartnerGrid;
                        slotTf.localPosition = Vector3.zero;
                        slotTf.localScale    = Vector3.one;
                    }

                    NetData._PartnerData data = dataList[i];
                    if (!data._isOwn)
                    {
                        slotTf.gameObject.SetActive(false);
                        continue;
                    }

                    slotTf.name = string.Format("{0}", data._partnerDataIndex);
                    ++ownCount;
                    slotTf.gameObject.SetActive(true);

                    UIButton uiBtn = slotTf.GetComponent <UIButton>();
                    EventDelegate.Set(uiBtn.onClick, delegate()
                    {
                        OnClickAddPartner(data);
                    });

                    UISprite faceIcon    = slotTf.FindChild("face_d3").GetComponent <UISprite>();
                    UISprite gradeIcon   = slotTf.FindChild("grade").GetComponent <UISprite>();
                    UISprite gradebgIcon = slotTf.FindChild("grade_bg").GetComponent <UISprite>();
                    UILabel  nameLbl     = slotTf.FindChild("partner_name_d4").GetComponent <UILabel>();
                    nameLbl.text           = data.GetLocName();
                    faceIcon.spriteName    = data.GetIcon();
                    gradeIcon.spriteName   = string.Format("Icon_0{0}", data.CurQuality);
                    gradebgIcon.spriteName = string.Format("Icon_bg_0{0}", data.CurQuality);

                    if (!data._isEquip)//장착중이 아니면
                    {
                        slotTf.FindChild("face_d3").GetComponent <UISprite>().color = Color.white;
                        continue;
                    }

                    //장착중인 것 셋팅
                    //등록한 파트너 슬롯 딤처리
                    slotTf.FindChild("face_d3").GetComponent <UISprite>().color = Color.gray;
                    PnRootInfo[data._SlotNumber - 1].SetModel(data._partnerDataIndex);
                }

                UIScrollView scroll = PartnerGrid.parent.GetComponent <UIScrollView>();
                if (4 < ownCount)
                {
                    scroll.enabled = true;
                }
                else
                {
                    if (ownCount <= 0)
                    {
                        NotPartner.SetActive(true);
                    }
                    else
                    {
                        NotPartner.SetActive(false);
                    }

                    scroll.enabled = false;
                }

                if (0 < ownCount)
                {
                    GameObject effGo_01 = UIHelper.CreateEffectInGame(PnTouchEff[0].transform, "Fx_UI_partner_select_01", false);
                    GameObject effGo_02 = UIHelper.CreateEffectInGame(PnTouchEff[1].transform, "Fx_UI_partner_select_01", false);
                    effGo_01.transform.localEulerAngles = Vector3.zero;
                    effGo_02.transform.localEulerAngles = Vector3.zero;

                    effGo_01.layer = LayerMask.NameToLayer("UI");
                    effGo_02.layer = LayerMask.NameToLayer("UI");
                    effGo_01.transform.SetChildLayer(LayerMask.NameToLayer("UI"));
                    effGo_02.transform.SetChildLayer(LayerMask.NameToLayer("UI"));

                    PnTouchEff[0].SetActive(true);
                    PnTouchEff[1].SetActive(false);
                }
            }

            //장착중인 파트너 생성
            NetData._PartnerData partner_0 = CharInven.GetEquipPartner(1);
            NetData._PartnerData partner_1 = CharInven.GetEquipPartner(2);
            if (partner_0 != null)
            {
                Transform modelRoot = PartnerModelRoot[0];
                PnTouchObj[0].SetActive(false);//터치 라벨 끈다.

                UIHelper.CreatePartnerUIModel(modelRoot, partner_0._partnerDataIndex, 3, true, false, "ReadyPopup");
                string lvStr = string.Format(_LowDataMgr.instance.GetStringCommon(453), partner_0._NowLevel);
                TakeParNames[0].text = string.Format("{0} {1}", lvStr, partner_0.GetLocName());
            }
            else if (0 < ownCount)
            {
                PnTouchObj[0].SetActive(true);//터치 라벨 킨다.
            }
            //else
            //{
            //    PnTouchObj[0].SetActive(true);//터치 라벨 킨다.
            //    TakeParNames[0].text = "";
            //}

            if (partner_1 != null)
            {
                Transform modelRoot = PartnerModelRoot[1];
                PnTouchObj[1].SetActive(false);//터치 라벨 끈다.

                UIHelper.CreatePartnerUIModel(modelRoot, partner_1._partnerDataIndex, 3, true, false, "ReadyPopup");
                string lvStr = string.Format(_LowDataMgr.instance.GetStringCommon(453), partner_1._NowLevel);
                TakeParNames[1].text = string.Format("{0} {1}", lvStr, partner_1.GetLocName());
            }
            else if (0 < ownCount)
            {
                PnTouchObj[1].SetActive(true);//터치 라벨 킨다.
            }
            //else
            //{
            //    PnTouchObj[1].SetActive(true);//터치 라벨 킨다.
            //    TakeParNames[1].text = "";
            //}
        }
        else
        {
            NotPartner.SetActive(false);
        }
    }
    /// <summary>
    /// Partner를 셋팅 및 보여준다.
    /// </summary>
    /// <param name="type">PartnerType으로 타입에 맞게 보여줌</param>
    int OnTabPartnerList(int typeIdx)
    {
        PartnerClassType type = (PartnerClassType)typeIdx;
        int gridSlotCount     = 0;

        bool isTuto = SceneManager.instance.CurTutorial == TutorialType.PARTNER;
        List <NetData._PartnerData> dataList = CharInven.GetPartnerList();
        int loopCount = dataList.Count;

        for (int i = 0; i < loopCount; i++)
        {
            ListGridTf.GetChild(i).gameObject.SetActive(false);

            NetData._PartnerData    data = dataList[i];
            Partner.PartnerDataInfo info = data.GetLowData();
            if (type != PartnerClassType.None && (PartnerClassType)info.Class != type)
            {
                continue;
            }

            Transform slotTf = ListGridTf.GetChild(gridSlotCount);
            slotTf.gameObject.SetActive(true);


            slotTf.FindChild("Mark").GetComponent <UISprite>().spriteName = data.GetClassType();
            //보유조각수
            slotTf.FindChild("Txt_count").GetComponent <UILabel>().text = string.Format(_LowDataMgr.instance.GetStringCommon(1154), data.NowShard, data._needShard);


            UISprite face = slotTf.FindChild("Itemroot/face").GetComponent <UISprite>();
            UISprite bg   = slotTf.FindChild("Itemroot/gradebg").GetComponent <UISprite>();
            face.spriteName = data.GetIcon();
            slotTf.FindChild("Txt_name").GetComponent <UILabel>().text = data.GetLocName();

            UILabel level = slotTf.FindChild("Txt_class").GetComponent <UILabel>();

            //등급은 색상도 고려해줘..
            UILabel gradeLabel = slotTf.FindChild("Txt_type").GetComponent <UILabel>();

            slotTf.FindChild("Itemroot/grade").GetComponent <UISprite>().spriteName = string.Format("Icon_0{0}", data.CurQuality);
            bg.spriteName = string.Format("Icon_bg_0{0}", data.CurQuality);

            Transform  btnGetTf    = slotTf.FindChild("Btn_Get");                 //소환버튼
            GameObject btnGetAfter = slotTf.FindChild("Btn_Getafter").gameObject; //보유중일때나옴
            btnGetAfter.SetActive(data._isOwn);
            btnGetTf.gameObject.SetActive(!data._isOwn);
            slotTf.FindChild("bg_on").gameObject.SetActive(data._isOwn);//배경

            if (data._isOwn)
            {
                EventDelegate.Set(btnGetAfter.GetComponent <UIEventTrigger>().onClick, delegate() {
                    UIMgr.instance.AddPopup(141, 1177, 117);    //보유중알림메시지
                });

                if (data._NowLevel >= data._MaxLevel)//최대렙
                {
                    level.text = string.Format(_LowDataMgr.instance.GetStringCommon(1152), data._NowLevel);
                }
                else
                {
                    level.text = string.Format(_LowDataMgr.instance.GetStringCommon(1151), data._NowLevel);
                }

                //색상도고려
                gradeLabel.text = string.Format("{0}{1}[-]", UIHelper.GetItemGradeColor((int)data.CurQuality), data.GetGradeName());
            }
            else
            {
                if (isTuto && type == PartnerClassType.Attack && data.NowShard >= data._needShard)
                {
                    isTuto = false;
                    TutorialSupport support = btnGetTf.gameObject.AddComponent <TutorialSupport>();
                    support.TutoType = TutorialType.PARTNER;
                    support.SortId   = 3;
                    support.IsScroll = true;

                    //support.NextTuto = OwnPartnerView.TabBtn[1].gameObject.GetComponent<TutorialSupport>();
                    support.OnTutoSupportStart();
                }

                btnGetTf.FindChild("Btn_on").gameObject.SetActive(data.NowShard >= data._needShard);
                btnGetTf.FindChild("Btn_off").gameObject.SetActive(data.NowShard < data._needShard);

                level.text      = "";
                gradeLabel.text = _LowDataMgr.instance.GetStringCommon(1155);                                                                   //없으면 미보유
                EventDelegate.Set(btnGetTf.GetComponent <UIEventTrigger>().onClick, delegate() { OnClickPartnerGet(data._partnerDataIndex); }); //소환
            }

            //슬롯 클릭시 실행할 함수 셋팅
            EventDelegate.Set(slotTf.GetComponent <UIEventTrigger>().onClick, delegate() {
                OnClickListSlot(data._partnerDataIndex);
            });

            ++gridSlotCount;
        }

        ListGridTf.GetComponent <UIGrid>().repositionNow = true;

        return(gridSlotCount);
    }