Ejemplo n.º 1
0
 /// <summary>
 /// Transition to new Scene (as if it was a state)
 /// </summary>
 ///
 public void TransitionTo(SceneID sceneID)
 {
     if (!IsFading)
     {
         StartCoroutine(DoSceneChange(sceneID));   // Start the scene transition
     }
 }
Ejemplo n.º 2
0
        private Stream GetFileStream(SceneID sceneID)
        {
            //todo, use resource
            var path = @"C:\Users\Miko\Documents\GitHub\Simple2DGame\QuickGame1\Content\Maps\" + sceneID.ToString() + ".map";

            return(File.Open(path, FileMode.OpenOrCreate));
        }
Ejemplo n.º 3
0
    /// <summary>
    /// 次のシーンに行かせる処理です。
    /// 切り替えたいシーンを引数で設定してください。
    /// </summary>
    /// <param name="nextScene"></param>
    public void ChangeScene(SceneID nextScene)
    {
        // 例外処理 ---------------------------------------------//

        if (nextScene == SceneID.MAX)
        {
            Debugger.LogError("そんなシーンはありません。");
        }

        if (nextScene == nowScene)
        {
            Debugger.LogWarning("同じシーンが設定されています。");
        }

        // -------------------------------------------------------//

        // 次のシーンを表示
        sceneList[(int)nextScene].behaviour.gameObject.SetActive(true);

        // 現在のシーンを非表示
        sceneList[(int)nowScene].behaviour.gameObject.SetActive(false);

        // 現在のシーンの終了処理
        sceneList[(int)nowScene].behaviour.Finish();

        nowScene = nextScene;

        Debugger.Log(">> ChangeScene");
        Debugger.Log(nowScene.ToString());
    }
Ejemplo n.º 4
0
    IEnumerator DoSceneChange(SceneID scene)
    {
        // Run scene exit, except if this is the first scene in session
        //
        if (m_currentGameScene)
        {
            m_currentGameScene.OnExitScene();

            // Fade to black
            //
            yield return(StartCoroutine(Fade(1.0f)));
        }

        // Switch scenes
        //
        yield return(StartCoroutine(SwapScenes(scene)));

        // Fade in to scene
        //
        yield return(StartCoroutine(Fade(0.0f)));

        // New scene "state"
        //
        m_currentGameScene = GetGameScene();

        // m_currentGameScene.Start() handles startup stuff, so no need for an explicit call
    }
Ejemplo n.º 5
0
    public void GotoScene(SceneID id)
    {
        switch (id)
        {
        case SceneID.Login:
            UnityEngine.SceneManagement.SceneManager.LoadScene(0);
            break;

        case SceneID.Main:
            UnityEngine.SceneManagement.SceneManager.LoadScene(1);
            break;

        case SceneID.Loading:
            UnityEngine.SceneManagement.SceneManager.LoadScene(2);
            break;

        case SceneID.Battle:
            UnityEngine.SceneManagement.SceneManager.LoadScene(3);
            break;

        case SceneID.Magic:
            UnityEngine.SceneManagement.SceneManager.LoadScene(4);
            break;

        default:
            Debug.LogError("error sceneid");
            break;
        }

        // 切换场景时,清楚gui缓存
        GUIManager.GetInstance().Clear();

        _CurrentSceneID = id;
    }
Ejemplo n.º 6
0
 public static DependenceData CreateAtLoaded(SceneID sceneID, Argument argument = null) =>
 new DependenceData
 {
     Timing = TimingType.Loaded, Data = new SceneData {
         SceneID = sceneID, Argument = argument
     }
 };
Ejemplo n.º 7
0
    private IEnumerator LoadScene(SceneID id)
    {
        currentAsyncOperation = SceneManager.LoadSceneAsync((int)id, LoadSceneMode.Additive);
        currentAsyncOperation.allowSceneActivation = false;

        yield return(currentAsyncOperation);
    }
Ejemplo n.º 8
0
        ////////////////

        protected sealed override void Receive()
        {
            var mngr       = CutsceneManager.Instance;
            var cutsceneId = new CutsceneID(this.CutsceneModName, this.CutsceneClassFullName);

            Player playsFor = Main.player[this.PlaysForWho];

            if (playsFor?.active != true)
            {
                LogHelpers.Warn("Missing player #" + this.PlaysForWho);
                return;
            }

            var cutscene = mngr.GetCurrentCutscene_Player(playsFor);

            if (cutscene == null)
            {
                LogHelpers.Warn("No cutscene " + cutsceneId + " playing " + playsFor.name + " (" + this.PlaysForWho + ")");
                return;
            }

            SceneID sceneId = new SceneID(this.SceneModName, this.SceneClassFullName);

            mngr.SetCutsceneSceneFromNetwork(cutsceneId, playsFor, sceneId, this, false);
        }
Ejemplo n.º 9
0
    public void ToggleEnding(SceneID endType)
    {
        switch (endType)
        {
        case SceneID.Craig:
            _ending1Toggle = true;
            ending1.isOn   = true;
            break;

        case SceneID.Dad:
            _ending2Toggle = true;
            ending2.isOn   = true;
            break;

        case SceneID.Sad:
            _ending3Toggle = true;
            ending3.isOn   = true;
            break;

        case SceneID.Happy:
            _ending4Toggle = true;
            ending4.isOn   = true;
            break;
        }
    }
Ejemplo n.º 10
0
        /// <summary>
        /// Converts a position within a certain map to the equivalent position within the entire template
        /// </summary>
        /// <param name="scene"></param>
        /// <param name="positionInMap"></param>
        /// <returns></returns>
        public Vector2 PositionInMapToPointInTemplate(SceneID scene, Vector2 positionInMap)
        {
            var mapRegion = MapRegions[scene.MapNumber];
            var ret       = mapRegion.UpperLeft.Translate(positionInMap);

            return(ret);
        }
Ejemplo n.º 11
0
        /// <summary>
        /// Converts a position within the template to a position with a particular map
        /// </summary>
        /// <param name="scene"></param>
        /// <param name="positionInMap"></param>
        /// <returns></returns>
        public Vector2 PointInTemplateToPositionInMap(SceneID scene, Vector2 pointInTemplate)
        {
            var mapRegion  = MapRegions[scene.MapNumber];
            var pointInMap = pointInTemplate.Subtract(mapRegion.UpperLeft);

            return(pointInMap);
        }
Ejemplo n.º 12
0
        public override bool OnStart()
        {
            try
            {
                ServicePointManager.DefaultConnectionLimit = 12;

                // For information on handling configuration changes
                // see the MSDN topic at http://go.microsoft.com/fwlink/?LinkId=166357.
                RoleEnvironment.Changing += roleEnvironmentChanging;
                m_threadsID           = new Dictionary <string, int>();
                m_renderAbortHandlers = new Dictionary <int, List <MessageQueue <RenderMessage> > >();
                m_connectionHandlers  = new Dictionary <string, NetMessageHandler>();
                m_log = new RenderLog("dispatcherlog");

                m_log.Info("storageAccount created");
                initQueue();
                m_log.Info("Queue initialized");
                initBlob();
                m_log.Info("Blob initialized");
                m_log.Info("RolesCnt initialized");
                m_scenesId        = SceneID.Get();
                m_instanceManager = InstanceManager.Get(m_log);
                m_log.Info("OnStart completed");
            }
            catch (Exception ex)
            {
                RoleEnvironment.RequestRecycle();    //request role restart
                System.Diagnostics.Trace.TraceWarning("Method OnStart() of WebRole is failed.");
                m_log.Error("Error when initializing: " + ex.Message);
                return(false);
            }

            return(base.OnStart());
        }
Ejemplo n.º 13
0
    IEnumerator SwapScenes(SceneID newScene)
    {
        int currentSceneIndex = SceneManager.GetActiveScene().buildIndex;

        if (currentSceneIndex != 0)       // Don't unload scene controller scene, if it's currently the only one loaded (at startup)
        {
            defaultCamera.enabled = true; // Switch to default camera during scene transition (Otherwise, "No cameras rendering" error pops up)

            // Out with the old...
            //
            yield return(SceneManager.UnloadSceneAsync(currentSceneIndex));   // Otherwise, swap out this scene for new one
        }

        // ... In with the new
        //
        yield return(SceneManager.LoadSceneAsync((int)newScene, LoadSceneMode.Additive));

        Scene currentScene = SceneManager.GetSceneAt(SceneManager.sceneCount - 1);

        SceneManager.SetActiveScene(currentScene);

        // Finally, set the camera
        //
        SetCamera();
    }
Ejemplo n.º 14
0
    // Update is called once per frame
    void Update()
    {
        if (Input.GetKey(KeyCode.E) && notagain == false)
        {
            notagain = true;
            delay    = Time.realtimeSinceStartup;
            GameObject me             = this.gameObject;
            SceneID    winner         = this.GetComponent <SceneID>();
            float      winnerdistance = float.MaxValue;

            float distance = float.MaxValue;
            foreach (SceneID sid in activeObjects)
            {
                distance = Vector3.Distance(sid.gameObject.transform.position, this.gameObject.transform.position);
                if (distance < winnerdistance)
                {
                    winnerdistance = distance;
                    winner         = sid;
                }
            }


            Debug.Log(winnerdistance);

            if ((winnerdistance < 3) && winner.available)
            {
                SceneManager.LoadScene(winner.id);
            }
        }

        if (Time.realtimeSinceStartup - delay > waittime)
        {
            notagain = false;
        }
    }
Ejemplo n.º 15
0
        private async Task LoadSceneAsync(SceneID sceneID, GameObject parameterObject = null)
        {
            if (loading)
            {
                Debug.LogWarning("SceneLoader is already loading a scene. Ignoring LoadScene call.");
                return;
            }

            loading = true;

            SceneReference targetScene = ActiveSceneMap[sceneID];

            await loadingScreen.Show();

            if (parameterObject)
            {
                SceneManager.MoveGameObjectToScene(parameterObject, baseScene);
            }

            await UnloadPreviousScene();
            await LoadNewScene(targetScene);

            await Awaiters.NextFrame;

            loading = false;

            await loadingScreen.Dismiss();
        }
Ejemplo n.º 16
0
    void Update()
    {
        if (_NextSceneID != SceneID.NULL && _AsyncObject == null)
        {
            //加载场景
            AsyncLoadScene(_NextSceneID);
            Debug.Log("START LOAD SCENE" + _NextSceneID.ToString());
        }
        //异步加载场景OK
        if (_AsyncObject != null && _AsyncObject.isDone && LoadedReady)
        {
            SceneTransitionData sd = GetSceneData(_NextSceneID);

            if (sd.CurrentSceneID == _LoadedSceneID)
            {
                Debug.Log("Scene " + sd.SceneName + " AsyncLoaded.");
                _NextSceneID   = SceneID.NULL;
                _LoadedSceneID = SceneID.NULL;
                _CurrSceneID   = sd.CurrentSceneID;
                _AsyncObject   = null;
            }
            else
            {
                Debug.Log("Scene Loading AsyncLoaded. Load Next Scene");
                AsyncLoadScene(_NextSceneID);
            }
        }
    }
Ejemplo n.º 17
0
 public void CutsceneEvent(SceneID endType)
 {
     menu.SetActive(false);
     cutscenes.SetActive(true);
     gameUI.SetActive(false);
     gameplay.SetActive(false);
     cutscenes.GetComponent <CutsceneManager>().DisplayCutscene(endType);
 }
Ejemplo n.º 18
0
 public SceneTransitionData(SceneID sid, string name, bool additive, SceneID loading, string uiPfbName)
 {
     CurrentSceneID = sid;
     SceneName      = name;
     IsAdditive     = additive;
     LoadingScene   = loading;
     UiPfb          = uiPfbName;
 }
Ejemplo n.º 19
0
 public void SetNextScene(SceneID sceneID)
 {
     if (sceneID != _LoadedSceneID)
     {
         EventListener.Broadcast(MsgType.SceneBeginLoad, sceneID);
         _NextSceneID = sceneID;
     }
 }
Ejemplo n.º 20
0
    private void StopForScene(SceneID sceneType)
    {
        _isPlaying = false;
        StopAllCoroutines();
        charCont.CharStop();

        sceneSwapper.CutsceneEvent(sceneType);
    }
Ejemplo n.º 21
0
    static int IntToEnum(IntPtr L)
    {
        int     arg0 = (int)LuaDLL.lua_tonumber(L, 1);
        SceneID o    = (SceneID)arg0;

        ToLua.Push(L, o);
        return(1);
    }
Ejemplo n.º 22
0
        private Vector2 CalculateActorStart(IMovesBetweenScenes actorInLastScene, SceneID lastScene, Scene nextScene)
        {
            var templatePosition = MasterTemplate.PositionInMapToPointInTemplate(lastScene, actorInLastScene.Position.Center);

            var nextMapPosition = MasterTemplate.PointInTemplateToPositionInMap(nextScene.ID, templatePosition);

            return(nextMapPosition);
        }
Ejemplo n.º 23
0
    private static void EnterCurrentScene(SceneID sceneID)
    {
        var scene = CreateScene(sceneID);

        // 异步加载场景
        scene.Load(OnSceneLoaded);

        m_curScene = scene;
    }
Ejemplo n.º 24
0
    /// <summary>
    /// 実行する
    /// </summary>
    /// <returns></returns>
    public bool Execute()
    {
        if (SceneManager.GetActiveScene().name != m_currentScene.Name)
        {
            return(false);
        }

        // 現在のシーンを実行する
        SceneID result = m_currentScene.Execute();

        // 戻り値で処理を分ける
        switch (result)
        {
        case SceneID.CONTINUE:
            // シーンを継続する
            break;

        case SceneID.SCENE_TITLE:
            // タイトルシーンへ
            ChangeScene(m_title);
            break;

        case SceneID.SCENE_REVISED:
            // 探索シーン
            ChangeScene(m_revised);
            break;

        case SceneID.SCENE_BATTLE:
            // バトルシーンへ
            ChangeScene(m_battle, LoadSceneMode.Additive);
            break;

        case SceneID.SCENE_RESULT:
            // リザルトシーンへ
            ChangeScene(m_result);
            break;

        case SceneID.SCENE_CAPTURETUTORIAL:
            // キャプチャーチュートリアル
            ChangeScene(m_captureTutorial);
            break;

        case SceneID.SCENE_BATTLETUTORIAL:
            // バトルチュートリアル
            ChangeScene(m_battleTutorial);
            break;

        case SceneID.SCENE_ENDING:
            // エンディングシーン
            ChangeScene(m_ending);
            break;
        }

        // 正常に更新
        return(true);
    }
Ejemplo n.º 25
0
    public static void SetupScene(SceneID id)
    {
        if (singleton == null)
        {
            Debug.LogError("SceneManager_VS.SetupScene(" + id.ToString() + ") called, but singleton was NULL! Aborting.");
            return;
        }

        singleton._SetupScene(id);
    }
Ejemplo n.º 26
0
    public void DisplayCutscene(SceneID scene)
    {
        //We create this variable to modify and send on later
        sceneSwapper.ToggleEnding(scene);

        //Choose which Cutscene is going to play
        switch (scene)
        {
        case SceneID.Mid1:
            //isEndScene = false;
            ShowSkipButton();
            _curActiveScene = midCutscene1;
            //midCutscene1.StartCutscene(this, false);
            break;

        case SceneID.Mid2:
            //isEndScene = false;
            ShowSkipButton();
            _curActiveScene = midCutscene2;
            //midCutscene2.StartCutscene(this, false);
            break;

        case SceneID.Craig:
            //isEndScene = true;
            ShowSkipButton();
            _curActiveScene = midCutscene1;
            //gameOverCraig.StartCutscene(this, true);
            break;

        case SceneID.Dad:
            //isEndScene = true;
            ShowSkipButton();
            _curActiveScene = gameOverDad;
            //gameOverDad.StartCutscene(this, true);
            break;

        case SceneID.Sad:
            //isEndScene = true;
            ShowSkipButton();
            _curActiveScene = gameOverSadness;
            //gameOverSadness.StartCutscene(this, true);
            break;

        case SceneID.Happy:
            //isEndScene = true;
            ShowSkipButton();
            _curActiveScene = endCutscene;
            //endCutscene.StartCutscene(this, true);
            break;
        }

        //Launch the selected scene
        _curActiveScene.StartCutscene(this);
    }
Ejemplo n.º 27
0
        /// <inheritdoc/>
        public override bool Equals(object obj)
        {
            if (!(obj is Scene))
            {
                return(false);
            }

            Scene other = obj as Scene;

            return(SceneID.Equals(other.SceneID));
        }
Ejemplo n.º 28
0
    public void LoadScene()
    {
        if (currentScene == pageID)
        {
            return;
        }

        UnloadPrevious();
        sceneLoader.LoadSceneAdditive(pageID);
        currentScene = pageID;
    }
Ejemplo n.º 29
0
 // Update is called once per frame
 void Update()
 {
     if (Input.GetKey(KeyCode.E))
     {
         bassstream.BASS_StreamFree(0);
         bassstream.BASS_Free();
         GameObject me     = this.gameObject;
         SceneID    winner = this.GetComponent <SceneID>();
         SceneManager.LoadScene(winner.id);
     }
 }
Ejemplo n.º 30
0
        /// <summary>
        /// Stack順にSceneIDからSceneDataを返す
        /// </summary>
        public SceneData FindSceneDataBySceneID(SceneID sceneID)
        {
            foreach (var sceneData in _sceneData)
            {
                if (sceneData.SceneID == sceneID)
                {
                    return(sceneData);
                }
            }

            return(null);
        }