Ejemplo n.º 1
0
    public void JudgeChaptersOpen()
    {
        for (int i = 0; i < ChapterList.Count; i++)
        {
            ChapterVo chapter = ChapterList[i];
//            int firstLevelId = chapter.LevelList[0].LevelId;
//            int beforeLevelId = GetLevelInfo(firstLevelId).BeforeLevelId;

            LevelVo firstLevel    = chapter.LevelList[0];
            int     beforeLevelId = firstLevel.BeforeLevelId;

            if (beforeLevelId == 0)
            {
                _firstNormalLevel    = firstLevel;
                chapter.IsNormalOpen = true;
            }
            else
            {
                //找到章节第一关卡的上一个关卡是否通过
                LevelVo level = GetLevelInfo(beforeLevelId);
                chapter.IsNormalOpen = level.IsPass;
            }
        }

//        //精英关卡开放逻辑
//        for (int i = 0; i < ChapterList.Count; i++)
//        {
//            ChapterVo chapter = ChapterList[i];
//            int firstLevelId = chapter.HardLevelList[0].LevelId;
//            int beforeLevelId = GetLevelInfo(firstLevelId).BeforeLevelId;
//            if (beforeLevelId == 0)
//            {
//                _firstHardLevel = GetLevelInfo(firstLevelId);
//                if (chapter.LevelList[chapter.LevelList.Count - 1].IsPass)
//                {
//                    chapter.IsHardOpen = true;
//                }
//            }
//            else
//            {
//                //找到章节第一个关卡的上一个关卡是否通过
//                //判断普通的这一章是否通关
//                if (chapter.ChapterId - 1 >= 0)
//                {
//                    ChapterVo thisChapter = ChapterList[chapter.ChapterId - 1];
//                    if (thisChapter.LevelList[thisChapter.LevelList.Count - 1].IsPass == false)
//                    {
//                        chapter.IsHardOpen = false;
//                        continue;
//                    }
//                }
//
//                chapter.IsHardOpen = GetLevelInfo(beforeLevelId).IsPass;
//            }
//        }

        NewNormalLevel = GetNewLevel(_firstNormalLevel);
//        NewHardLevel = GetNewLevel(_firstHardLevel);
    }
Ejemplo n.º 2
0
    private void OnSelectChapter(int index)
    {
        if (_levelModel.ChapterList[index].IsNormalOpen == false)
        {
            FlowText.ShowMessage(I18NManager.Get("Common_ChapterNotUnlock"));
            _dropdown.value = _currentChapterId - 1;
            return;
        }

        if (!_levelModel.ChapterList[index].IsSupporterLevelSatisfy)
        {
            // FlowText.ShowMessage("应援会 Lv." + _levelModel.NewNormalLevel?.DepartmentLevel + "解锁");
            FlowText.ShowMessage(I18NManager.Get("MainLine_Hint3", _levelModel.NewNormalLevel?.DepartmentLevel));
            _dropdown.value = _currentChapterId - 1;
            return;
        }

        _currentChapterId = index + 1;
        _currentChapter   = _levelModel.ChapterList[_currentChapterId - 1];

        IsShowDownloadBtn(_currentChapterId);

        int imageIndex = (_currentChapterId - 1) % 4 + 1;

        _calendar.texture   = ResourceManager.Load <Texture>("MainLine/calendar" + imageIndex, ModuleName);
        _dropdownImg.sprite = AssetManager.Instance.GetSpriteAtlas("UIAtlas_MainLine_" + imageIndex);
        _dropdownBg.sprite  = AssetManager.Instance.GetSpriteAtlas("UIAtlas_MainLine_dropdownBg" + imageIndex);

        _expression.sprite = AssetManager.Instance.GetSpriteAtlas("UIAtlas_MainLine_Expression" + (index % 12 + 1));

        _calendar.transform.RemoveChildren();

        Color color = Colors[index % 4];

        _prevChapterBtn.GetComponentInChildren <Text>().color = color;
        _nextChapterBtn.GetComponentInChildren <Text>().color = color;


        if (_currentChapter.NextChapterVo != null && _currentChapter.IsNormalPass && _currentChapter.NextChapterVo.LevelList[0].IsPass == false)
        {
            _newNextChapter.gameObject.SetActive(true);
        }
        else
        {
            _newNextChapter.gameObject.SetActive(false);
        }
//        foreach (var levelData in _levelModel.LocalDataList[index])
//        {
//            if (!string.IsNullOrEmpty(levelData.itemId))
//            {
//                Image tagImage = Instantiate(tagItem).transform.GetImage("Image");
//                tagImage.transform.parent.SetParent(_calendar.transform, false);
//                tagImage.sprite = AssetManager.Instance.GetSpriteAtlas(levelData.itemId);
//                tagImage.SetNativeSize();
//
//                tagImage.transform.parent.GetRectTransform().anchoredPosition = levelData.position;
//            }
//        }


        var battleItemPref = GetPrefab("MainLine/Prefabs/BattleItem");
        var storyItemPref  = GetPrefab("MainLine/Prefabs/StoryItem");

        _prevChapterBtn.gameObject.SetActive(_currentChapterId != 1);

        if (_currentChapter.NextChapterVo == null && _currentChapter.IsNormalPass)
        {
            _nextChapterBtn.gameObject.SetActive(true);
        }
        else if (_currentChapter.NextChapterVo != null && _currentChapter.NextChapterVo.IsNormalOpen)
        {
            _nextChapterBtn.gameObject.SetActive(true);
        }
        else
        {
            _nextChapterBtn.gameObject.SetActive(false);
        }

        //策划说不要这个地方了
        // _starText.text = _currentChapter.CurrentStar + "/" + _currentChapter.MaxStar;

        Transform item = null;

        foreach (var levelVo in _currentChapter.LevelList)
        {
            if (levelVo.IsPass == false && levelVo != _levelModel.NewNormalLevel)
            {
                continue;
            }

            if (levelVo.LevelType == LevelTypePB.Story)
            {
                //剧情
                item = Instantiate(storyItemPref).transform;
            }
            else if (levelVo.LevelType == LevelTypePB.Value)
            {
                //战斗
                item = Instantiate(battleItemPref).transform;
            }

            bool doAnimation = _levelModel.LastLevel != null &&
                               _levelModel.NewNormalLevel != null &&
                               _levelModel.NewNormalLevel.LevelId != _levelModel.LastLevel.LevelId &&
                               levelVo == _levelModel.NewNormalLevel;

            item.gameObject.AddComponent <CalendarItem>().SetData(levelVo, doAnimation);
            item.GetComponent <RectTransform>().anchoredPosition = levelVo.Positon;
            item.SetParent(_calendar.transform, false);
            PointerClickListener.Get(item.gameObject).onClick = OnCalendarItemClick;
        }

        _levelModel.LastLevel = _levelModel.NewNormalLevel;

        var tagItem = GetPrefab("MainLine/Prefabs/TagItem");

        if (_levelModel.NewNormalLevel != null && _levelModel.NewNormalLevel.ChapterGroup == _currentChapterId)
        {
            Image tagImage = Instantiate(tagItem).transform.GetImage("Image");
            tagImage.transform.parent.SetParent(_calendar.transform, false);

            tagImage.color = new Color(1, 1, 1, 0);
            tagImage.DOFade(1, 0.05f).SetDelay(0.6f);
            tagImage.transform.parent.GetRectTransform().anchoredPosition = _levelModel.NewNormalLevel.Positon;
        }

        if (_canvasGroup.alpha < 1)
        {
            _canvasGroup.alpha = 0.5f;
            _canvasGroup.DOFade(1, 0.2f);
        }
    }
Ejemplo n.º 3
0
    public void SetData(LevelRes res)
    {
        LocalDataList = ClientData.LoadLevelData();

        LevelBuyRules = res.LevelBuyRules;
        CommentRule   = res.CommentRules;
        CardNumRules  = res.CardNumRules;

        InfoRule = res.InfoRules;
        PlotRule = res.PlotRules;

        LevelDict   = new Dictionary <int, LevelVo>();
        ChapterList = new List <ChapterVo>();

        ChapterVo chapter = null;

        Dictionary <int, ChapterVo> chapterDict = new Dictionary <int, ChapterVo>();

        for (int i = 0; i < res.Levels.Count; i++)
        {
            var level = new LevelVo();
            level.SetData(res.Levels[i], PlotRule, InfoRule, LocalDataList);

            LevelDict.Add(level.LevelId, level);

            if (chapterDict.ContainsKey(level.ChapterGroup) == false)
            {
                chapter = new ChapterVo();
                chapterDict[level.ChapterGroup] = chapter;
                chapter.LevelList     = new List <LevelVo>();
                chapter.HardLevelList = new List <LevelVo>();
                chapter.ChapterId     = level.ChapterGroup;

                for (int j = 0; j < InfoRule.Count; j++)
                {
                    var info = InfoRule[j];
                    if (info.InfoType == 1 && info.InfoId == level.ChapterGroup)
                    {
                        chapter.ChapterName = info.LevelName;
                        chapter.ChapterDesc = info.LevelDesc;
                        break;
                    }
                }
            }

            if (level.Hardness == GameTypePB.Difficult)
            {
                chapterDict[level.ChapterGroup].HardLevelList.Add(level);
            }
            else
            {
                chapterDict[level.ChapterGroup].LevelList.Add(level);
            }
        }

//        var prevPos = GetPrevChapterPos();
//        var nextPos = GetNextChapterPos();
        foreach (var chapterVo in chapterDict)
        {
            ChapterList.Add(chapterVo.Value);
//            if (nextPos.Length >= chapterVo.Value.ChapterId)
//            {
//                chapterVo.Value.NextPos = nextPos[chapterVo.Value.ChapterId - 1];
//                chapterVo.Value.PrevPos = prevPos[chapterVo.Value.ChapterId - 1];
            if (chapterDict.ContainsKey(chapterVo.Value.ChapterId + 1))
            {
                chapterVo.Value.NextChapterVo = chapterDict[chapterVo.Value.ChapterId + 1];
            }

            if (chapterDict.ContainsKey(chapterVo.Value.ChapterId - 1))
            {
                chapterVo.Value.PrevChapterVo = chapterDict[chapterVo.Value.ChapterId - 1];
            }
//            }
        }
    }