Exemplo n.º 1
0
        public GameSceneManager()
        {
            Transform root = GameObject.Find("GameRoot").transform;

            Assert.IsTrue(root != null, "Game Root must always exist.");
            if (root == null)
            {
                return;
            }

            GameObject manager = new GameObject(typeof(GameSceneManager).ToString());

            manager.transform.SetParent(root.transform);
            m_currentSceneSlot = manager.AddComponent <SceneSlot>();

            m_currentSceneSlot.AddCallbackAfterLoaded(delegate() {
                CameraService.Instance.UpdateCurrentCamera();
                //DisplayCurrentSceneNameTip ();
                CinemachineManager.Instance.SetBoundingVolumeByName(GetCurrentSceneEnum().ToString());// set camera move range

                //Active scene and skybox setting
                UnityEngine.SceneManagement.Scene loadedScene = new UnityEngine.SceneManagement.Scene();
                bool result = StarPlatinum.PrefabManager.Instance.GetLoadedScene(m_currentSceneSlot.GetCurrentSceneEnum(), ref loadedScene);
                if (result)
                {
                    UnityEngine.SceneManagement.SceneManager.SetActiveScene(loadedScene);
                    SkyboxManager.Instance().RefreshSkyboxSettingAfterNewGameSceneIsLoaded(RenderSettings.skybox, RenderSettings.ambientLight);
                }
            });
        }
Exemplo n.º 2
0
        private void SetNextAction(StoryAction storyAction)
        {
            if (storyAction == null)
            {
                EventManager.Instance.SendEvent(new LabelEndEvent()
                {
                    LabelID = m_currentID
                });
                m_currentID = null;
                SetActionState(ActionState.Waiting);
                if (m_nextIDQueue.Count > 0)
                {
                    return;
                }
                if (RecoverRecord())
                {
                    return;
                }
                InvokeHidePanel();
                UIPanelDataProvider.OnTalkEnd?.Invoke();
                return;
            }
            m_actionType = storyAction.Type;
            m_curAction  = storyAction;
            SetActionState(ActionState.Actioning);
            Debug.LogWarning($"当前行为:{m_actionType}");

            switch (storyAction.Type)
            {
            case StoryActionType.WaitClick:
                WaitClickEnd();
                break;

            case StoryActionType.Name:
                SetNameContent(storyAction.Content);
                break;

            case StoryActionType.Content:
                if (m_typewriterCoroutine != null)
                {
                    StopCoroutine(m_typewriterCoroutine);
                }
                m_typewriterCoroutine = StartCoroutine(Typewriter(storyAction.Content));
                break;

            case StoryActionType.Color:
                m_textHelp.PushColor(storyAction.Content);
                SetActionState(ActionState.End);
                break;

            case StoryActionType.Font:
                m_textHelp.PushFont(storyAction.Content);
                SetActionState(ActionState.End);
                break;

            case StoryActionType.Jump:
                var jumpAction = storyAction as StoryJumpAction;
                if (jumpAction == null)
                {
                    Debug.LogError("JumpAction null!!!!!!!Please check");
                    SetActionState(ActionState.End);
                    return;
                }
                Debug.Log($"=== options:{jumpAction.Options}");
                ShowJumpOption(jumpAction.Options);
                break;

            case StoryActionType.Picture:
                var pictureAction = storyAction as StoryShowPictureAction;
                if (pictureAction == null)
                {
                    Debug.LogError("pictureAction null!!!!!!!Please check");
                    SetActionState(ActionState.End);
                    return;
                }

                ShowPicture(pictureAction.Content, pictureAction.Pos);
                SetActionState(ActionState.End);
                break;

            case StoryActionType.Waiting:
                SetActionState(ActionState.Actioning);
                if (m_skip == false)
                {
                    CallbackTime(float.Parse(storyAction.Content), () => { SetActionState(ActionState.End); });
                }
                else
                {
                    SetActionState(ActionState.End);
                }
                break;

            case StoryActionType.PictureMove:
                var pictureMoveAction = storyAction as StoryPictureMoveAction;
                MovePicture(pictureMoveAction.PicID, pictureMoveAction.StartX, pictureMoveAction.StartY, pictureMoveAction.EndX, pictureMoveAction.EndY, pictureMoveAction.Ease, pictureMoveAction.Duration);
                break;

            case StoryActionType.FontSize:
                m_textHelp.PushFontSize(storyAction.Content);
                SetActionState(ActionState.End);
                break;

            case StoryActionType.Bold:
                m_textHelp.PushBold();
                SetActionState(ActionState.End);
                break;

            case StoryActionType.ChangeBGM:
                SetBgm(storyAction.Content);
                break;

            case StoryActionType.ChangeEffectMusic:
                PlayEffectMusic(storyAction.Content);
                break;

            case StoryActionType.TypewriterInterval:
                m_textHelp.TypewriterInterval = float.Parse(storyAction.Content);
                SetActionState(ActionState.End);
                break;

            case StoryActionType.ShowEvidence:
                InvokeShowPanel(UIPanelType.UICommonDetectiveNotesPanel, new EvidenceDataProvider()
                {
                    OnShowEvidence  = OnSelectEvidenceEnd,
                    IsOnEvidence    = true,
                    CurState        = CommonMapsTipsEvidencesPanel.ShowState.Evidences,
                    IsShowSelectBtn = true
                });
                return;

            case StoryActionType.LoadGameScene:
                GameSceneManager.Instance.LoadScene(SceneLookup.GetEnum(m_curAction.Content, false));
                bool result = MissionSceneManager.Instance.LoadCurrentMissionScene();
                if (result == false)
                {
                    Debug.LogError("Current Game Scene: " + m_curAction.Content + " doesn`t contain Mission Scene " +
                                   MissionSceneManager.Instance.GetCurrentMissionEnum().ToString());
                }
                SetActionState(ActionState.End);
                break;

            case StoryActionType.LoadMission:
                var action = m_curAction as StoryLoadMissionAction;
                MissionSceneManager.Instance.SetCurrentMission(action.Mission);
                MissionSceneManager.Instance.LoadCurrentMissionScene();
                //if (MissionSceneManager.Instance.IsMissionSceneExist(action.Mission))
                //{
                //    MissionSceneManager.Instance.LoadMissionScene(action.Mission);
                //}
                //else
                //{
                //    MissionSceneManager.Instance.LoadMissionScene(MissionEnum.None);
                //}
                SetActionState(ActionState.End);
                break;

            case StoryActionType.LoadCgScene:
                UI.UIManager.Instance().ShowStaticPanel(UIPanelType.UICommonCgscenePanel, new CGSceneDataProvider()
                {
                    CGSceneID = m_curAction.Content
                });
                SetActionState(ActionState.End);
                break;

            case StoryActionType.CloseCgScene:
                if (UIManager.Instance().IsPanelShow(UIPanelType.UICommonCgscenePanel))
                {
                    StarPlatinum.TimerService.Instance.AddTimer(0.01f, () =>
                    {
                        EventManager.Instance.SendEvent(new CGSceneCloseEvent()
                        {
                            m_cgSceneId = m_curAction.Content
                        });
                    });
                }
                SetActionState(ActionState.End);
                break;

            case StoryActionType.TriggerEvent:
                var triggerAction = m_curAction as StoryEventAction;
                EventManager.Instance.SendEvent(triggerAction.Event);
                SetActionState(ActionState.End);
                break;

            case StoryActionType.PlayAnimation:
                SetActionState(ActionState.End);
                //TODO:播放动画
                break;

            case StoryActionType.PlayInteractionAnimation:
                EventManager.Instance.SendEvent(new PlayInteractionAnimationEvent()
                {
                    m_itemName = m_curAction.Content
                });
                SetActionState(ActionState.End);
                break;

            case StoryActionType.ChangeBackground:
                ShowBG(storyAction.Content);
                SetActionState(ActionState.End);
                break;

            case StoryActionType.Wrap:
                m_txtPro_content_TextMeshProUGUI.text += '\n';
                SetActionState(ActionState.End);
                break;

            case StoryActionType.ChangeSoundVolume:
                int volume = int.Parse(m_curAction.Content);
                SoundService.Instance.SetVolumePercentage(volume);
                SetActionState(ActionState.End);
                break;

            case StoryActionType.EnterControversy:
                UIManager.Instance().ShowPanel(UIPanelType.UIJudgmentControversyPanel, new ControversyDataProvider()
                {
                    ID = m_curAction.Content
                });
                SetActionState(ActionState.End);
                break;

            case StoryActionType.CutIn:
                UIManager.Instance().ShowPanel(UIPanelType.UICommonBreaktheoryPanel, new BreakTheoryDataProvider()
                {
                    Type = EnumBreakTheoryType.CutIn, ImgKey = m_curAction.Content, CloseCallback =
                        () =>
                    {
                        SetActionState(ActionState.End);
                    }
                });
                break;

            case StoryActionType.LoadSkybox:
            {
                StoryLoadSkyboxAction skyboxAction = m_curAction as StoryLoadSkyboxAction;
                SkyboxManager.Instance().UpdateSkybox(skyboxAction.m_skyEnum);
                SetActionState(ActionState.End);
            }
            break;

            case StoryActionType.ChangeTalkPanelType:
                SetTalkPanelType(m_curAction.Content);
                break;

            case StoryActionType.ChangeFrontImg:
                SetFrontImg(m_curAction.Content);
                break;

            case StoryActionType.RemoveAllExhibit:
                EvidenceDataManager.Instance.RemoveAllEvidence();
                SetActionState(ActionState.End);
                break;

            case StoryActionType.TimeLine:
                PrefabManager.Instance.LoadAssetAsync <TimelineAsset>(m_curAction.Content, (res) =>
                {
                    if (res.status != RequestStatus.FAIL)
                    {
                        gameObject.SetActive(false);
                        TimelineManager.Instance().PlayTimeline(res.result as TimelineAsset, null, () =>
                        {
                            gameObject.SetActive(true);
                            SetActionState(ActionState.End);
                        });
                    }
                    else
                    {
                        SetActionState(ActionState.End);
                    }
                });
                break;

            case StoryActionType.AddEvidence:
                EvidenceDataManager.Instance.AddEvidence(m_curAction.Content);
                SetActionState(ActionState.End);
                break;

            case StoryActionType.RemoveEvidence:
                EvidenceDataManager.Instance.RemoveEvidence(m_curAction.Content);
                SetActionState(ActionState.End);
                break;

            case StoryActionType.AddTip:
                Tips.TipsManager.Instance.UnlockTip(m_curAction.Content, Tips.TipsManager.ConvertDateTimeToLong(System.DateTime.Now));      // 添加tip 数据
                SetActionState(ActionState.End);
                break;

            case StoryActionType.Position:
            {
                StoryVector3Action vector3Action = m_curAction as StoryVector3Action;
                CoreContainer.Instance.SetPlayerPosition(vector3Action.m_vector);
                SetActionState(ActionState.End);
            }
            break;

            case StoryActionType.Rotation:
            {
                StoryVector3Action vector3Action = m_curAction as StoryVector3Action;
                VMCameraManager.Instance().SetLookAtRotation(vector3Action.m_vector.x, vector3Action.m_vector.y, vector3Action.m_vector.z);
                SetActionState(ActionState.End);
            }
            break;

            case StoryActionType.GameEvent:
            {
                EventManager.Instance.SendEvent(new GameEvent()
                    {
                        EventName = m_curAction.Content
                    });
                SetActionState(ActionState.End);
            }
            break;

            default:
                Debug.LogError($"未处理对话行为:{storyAction.Type}");
                break;
            }
        }