コード例 #1
0
ファイル: Scene.cs プロジェクト: laurence6/Mario
        public void Active(string level)
        {
            unsubscribe?.Invoke();
            unsubscribe = null;

            ActiveScene?.Deactive();
            ActiveScene = scenes[level];
            ActiveScene.Active();
            Camera.Ins.Reset();
            Camera.Ins.LookAt(Player.Location);

            unsubscribe += EventManager.Ins.Subscribe(EventEnum.GameObjectCreate, (s, e) => ActiveScene.AddGameObject((e as GameObjectCreateEventArgs).Object));
            unsubscribe += EventManager.Ins.Subscribe(EventEnum.GameObjectDestroy, (s, e) =>
            {
                var eventArgs = e as GameObjectDestroyEventArgs;
                (eventArgs.Object as IDisposable)?.Dispose();
                ActiveScene.RemoveGameObject(eventArgs.Object);
            });
        }