Beispiel #1
0
    private void DefenceItemClick(DefenceEctypeEnableItemBehaviour clickItem)
    {
        SoundManager.Instance.PlaySoundEffect("Sound_Button_DefenceLevelSelect");
        m_enableItems.ApplyAllItem(P => { if (P != null)
                                          {
                                              P.SetFocus(false);
                                          }
                                   });
        clickItem.SetFocus(true);
        m_selectedDefenceItem = clickItem;
        int remainNum = 0;

        int.TryParse(m_selectedDefenceItem.RemainNum.text, out remainNum);
        //挑战防守副本,判断体力和次数
        if (remainNum <= 0)
        {
            ChallengeBtn.Enable = false;
            m_challengeBtnSpriteSwitch.ChangeSprite(3);
        }
        else
        {
            ChallengeBtn.Enable = true;
            m_challengeBtnSpriteSwitch.ChangeSprite(1);
        }
    }
Beispiel #2
0
    public void Init(int?selectedEctype)
    {
        m_selectedDefenceItem = null;
        m_posAnim.Reset();
        m_posAnim.Play(true);
        EnableItemPoints.ApplyAllItem(P => P.transform.ClearChildImmediate());
        DisableItemPoints.ApplyAllItem(P => P.transform.ClearChildImmediate());

        var heroPlayerDataModel = PlayerManager.Instance.FindHeroDataModel();
        //副本类型为8  指防守副本
        var defenceEctypes = EctypeConfigManager.Instance.EctypeContainerConfigFile.ectypeContainerDataList.Where(P => P.lEctypeType == 8);
        var playerLev      = heroPlayerDataModel.GetUnitValue().sMsgPropCreateEntity_SC_UnitVisibleValue.UNIT_FIELD_LEVEL;
        //获得能挑战的防守副本
        var sortedList = defenceEctypes.ToList();

        sortedList.Sort((x, y) => {
            if (x.lMinActorLevel == y.lMinActorLevel)
            {
                return(0);
            }
            else if (x.lMinActorLevel < y.lMinActorLevel)
            {
                return(1);
            }
            else
            {
                return(-1);
            }
            //return x.lMinActorLevel<y.lMinActorLevel?1:-1;
        });
//		for(int i=0;i<sortedList.Count;i++)
//		{
//			Debug.Log(sortedList[i].lMinActorLevel);
//		}
        EctypeContainerData[] canChallengeEctypes = new EctypeContainerData[3];

        //EctypeConfigManager.Instance.EctypeSelectConfigList.Values.ApplyAllItem(P=>P.DefenceChallengeRemainNum=2);

        canChallengeEctypes[0] = sortedList.FirstOrDefault(P => P.lMinActorLevel <= playerLev && P.lEctypePos[2] == "1");
        canChallengeEctypes[1] = sortedList.FirstOrDefault(P => P.lMinActorLevel <= playerLev && P.lEctypePos[2] == "2");
        canChallengeEctypes[2] = sortedList.FirstOrDefault(P => P.lMinActorLevel <= playerLev && P.lEctypePos[2] == "3");

        for (int i = 0; i < 3; i++)
        {
            if (canChallengeEctypes[i] == null)
            {
                continue;
            }
            var enableItem    = NGUITools.AddChild(EnableItemPoints[i], DefenceEctypeEnableItemPrefab);
            var itemBehaviour = enableItem.GetComponent <DefenceEctypeEnableItemBehaviour>();
            itemBehaviour.Init(canChallengeEctypes[i]);

            #region 引导代码
            BtnMapId_Sub defence_Stage = BtnMapId_Sub.Defence_Stage1;
            int          remainNum     = 0;
            switch (i)
            {
            case 0:
                defence_Stage = BtnMapId_Sub.Defence_Stage1;
                remainNum     = heroPlayerDataModel.PlayerValues.PLAYER_FIELD_EXPDEFIEND_VALUE;
                break;

            case 1:
                defence_Stage = BtnMapId_Sub.Defence_Stage2;
                remainNum     = heroPlayerDataModel.PlayerValues.PLAYER_FIELD_COINDEFINED_VALUE;
                break;

            case 2:
                defence_Stage = BtnMapId_Sub.Defence_Stage3;
                remainNum     = heroPlayerDataModel.PlayerValues.PLAYER_FIELD_GOLDDEFINED_VALUE;
                break;
            }
            itemBehaviour.CallBackBtn.gameObject.RegisterBtnMappingId(UIType.Defence, defence_Stage);
            #endregion


            //var selectEct=EctypeConfigManager.Instance.EctypeSelectConfigList.Values.SingleOrDefault(P=>P._vectContainer.Contains(canChallengeEctypes[i].lEctypeContainerID));
            if (m_selectedDefenceItem == null && remainNum > 0)
            {
                itemBehaviour.SetFocus(true);
                m_selectedDefenceItem = itemBehaviour;
            }
            else
            {
                itemBehaviour.SetFocus(false);
            }
            m_enableItems[i] = itemBehaviour;
            //监听点击事件处理
            itemBehaviour.CallBackAct = DefenceItemClick;
        }
        if (selectedEctype != null)
        {
            for (int m = 0; m < m_enableItems.Length; m++)
            {
                if (m_enableItems[m] != null && m_enableItems[m].EctypeContainerData.lEctypeContainerID == selectedEctype.Value)
                {
                    if (m_selectedDefenceItem != null)
                    {
                        m_selectedDefenceItem.SetFocus(false);
                    }
                    m_selectedDefenceItem = m_enableItems[m];
                    m_selectedDefenceItem.SetFocus(true);
                    break;
                }
            }
        }
        //没有一个副本可以挑战,按钮不可用
        if (m_selectedDefenceItem == null)
        {
            ChallengeBtn.Enable = false;
            //置灰
            m_challengeBtnSpriteSwitch.ChangeSprite(3);
        }
        else
        {
            ChallengeBtn.Enable = true;
            m_challengeBtnSpriteSwitch.ChangeSprite(1);
        }


        //下一级挑战副本
        EctypeContainerData[] CntnChallengeEctypes = new EctypeContainerData[3];

        CntnChallengeEctypes[0] = sortedList.LastOrDefault(P => P.lMinActorLevel > playerLev && P.lEctypePos[2] == "1");
        CntnChallengeEctypes[1] = sortedList.LastOrDefault(P => P.lMinActorLevel > playerLev && P.lEctypePos[2] == "2");
        CntnChallengeEctypes[2] = sortedList.LastOrDefault(P => P.lMinActorLevel > playerLev && P.lEctypePos[2] == "3");

        for (int i = 0; i < 3; i++)
        {
            if (CntnChallengeEctypes[i] == null)
            {
                continue;
            }
            var enableItem    = NGUITools.AddChild(DisableItemPoints[i], DefenceEctypeDisableItemPrefab);
            var itemBehaviour = enableItem.GetComponent <defenceEctypedisableItemBehaviour>();
            itemBehaviour.Init(CntnChallengeEctypes[i]);
        }
    }