Exemplo n.º 1
0
        void Awake()
        {
            _commonTopBarView = CommonTopBarView.CreateNewAndAttachTo(core.transform);
            _commonTopBarView.SetAsCommonStyle(string.Empty, ClickCloseHandler, true, true, true, false);
            _commonTopBarView.transform.localPosition = new Vector3(_commonTopBarView.transform.localPosition.x, _commonTopBarView.transform.localPosition.y, -1000);

            Logic.UI.Chat.View.SystemNoticeView.Create(systemNoticeRoot);

            PlayerInfo playerInfo = GameProxy.instance.PlayerInfo;

            _characterEntity = CharacterEntity.CreatePlayerEntityAsUIElement(playerInfo, roleModelRootRectTransform, false, false);
            AnimatorUtil.SetBool(_characterEntity.anim, AnimatorUtil.RUN, true);

            chapterViewPrefab.gameObject.SetActive(true);
            List <ChapterInfo> chapterInfoList = ChapterProxy.instance.GetAllChapterInfos();
            int chapterInfoCount = chapterInfoList.Count;

            for (int i = 0; i < chapterInfoCount; i++)
            {
                ChapterInfo chapterInfo = chapterInfoList[i];
                ChapterView chapterView = GameObject.Instantiate <ChapterView>(chapterViewPrefab);
//                chapterView.SetChapterInfoAndType(chapterInfo);
                chapterView.transform.SetParent(chapterBGsRoot, false);
                chapterView.transform.localScale    = Vector3.one;
                chapterView.transform.localPosition = chapterInfo.chapterData.chapterPosition;
                _chapterViewList.Add(chapterView);
                _chapterViewsDictionary.Add(chapterInfo.chapterData.Id, chapterView);

                int dungeonsCount = chapterInfo.chapterData.easyDungeonIDList.Count;
                for (int dungeonIndex = 0; dungeonIndex < dungeonsCount; dungeonIndex++)
                {
                    int easyDungeonID   = chapterInfo.chapterData.easyDungeonIDList[dungeonIndex];
                    int normalDungeonID = chapterInfo.chapterData.normalDungeonIDList[dungeonIndex];
                    int hardDungeonID   = chapterInfo.chapterData.hardDungeonIDList[dungeonIndex];

                    DungeonButton dungeonButton = GameObject.Instantiate <DungeonButton>(dungeonButtonPrefab);
                    dungeonButton.transform.SetParent(dungeonButtonsRoot, false);
                    dungeonButton.transform.localPosition = chapterInfo.chapterData.chapterPosition + chapterInfo.chapterData.positions[dungeonIndex];
                    dungeonButton.SetDungeonInfo(DungeonProxy.instance.GetDungeonInfo(chapterInfo.chapterData.easyDungeonIDList[dungeonIndex]));
                    dungeonButton.name = string.Format("dungeon_button_{0}", dungeonButton.DungeonInfo.dungeonData.dungeonID);
                    dungeonButton.gameObject.SetActive(true);
                    _easyDungeonButtonDic.Add(easyDungeonID, dungeonButton);
                    _normalDungeonButtonDic.Add(normalDungeonID, dungeonButton);
                    _hardDungeonButtonDic.Add(hardDungeonID, dungeonButton);
                }
                dungeonButtonPrefab.gameObject.SetActive(false);
            }
            chapterViewPrefab.gameObject.SetActive(false);
            selectChapterScrollRect.content.sizeDelta    = RectTransformUtility.CalculateRelativeRectTransformBounds(chapterBGsRoot).size;
            selectChapterScrollRect.onEndDragDelegate   += OnMapEndDragHandler;
            selectChapterScrollRect.onDragLeftDelegate  += OnMapDragLeftHandler;
            selectChapterScrollRect.onDragRightDelegate += OnMapDragRightHandler;
            _chapterScrollViewportSize = selectChapterScrollRect.viewport.rect.size;
            AudioController.instance.PlayBGMusic(Logic.Audio.Controller.AudioController.SELECTDUNGEON);
            BindDelegate();
        }
Exemplo n.º 2
0
        private void MoveTo(ChapterData chapterData, bool withTweenAnimation = false)
        {
            selectChapterScrollRect.StopMovement();
            _currentSelectChapterData = chapterData;

            CanvasScaler parentCanvasScaler = GetComponentInParent <CanvasScaler>();
            float        diffx   = 0;
            Vector2      destPos = Vector2.zero;

            if (parentCanvasScaler.matchWidthOrHeight <= 0)
            {
                diffx   = (960f - ChapterView.CHAPTER_BG_WIDTH) * 0.5f;
                destPos = -_currentSelectChapterData.chapterPosition + new Vector2(diffx, 0);
            }
            else if (parentCanvasScaler.matchWidthOrHeight >= 1)
            {
                diffx   = (((float)Screen.width / Screen.height) * 640 - ChapterView.CHAPTER_BG_WIDTH) * 0.5f;
                destPos = -_currentSelectChapterData.chapterPosition + new Vector2(diffx, 0);
            }

            if (withTweenAnimation)
            {
                LTDescr ltDescr = LeanTween.value(gameObject, selectChapterScrollRect.content.anchoredPosition, destPos, 0.25f);
                ltDescr.setOnUpdateVector2(OnUpdateMapPosition);
            }
            else
            {
                selectChapterScrollRect.content.anchoredPosition = destPos;
            }

            ChapterView chapterView = _chapterViewsDictionary.GetValue(chapterData.Id);

            chapterView.Show();
            _commonTopBarView.titleText.text = string.Format(Localization.Get("ui.select_chapter_view.title_template"), UIUtil.GetChineseNumberString(chapterData.Id), Localization.Get(chapterData.name));
            RefreshStarChests();
            RefreshPreviousAndNextChapterButtons();
        }
Exemplo n.º 3
0
        private void ResetDifficulty(DungeonType dungeonType)
        {
            _currentSelectDungeonType = dungeonType;
            DungeonProxy.instance.DungeonModelLuaTable.GetLuaFunction("SetPveSelectDungeonType").Call((int)dungeonType);
            if (_currentSelectDungeonType == DungeonType.Easy)
            {
                List <int> easyDungeonIDs     = _easyDungeonButtonDic.GetKeys();
                int        easyDungeonIDCount = easyDungeonIDs.Count;
                for (int i = 0; i < easyDungeonIDCount; i++)
                {
                    int dungeonID = easyDungeonIDs[i];
                    _easyDungeonButtonDic[dungeonID].SetDungeonInfo(DungeonProxy.instance.GetDungeonInfo(dungeonID));
                }
                ResetRoleModel(_easyDungeonButtonDic[DungeonProxy.instance.LastUnlockEasyDungeonID].GetComponent <RectTransform>().anchoredPosition);
            }
            else if (_currentSelectDungeonType == DungeonType.Normal)
            {
                List <int> normalDungeonIDs     = _normalDungeonButtonDic.GetKeys();
                int        normalDungeonIDCount = normalDungeonIDs.Count;
                for (int i = 0; i < normalDungeonIDCount; i++)
                {
                    int dungeonID = normalDungeonIDs[i];
                    _normalDungeonButtonDic[dungeonID].SetDungeonInfo(DungeonProxy.instance.GetDungeonInfo(dungeonID));
                }
                ResetRoleModel(_normalDungeonButtonDic[DungeonProxy.instance.LastUnlockNormalDungeonID].GetComponent <RectTransform>().anchoredPosition);
            }
            else if (_currentSelectDungeonType == DungeonType.Hard)
            {
                List <int> hardDungeonIDs     = _hardDungeonButtonDic.GetKeys();
                int        hardDungeonIDCount = hardDungeonIDs.Count;
                for (int i = 0; i < hardDungeonIDCount; i++)
                {
                    int dungeonID = hardDungeonIDs[i];
                    _hardDungeonButtonDic[dungeonID].SetDungeonInfo(DungeonProxy.instance.GetDungeonInfo(dungeonID));
                }
                ResetRoleModel(_hardDungeonButtonDic[DungeonProxy.instance.LastUnlockHardDungeonID].GetComponent <RectTransform>().anchoredPosition);
            }

            easyButton.transform.localScale = new Vector3(0.9f, 0.9f, 1);
            UIUtil.SetGrayExcludeUITextOutline(easyButton.gameObject, true);
            normalButton.transform.localScale = new Vector3(0.9f, 0.9f, 1);
            UIUtil.SetGrayExcludeUITextOutline(normalButton.gameObject, true);
            hardButton.transform.localScale = new Vector3(0.9f, 0.9f, 1);
            UIUtil.SetGrayExcludeUITextOutline(hardButton.gameObject, true);
            if (_currentSelectDungeonType == DungeonType.Easy)
            {
                easyButton.transform.localScale = new Vector3(1.1f, 1.1f, 1);
                UIUtil.SetGrayExcludeUITextOutline(easyButton.gameObject, false);
            }
            else if (_currentSelectDungeonType == DungeonType.Normal)
            {
                normalButton.transform.localScale = new Vector3(1.1f, 1.1f, 1);
                UIUtil.SetGrayExcludeUITextOutline(normalButton.gameObject, false);
            }
            else if (_currentSelectDungeonType == DungeonType.Hard)
            {
                hardButton.transform.localScale = new Vector3(1.1f, 1.1f, 1);
                UIUtil.SetGrayExcludeUITextOutline(hardButton.gameObject, false);
            }

            List <ChapterInfo> chapterInfoList = ChapterProxy.instance.GetAllChapterInfos();
            ChapterInfo        chapterInfo     = null;
            ChapterView        chapterView     = null;

            for (int i = 0, count = _chapterViewList.Count; i < count; i++)
            {
                chapterInfo = chapterInfoList[i];
                chapterView = _chapterViewList[i];
                if (!chapterInfo.IsLock(_currentSelectDungeonType))
                {
                    chapterView.SetChapterInfoAndType(chapterInfo);
                    chapterView.gameObject.SetActive(true);
                }
                else
                {
                    chapterView.gameObject.SetActive(false);
                }
            }
            selectChapterScrollRect.content.sizeDelta = RectTransformUtility.CalculateRelativeRectTransformBounds(chapterBGsRoot).size;

            int lastUnlockedDungeonID = Logic.Dungeon.Model.DungeonProxy.instance.GetLastUnlockDungeonID(dungeonType);

            this.SetSelectDungeon(lastUnlockedDungeonID);
            ChapterProxy.instance.SetLastSelect(_currentSelectDungeonType, 0);
            DungeonProxy.instance.LastSelectPVEDungeonType = dungeonType;

            easyButtonParticleEffectRootGameObject.SetActive(_currentSelectDungeonType == DungeonType.Easy);
            normalButtonParticleEffectRootGameObject.SetActive(_currentSelectDungeonType == DungeonType.Normal);
            hardButtonParticleEffectRootGameObject.SetActive(_currentSelectDungeonType == DungeonType.Hard);

            easyParticleRootGameObject.SetActive(_currentSelectDungeonType == DungeonType.Easy);
            normalParticleRootGameObject.SetActive(_currentSelectDungeonType == DungeonType.Normal);
            hardParticleRootGameObject.SetActive(_currentSelectDungeonType == DungeonType.Hard);
        }