public static bool GetCurrentScene(SceneController rootSceneController, out SceneBase currentScene)
    {
        SceneController sceneController;
        SceneBase       scene = rootSceneController.currentScene;
        bool            isSub = (scene is SceneWithSubBase);

        if (isSub)
        {
            sceneController = ((SceneWithSubBase)scene).GetSubSceneController();

            if (sceneController != null)
            {
                if (sceneController.currentScene != null)
                {
                    return(GetCurrentScene(sceneController, out currentScene));
                }
                else
                {
                    currentScene = scene;
                    return(true);
                }
            }
        }
        currentScene = scene;
        return(true);
    }
Exemple #2
0
    public static void openNextScene(SceneBase scene)
    {
        Tools.Log("===> openNextScene!");
        if (m_busy)
        {
            Tools.Log("next scene is busy now!");
            return;
        }
        //MgrPanel.disposeAllPanel();

        if (m_curScene != null)
        {
            MgrResLoader.insertRemoving(m_curScene.getResList());
            m_curScene.onLeave();
            m_curScene = null;
        }

        m_busy = true;
        PanelLoading.open();

        MgrResLoader.insertLoading(scene.getResList());
        m_nextScene = scene;

        MgrPanel.disposeAllPanel();
        MgrRes.clearObjectCacheAll();
        Util.ClearMemory();

        MgrResLoader.start(executeSceneDown);
    }
    public void SwitchToScene(SceneId sceneId, object param = null)
    {
        if (sceneId == CurrentSceneId)
        {
            LogModule.WarningLog("switch to current scene: " + sceneId);
        }
        LogModule.DebugLog("SceneMgr  SwitchToScene  sceneId:" + sceneId.ToString() + "  " + System.DateTime.Now.ToString());
        mParam = param;

        if (mCurScene != null)
        {
            mCurScene.OnWillExit();
            //App.EventMgr.Post(EventId.SceneWillExit, mCurScene.Id);
        }

        if (mSceneTypeDict.ContainsKey(sceneId))
        {
            mNextScene = Activator.CreateInstance(mSceneTypeDict[sceneId]) as SceneBase;
            if (mNextScene != null)
            {
                mNextScene.OnWillEnter(param);
            }
        }

        if (hdlSceneWillSwitch != null)
        {
            hdlSceneWillSwitch.Invoke(mCurrentSceneId, sceneId, param);
        }

        SceneManager.LoadScene(sceneId.ToString());
    }
    public void SetSceneCross(int sceneId)
    {
        SceneBase scene = scenes [sceneId];

        nextScene = scene;
        if (currentScene != null)
        {
            if (currentScene == scene)
            {
                Debug.Log("Same Scene");
                return;
            }

            currentScene.eventCloseComplete += HandleCurrentSceneEventEndCrossComplete;
            CloseScene(currentScene);

            // set nextScene
            if (nextScene != null)
            {
                OpenScene(nextScene);
            }
        }
        else
        {
            OpenScene(nextScene);
        }
    }
    void OpenScene(SceneBase scene)
    {
        Log("Open: " + scene);
        if (scene == null)
        {
            Log("Wrong Scene");
            return;
        }

        if (!scene.gameObject.activeSelf)
        {
            scene.gameObject.SetActive(true);
        }
        if (!scene.enabled)
        {
            scene.enabled = true;
        }

        scene.Initialization();          // シーンの初期化

        // EVENT / 遷移開始
        if (eventTransition != null)
        {
            eventTransition(scene, TransitionType.OPEN_START);
        }

        openTransitionScene = scene;         // 遷移中のシーン
        currentScene        = null;

        scene.eventOpenComplete += SceneOpenComplete;
        scene.OpenScene();
    }
 void SceneClearComplete(SceneBase scene)
 {
     scene.eventCloseComplete -= SceneClearComplete;
     // 現在のシーンのクローズが完了。
     closeTransitionScene = null;
     CloseSceneComplete(scene);
 }
Exemple #7
0
    public void SwitchScene(SceneType sceneType, params object[] sceneArgs)
    {
        string     name    = sceneType.ToString();
        GameObject scene   = new GameObject(name);
        SceneBase  baseObj = scene.AddComponent(Type.GetType(name)) as SceneBase;

        //baseObj.Init(sceneArgs);
        baseObj.OnInit(sceneArgs);
        if (parentObj != null)
        {
            parentObj = GameObject.Find("UI Root").transform;
        }
        scene.transform.parent = parentObj;


        LayerMgr.GetInstance().SetLayer(baseObj.gameObject, LayerType.Scene);

        scene.transform.localEulerAngles = Vector3.zero;
        scene.transform.localScale       = Vector3.one;
        scene.transform.localPosition    = Vector3.zero;
        if (name.Equals("SceneHome"))
        {
            switchRecorder.Clear();
        }

        switchRecorder.Add(new SwitchRecorder(sceneType, sceneArgs));
        if (current != null)
        {
            GameObject.Destroy(current);
        }

        current = scene;
    }
 public void PopTill(Type sceneType, bool destroy = false, bool include = false)
 {
     while (_stack.Count > 1)
     {
         var scene = pop(false);
         if (scene != null)
         {
             if (scene.GetType() == sceneType)
             {
                 if (!include)
                 {
                     push(scene, false);
                 }
                 else
                 {
                     SceneBase.Destroy(scene);
                 }
                 break;
             }
             else
             {
                 SceneBase.Destroy(scene);
             }
         }
     }
     SwitchScenesActivity();
 }
Exemple #9
0
        public void Update(SceneBase scene, float dt)
        {
            foreach (var entity in scene.Entities)
            {
                var camera = entity.GetComponent <CameraFree>();
                //   var cameraRenderable = entity.GetComponent<CameraRenderable>();
                if (camera != null)
                {
                    //if (camera.CamType == Cam_Type.CA_CHARACTER)
                    //{
                    //    // move the camera smoothly to the goal
                    //    Vector3 goalOffset = camera.CameraGoal.WorldPosition - camera.CameraNode.Position;
                    //    camera.CameraNode.Translate(goalOffset * dt * 9.0f);

                    //    // always look at the pivot
                    //    camera.CameraNode.LookAt(camera.CameraPivot.WorldPosition);

                    //}else if(camera.CamType == Cam_Type.CA_FREE)
                    //{
                    //bool speedmodifier = false;
                    //Vector3 camMovementDir = camera.Camera_GetMove();
                    //camMovementDir = Vector3.Vector3_Normalize(camMovementDir);
                    //camMovementDir *= dt * 10.0f * (1);// + speedmodifier * 5);

                    //camera.Camera_MoveRelative(camMovementDir);


                    //      }
                }
            }
        }
Exemple #10
0
    /// <summary>
    /// 弹出栈顶场景,并将当前场景销毁
    /// </summary>
    public void PopScene()
    {
        if (sceneStack.Count <= 0 || sceneStack.Last == null)
        {
            return;
        }

        SceneBase last    = currentScene;
        SceneBase bePoped = sceneStack.Last.Value;

        if (currentScene != null)
        {
            currentScene.OnDestroy();
        }

        if (bePoped != null)
        {
            bePoped.OnPoped(last);

            bePoped.LoadScene();
            bePoped.UpdateAudioState();
            bePoped.UpdateGlobalLight();

            currentScene = bePoped;
        }

        sceneStack.RemoveLast();
    }
Exemple #11
0
    /// <summary>
    /// 将当前场景入栈,并加载新场景
    /// </summary>
    /// <param name="next">待加载的场景</param>
    public void PushScene(SceneBase next)
    {
        if (next == null)
        {
            Debug.LogWarning("SceneManager.PushScene : Null GameScene.");
            return;
        }

        if (currentScene != null)
        {
            if (currentScene.SNode == next.SNode)
            {
                Debug.LogWarning("SceneManager.PushScene : The Same GameScene.");
                return;
            }

            currentScene.OnPushed(next);
            sceneStack.AddLast(currentScene);
        }

        next.LoadScene();
        next.UpdateAudioState();
        next.UpdateGlobalLight();
        currentScene = next;
    }
    protected IEnumerator SceneLoadCorountine(GameObject sceneObj)
    {
        bool isFade = true;

        StartCoroutine(FadeScene.Instance.FadeOut(() => isFade = false));
        while (isFade)
        {
            yield return(null);
        }
        if (NowScene != null)
        {
            NowScene.Destroy();
        }
        float elapsedTime = Time.time;

        NowScene = Instantiate(sceneObj, SceneRoot.transform).GetComponent <SceneBase>();
        NowScene.Initilize();
        yield return(StartCoroutine(NowScene.DoInitialize()));

        elapsedTime = Time.time - elapsedTime;

        // フェードアニメーションの間隔を最低限あける
        if (elapsedTime < FadeSpaceTime)
        {
            yield return(new WaitForSeconds(FadeSpaceTime - elapsedTime));
        }
        StartCoroutine(FadeScene.Instance.FadeIn(() => isFade = false));
        while (isFade)
        {
            yield return(null);
        }
        NowScene.OnCompleteInitialize();
    }
        public void Process(SceneBase world, int ci, int ri, int hres, int vres)
        {
            Vec2 s = world.ViewPlane.PixelSize / zoom;

            int numSamples = world.ViewPlane.NumSamples;

            Vec3 pixelColor = ColorUtils.BLACK;
            Ray  ray        = new Ray(eye, null);
            Vec2 pp         = new Vec2();
            Vec2 sp;

            for (int r = ri; r < vres; r++)     //up - y height
            {
                for (int c = ci; c < hres; c++) //across - x width
                {
                    pixelColor = ColorUtils.BLACK;

                    for (int j = 0; j < numSamples; j++)
                    {
                        sp          = world.ViewPlane.Sampler.SampleUnitSquare();
                        pp.X        = s.X * (c - 0.5 * world.ViewPlane.Hres + sp.X);
                        pp.Y        = s.Y * (r - 0.5 * world.ViewPlane.Vres + sp.Y);
                        ray.D       = RayDirection(pp);
                        pixelColor += world.Tracer.TraceRay(ray, 0);
                    }

                    pixelColor /= numSamples;
                    pixelColor *= exposureTime;

                    world.DisplayPixel(c, r, pixelColor);
                }
            }
        }
Exemple #14
0
 public void Update(SceneBase scene, float dt)
 {
     foreach (var ent in scene.Entities)
     {
         UpdateActionMap(ent, dt);
     }
 }
 void InitScene(SceneBase sceneBase)
 {
     //创建主角
     //初始化主角
     //var behaviour = LogicMM.mainRole.AddMainRole();
     //behaviour.transform.position = sceneBase.player_pos;
 }
Exemple #16
0
    private void Update()
    {
        for (int i = 0; i < sceneLoaderList.Count; i++)
        {
            SceneLoader loader = sceneLoaderList[i];
            bool        loaded = loader.Update();
            if (loaded)
            {
                SceneDefine.SCENE_ID id         = loader.SceneID;
                UnityScene           unityScene = UnitySceneManager.GetSceneByName(loader.Name);
                SceneBase            scene      = GameObject.Find(unityScene.name).GetComponent <SceneBase>();
                sceneList.Add(scene);

                sceneLoaderList.RemoveAt(i);

                UnitySceneManager.SetActiveScene(unityScene);
                scene.Setup(id, unityScene);
                break;
            }
        }

        for (int i = 0; i < sceneList.Count; i++)
        {
            // アンロード処理
            if (sceneList[i] == null)
            {
                sceneList.RemoveAt(i);
                break;
            }
        }
    }
Exemple #17
0
    /// <summary>
    /// 打开指定场景
    /// </summary>
    /// <param name="sceneType"></param>
    /// <param name="sceneArgs">场景参数</param>
    private void ShowScene(SceneType sceneType, params object[] sceneArgs)
    {
        if (scenes.ContainsKey(sceneType))
        {
            current = scenes[sceneType];
            current.OnShowing();
            current.OnResetArgs(sceneArgs);
            current.gameObject.SetActive(true);
            current.OnShowed();
        }
        else
        {
            if (sceneType == SceneType.None)
            {
                current = null;
                return;
            }

            GameObject go    = new GameObject(sceneType.ToString());
            Type       mType = Type.GetType(sceneType.ToString());
            current = go.AddComponent(mType) as SceneBase;
            current.OnInit(sceneArgs);
            scenes.Add(current.type, current);
            current.OnShowing();
            LayerMgr.GetInstance.SetLayer(current.gameObject, LayerType.Scene);
            go.transform.localPosition(Vector3.zero).localRotation(Quaternion.identity).localScale(1);
            current.OnShowed();
        }
    }
Exemple #18
0
    /// <summary>
    /// シーンロード
    /// </summary>
    private static void LoadSceneAsync(SceneDataPackBase dataPack)
    {
        //Header非表示 ※次のシーンでも表示が続くなら非表示にしない方が良いか?
        SharedUI.Instance.HideHeader();

        //ロード開始
        SceneManager.LoadSceneAsync(dataPack.toSceneName).completed += (op) =>
        {
            //シーン取得
            currentSceneName = dataPack.toSceneName;
            currentScene     = SceneManager
                               .GetSceneByName(currentSceneName)
                               .GetRootGameObjects()
                               .Select(g => g.GetComponent <SceneBase>())
                               .First(s => s != null);

            if (IsAutoHideLoading)
            {
                //シーン移動アニメーション終了
                SharedUI.Instance.HideSceneChangeAnimation();
            }

            //ロード完了通知
            IsLoading = false;
            currentScene.OnSceneLoaded(dataPack);
        };
    }
    public void ChangeScene(eScene scene)
    {
        SceneBase change = null;

        switch (scene)
        {
        case eScene.None:
            break;

        case eScene.MainTown:
            change = new MainScene();
            break;

        case eScene.Battle:

            break;

        default:
            break;
        }

        if (change != null)
        {
            SceneSwitch(change);
        }
    }
Exemple #20
0
        // private SceneBase m_scene;
        public SceneBanner(SceneBase scene, List<string> banList)
        {
            scene.EventManager.OnClientConnect += EventManager_OnClientConnect;

            bans = banList;
            // m_scene = scene;
        }
Exemple #21
0
 // Update is called once per frame
 void Update()
 {
     //arrayPos = i;
     scene  = GameObject.FindGameObjectWithTag("Scenery");
     sceneC = scene.GetComponent <SceneBase> ();
     Actualizar();
 }
Exemple #22
0
 public window()
 {
     Thread.CurrentThread.Name = "Primary - ";
     InitializeComponent();
     sf = new SceneFactory();
     //scene = new SingleSphere(this);
     //scene = sf.CreateMultipleSphere(this);
     //scene = sf.CreateBallsScene2(this);
     //scene = sf.CreateAmbientOcclusion(this);
     //scene = sf.CreateAreaLighting(this);
     //scene = sf.CreateObjectTest(this);
     //scene = sf.CreateEnvironmentLight(this);
     //scene = sf.CreateObjectsSSFloat(this);
     //scene = sf.CreateTriangleScene(this);
     //scene = sf.CreateTorusScene(this);
     //scene = sf.CreateSolidCylinderScene(this);
     //scene = sf.CreateSolidConeScene(this);
     //scene = sf.CreateAnnulusScene(this);
     //scene = sf.CreateBowlScene(this);
     //scene = sf.CreateInstanceScene(this);
     //scene = sf.CreateBeveledCylinderScene(this);
     //scene = sf.CreateRandomSpheres(this);
     //scene = sf.CreateGridAndTransformedObject1(this);
     //scene = sf.CreateGridAndTransformedObject2(this);
     //scene = sf.CreateTessellateSphere(this);
     //scene = sf.CreateReflectiveObjects(this);
     //scene = sf.CreateGlossyReflectorTest1(this);
     //scene = sf.CreatePathTracingTest(this);
     //scene = sf.CreatePerfectTransmitterTest(this);
     //scene = sf.CreateGlobalTraceTest(this);
     //scene = sf.CreateGlassWithLiquid(this);
     scene = sf.CreateEarthScene(this);
 }
Exemple #23
0
    private void ShowScene(SceneType sceneType, params object[] sceneArgs)
    {
        if (scenes.ContainsKey(sceneType))
        {
            currentSceneBase = scenes[sceneType];
            currentSceneBase.OnShowing();
            currentSceneBase.OnResetArgs(sceneArgs);
            currentSceneBase.gameObject.SetActive(true);
            currentSceneBase.OnShowed();
        }
        else
        {
            if (parentObj == null)
            {
                parentObj = UIRoot;
            }
            string name = sceneType.ToString();

            GameObject scene = new GameObject(name);
            UnityHelper.AddUIChildNodeToParentNode(parentObj, scene.transform);
            SceneBase currentScene = scene.AddComponent(Type.GetType(name)) as SceneBase;

            currentSceneBase = currentScene;
            CurrentSceneType = sceneType;

            currentSceneBase.OnInit(sceneArgs);
            currentSceneBase.OnShowing();
            SetLayer(currentSceneBase.gameObject, LayerType.Scene);
            currentSceneBase.OnShowed();
            scenes.Add(sceneType, currentSceneBase);
            switchRecoders.Add(new SwitchRecorder(sceneType, sceneArgs));
        }
    }
Exemple #24
0
    public void GotoScene(string scneneType, Type t = null, Func <SceneBase> func = null, object param = null)
    {
        FairyGUI.GRoot.inst.touchable = false;
        SceneBase scene = GetScnene(scneneType);

        if (func == null)
        {
            func = () =>
            {
                return(Activator.CreateInstance(t) as SceneBase);
            };
        }
        if (scene == null)
        {
            scene           = func();
            scene.SceneName = scneneType;
            mScenes.Add(scneneType, scene);
        }
        if (currentScene != null && scneneType == currentScene.SceneName)
        {
            Debug.LogError("当前场景和要到的目标场景重复" + scneneType);
            currentScene.Enter(param);
        }
        else
        {
            if (currentScene != null)
            {
                currentScene.Leave();
                oldScenes.Enqueue(currentScene);
            }
            currentScene = mScenes[scneneType];
            currentScene.Enter(param);
        }
    }
Exemple #25
0
        public SceneBanner(SceneBase scene, List <string> banList)
        {
            scene.EventManager.OnClientConnect += EventManager_OnClientConnect;

            bans    = banList;
            m_scene = scene;
        }
Exemple #26
0
    /// <summary>
    /// UI를 만드는 함수
    /// UI를 만들고 Scene과 UI를 서로 연결
    /// </summary>
    /// <typeparam name="T"></typeparam>
    /// <param name="scene"></param>
    /// <returns></returns>
    public T CreateUI <T>(SceneBase scene) where T : UIBase, new()
    {
        var newUI = new T();

        scene.CurrentUI    = newUI;
        newUI.CurrentScene = scene;

        newUI.Start();

        switch (newUI.Type())
        {
        case UI_TYPE.PAGE:
        {
            _currentPage = newUI;
            _mapPageStack.Add(_currentPage, new List <UIBase>());
        }
        break;

        case UI_TYPE.STACK: { _mapPageStack[_currentPage].Add(newUI); } break;

        case UI_TYPE.POPUP: { _listPopup.Add(newUI); } break;

        default: break;
        }
        return(newUI);
    }
Exemple #27
0
    public IEnumerator LoadScene(string nextScene)
    {
        Scene curScene = SceneManager.GetActiveScene();

        if (string.IsNullOrEmpty(nextScene) || m_isLoading || curScene.name.Equals(nextScene))
        {
            yield break;
        }

        m_isLoading = true;

        SceneManager.LoadScene(SceneConst.SceneName, LoadSceneMode.Additive);

        yield return(StartCoroutine(AsyncLoadScene(nextScene)));

        FreshProcessEvent.Invoke(SceneConst.LOADSCENEPROCESS);
        m_unloadAsync = SceneManager.UnloadSceneAsync(curScene);

        /*
         * //使用LoadSceneMode.Additive进行场景切换,无法完全释放资源。即使使用Resources.UnloadUnusedAssets()也不行
         * //可能出现如下情况:
         * //1.资源没有引用了,但是还没有回收
         * //2.被UnityEngine.EventSystems.StandaloneInputModule和UnityEngine.EventSystems引用
         * //当然如果单纯从一个场景切换另外一个场景,直接使用UnityEngine.SceneManagement.SceneManager.LoadScene("xxx")
         * //直接切换场景,这个会进行内存回收
         */
        yield return(m_unloadAsync);

        FreshProcessEvent.Invoke(SceneConst.UNSCENEPROCESS);
        //场景中必须有一个对象挂载SceneBase
        SceneBase sceneLoader = UnityTool.GetTopObject("SceneLoader").GetComponent <SceneBase>();

        if (sceneLoader == null)
        {
            Debug.LogError("lack of gameobject of name 'SceneLoader'");
            yield break;
        }

        yield return(new WaitUntil(sceneLoader.FinishConfigRes));

        FreshProcessEvent.Invoke(SceneConst.INITNETPROCESS);

        yield return(new WaitUntil(sceneLoader.FinishGetData));

        FreshProcessEvent.Invoke(SceneConst.INITCONFIGPROCESS);

        yield return(new WaitUntil(sceneLoader.FinishInit));

        FreshProcessEvent.Invoke(SceneConst.INITSCENEPROCESS);

        yield return(new WaitForSeconds(1f));

        FreshProcessEvent.Invoke(1f);
        m_loadAsync = SceneManager.UnloadSceneAsync(SceneConst.SceneName);

        yield return(m_loadAsync);

        m_isLoading = false;
    }
Exemple #28
0
 /// <summary>
 /// 同ReplaceScene,但将栈清空
 /// </summary>
 /// <param name="target"></param>
 public void SetScene(SceneBase target)
 {
     if (target != null)
     {
         ReplaceScene(target);
         sceneStack.Clear();
     }
 }
Exemple #29
0
    public void ChangeScene <T>() where T : SceneBase
    {
        Assembly assembly = Assembly.GetExecutingAssembly(); // 获取当前程序集

        m_curScene = (T)assembly.CreateInstance(typeof(T).ToString());

        m_curScene.Init();
    }
Exemple #30
0
        public void LoadScene(int sceneNo)
        {
            SceneBase scene;

            switch (sceneNo)
            {
            case 0:
                scene = new SceneRandom();
                break;

            case 1:
                scene = new SceneFire();
                break;

            case 2:
                scene = new SceneTwinkle();
                break;

            case 3:
                scene = new SceneOcean();
                break;

            case 4:
                scene = new SceneRainbow();
                break;

            case 5:
                scene = new SceneJuly();
                break;

            case 6:
                scene = new SceneHoliday();
                break;

            case 7:
                scene = new ScenePop();
                break;

            case 8:
                scene = new SceneForest();
                break;

            default:
                scene = null;
                break;
            }

            if (scene == null)
            {
                return;
            }
            CurrentScene  = scene;
            colors        = scene.GetColors();
            animationTime = scene.AnimationTime;
            mode          = scene.Mode;
            startInt      = 0;
            RefreshColors(colors);
        }
 public void Pop(SceneBase scene)
 {
     if (_stack.Contains(scene))
     {
         _stack.Remove(scene);
         scene.Enabled = false;
         SwitchScenesActivity();
     }
 }
Exemple #32
0
        public void Add(SceneBase scene, bool initializeAndLoadContent = false)
        {
            if (initializeAndLoadContent)
            {
                scene.Initialize(context);
                scene.LoadContent();
            }

            Scenes.Add(scene);
        }
Exemple #33
0
    public virtual void initialize()
    {
        // base initialization
        currentSceneGameObject = gameObject;
        currentSceneClass = this;

        // add audio listner
        gameObject.AddComponent<AudioListener>();

        // create UI Manager
        uiManager = UIManager.createNewInstance();
    }
Exemple #34
0
        public void AddChild(SceneBase parent, SceneBase child, bool initializeAndLoadContent = false)
        {
            child.Parent = parent;

            if (initializeAndLoadContent)
            {
                child.Initialize(context);
                child.LoadContent();
            }

            parent.SceneChildren.Add(child);
        }
Exemple #35
0
        public void Remove(SceneBase scene)
        {
            // Remove a root scenes
            if (scene.Parent == null)
            {
                for (int i = 0; i < Scenes.Count; i++)
                {
                    var currentScene = Scenes[i];

                    // Remove the scene
                    if (scene == currentScene)
                    {
                        scene.UnloadContent();
                        Scenes.Remove(scene);
                        break;
                    }
                }
            }
            // Remove a child scene
            else
            {
                for (int i = 0; i < Scenes.Count; i++)
                {
                    var currentScene = Scenes[i];

                    // Remove the scene if found as a child-scene to the current scene
                    for (int j = 0; j < currentScene.SceneChildren.Count; j++)
                    {
                        var child = currentScene.SceneChildren[j];

                        if (scene == child)
                        {
                            scene.UnloadContent();
                            currentScene.SceneChildren.Remove(scene);
                            break;
                        }
                    }
                }
            }
        }
Exemple #36
0
 /// <summary>
 /// 场景入栈时操作
 /// </summary>
 /// <param name="next">下一个场景</param>
 public virtual void OnPushed(SceneBase next)
 {
 }
Exemple #37
0
 /// <summary>
 /// 场景出栈时操作
 /// </summary>
 /// <param name="last">上一个场景</param>
 public virtual void OnPoped(SceneBase last)
 {
 }
Exemple #38
0
 /// <summary>
 /// Show assigned scene
 /// </summary>
 private void ShowScene(SceneType sceneType, params object[] sceneArgs)
 {
     if(scenes.ContainsKey(sceneType)){
         current = scenes[sceneType];
         current.OnShowing();
         current.OnResetArgs(sceneArgs);
         NGUITools.SetActive(current.gameObject, true);
         current.OnShowed();
     }
     else{
         GameObject go = new GameObject(sceneType.ToString());
         //sceneType.tostring = classname for current scene
         current = UnityEngineInternal.APIUpdaterRuntimeServices.AddComponent(go, "Assets/Script/Core/View/SceneMgr.cs (120,14)", sceneType.ToString()) as SceneBase;
         current.OnInit(sceneArgs);
         scenes.Add(current.type, current);
         current.OnShowing();
         LayerMgr.GetInstance().SetLayer(current.gameObject, LayerType.Scene);
         go.transform.localScale = Vector3.one;
         go.transform.localRotation = Quaternion.identity;
         current.OnShowed();
     }
 }
Exemple #39
0
 private static SceneItem LoadCompositeEntity(XmlNode node, SceneBase scene)
 {
     TraceLogger.TraceInfo("Beginning LoadCompositeAnimation");
     _storedScene = scene as IceScene;
     CompositeEntity _compositeEntity = new CompositeEntity();
     LoadBaseSceneItem(node, _compositeEntity);            
     XmlNode _node = node.SelectSingleNode("CompositeEntityData");
     SetProperty("SceneItemBank", _compositeEntity, _node);
     SetProperty("RootBone", _compositeEntity, _node);
     SetProperty("Animations", _compositeEntity, _node);
     SetIAnimationDirectorProperties(_node, _compositeEntity as IAnimationDirector);
     TraceLogger.TraceInfo("Ending LoadCompositeEntity");
     return _compositeEntity;
 }
Exemple #40
0
        private static SceneItem LoadParticleEffect(XmlNode node, SceneBase scene)
        {
            TraceLogger.TraceInfo("Beginning LoadParticleEffect");

            ParticleEffect _particle = new ParticleEffect();
            LoadBaseSceneItem(node, _particle);

            XmlNode emitterNode = node.SelectSingleNode("Emitter");
            if (emitterNode != null)
            {
                LoadEmitter(emitterNode, _particle, scene);
            }
            SetProperty("EditorBackgroundColor", _particle, node);
            SetIAnimationProperties(node, _particle);

            TraceLogger.TraceInfo("Ending LoadParticleEffect");
            return _particle;
        }
Exemple #41
0
 private static XmlNode WriteSceneComponents(XmlDocument doc, SceneBase scene)
 {
     XmlNode _componentsNode = doc.CreateElement(NodeNames.COMPONENTS);
     foreach (var comp in scene.SceneComponents)
     {
         XmlNode _componentNode = doc.CreateElement(comp.GetType().FullName);
         WriteSceneComponent(_componentNode, comp, doc);
         _componentsNode.AppendChildIfNotNull(_componentNode);
     }
     return _componentsNode;
 }
Exemple #42
0
 private static Material GetMaterialAssetFromNode(XmlNode node, SceneBase scene)
 {
     string _materialSource = node.Attributes["materialSource"].InnerText;
     string _matRef = "";
     if (node.Attributes["materialRef"] != null)
         _matRef = node.Attributes["materialRef"].InnerText;
     else
         _matRef = node.InnerText;
     if (_materialSource.ToUpper() == "LOCAL")
         return scene.GetMaterial(_matRef);
     else if (_materialSource.ToUpper() == "GLOBAL")
         return SceneManager.GlobalDataHolder.GetMaterial(_matRef);
     else if (_materialSource.ToUpper() == "EMBEDDED")
         return SceneManager.GetEmbeddedMaterial(_matRef);
     else
         return null;
 }
Exemple #43
0
        public static void DeSerializeScene(String filename, String contentRoot, SceneBase scene)
        {
            Console.WriteLine("**************************************************");
            Console.WriteLine("Deserializing scene");
            Console.WriteLine(filename);
            Console.WriteLine("**************************************************");

            _loadingScene = scene;
            scene.SceneComponents.Clear();
            scene.Fonts.Clear();
            scene.SceneItems.Clear();
            scene.Materials.Clear();
            scene.TemplateItems.Clear();            

            FireStatusUpdate("Loading File", 50);
            StreamReader _sr = new StreamReader(filename);
            XmlDocument doc = new XmlDocument();
            doc.Load(_sr);

            if (scene is GlobalDataHolder)
            {
                GlobalDataHolder gdh = scene as GlobalDataHolder;
                XmlNode _resNode = doc.SelectSingleNode("IceScene/NativeResolution");
                if (_resNode != null)
                {
                    gdh.NativeResolution = new Point(
                        Int32.Parse(_resNode.SelectSingleNode("X").InnerText, CultureInfo.InvariantCulture),
                        Int32.Parse(_resNode.SelectSingleNode("Y").InnerText, CultureInfo.InvariantCulture));
                }
            }
            TraceLogger.TraceInfo("LOADING ASSETS");
            FireStatusUpdate("Loading Assets", 100);
            LoadAssets(doc, scene);

            TraceLogger.TraceInfo("LOADING SCENE COMPONENTS");
            FireStatusUpdate("Loading Scene Components", 0);
            LoadSceneComponents(doc, scene);

            TraceLogger.TraceInfo("LOADING SCENE ITEMS");

            FireStatusUpdate("Loading Scene Items", 0);
            LoadSceneItems(doc, scene);

            TraceLogger.TraceInfo("LOADING SCENE TEMPLATE ITEMS");

            FireStatusUpdate("Loading Scene Templates", 0);
            LoadTemplateItems(doc, scene);

            FireStatusUpdate("Loading Scene Templates", 100);
            _sr.Close();
            _sr.Dispose();
            _sr = null;
            doc = null;

        }
Exemple #44
0
 private static XmlNode WriteTemplateItems(XmlDocument doc, SceneBase scene)
 {
     XmlNode _templatesNode = doc.CreateElement(NodeNames.TEMPLATES);
     WritesSceneCollection(doc, _templatesNode, scene.TemplateItems);
     return _templatesNode;
 }
Exemple #45
0
        public static void SerializeScene(SceneBase scene, string filename)
        {
            try
            {
                XmlDocument _doc = new XmlDocument();
                XmlNode _rootNode = _doc.CreateElement(NodeNames.ICESCENE);
                _doc.AppendChild(_rootNode);
                if (scene.Equals(SceneManager.GlobalDataHolder))
                {
                    GlobalDataHolder globalDataHolder = scene as GlobalDataHolder;
                    XmlNode _res = _doc.CreateElement("NativeResolution");
                    _res.AppendChild(_doc.CreateElement("X")).InnerText = globalDataHolder.NativeResolution.X.ToString();
                    _res.AppendChild(_doc.CreateElement("Y")).InnerText = globalDataHolder.NativeResolution.Y.ToString();
                    _rootNode.AppendChild(_res);
                }
                _rootNode.AppendChildIfNotNull(WriteAssets(_doc, scene));
                _rootNode.AppendChildIfNotNull(WriteSceneComponents(_doc, scene));
                _rootNode.AppendChildIfNotNull(WriteSceneItems(_doc, scene));
                _rootNode.AppendChildIfNotNull(WriteTemplateItems(_doc, scene));

                _doc.Save(filename);
                _doc = null;
            }
            catch (Exception err)
            {
                throw err;
            }
        }
Exemple #46
0
 private static TileSheet LoadTileSheet(XmlNode _node, SceneBase scene)
 {
     TileSheet tileSheet = new TileSheet();            
     tileSheet.Material = GetMaterialAssetFromNode(_node, scene);
     SetProperty("EnableCollisionByDefault", tileSheet, _node);
     SetProperty("TileSize", tileSheet, _node);
     SetProperty("Polygons", tileSheet, _node);
     tileSheet.CreateFlippedPolygons();
     return tileSheet;
 }
Exemple #47
0
 private static XmlNode WriteSceneItems(XmlDocument doc, SceneBase scene)
 {
     XmlNode _sceneItemsNode = doc.CreateElement(NodeNames.SCENEITEMS);
     WritesSceneCollection(doc, _sceneItemsNode, scene.SceneItems);
     return _sceneItemsNode;
 }
Exemple #48
0
        private static void LoadAssets(XmlDocument doc, SceneBase scene)
        {
            string _lastValidName = "";
            try
            {
                XmlNode _el = doc.SelectSingleNode("IceScene/Assets");
                int _count = _el.ChildNodes.Count;
                int _current = 0;
                foreach (XmlNode _node in _el.ChildNodes)
                {
                    _current++;
                    int perc = (int)((double)_current / (double)_count * 100); ;
                    FireStatusUpdate(string.Format("Loading Asset {0}/{1}", _current, _count), perc);

                    IceAsset asset = null;
                    if (_node.Name.ToUpper() == "MATERIAL")
                    {
                        Material newMat = new Material();
                        asset = newMat;
                        scene.Materials.Add(newMat);
                        TraceLogger.TraceInfo("Loading Material");
                        if (_node.Attributes.GetNamedItem("areas_definition") != null)
                        {
                            newMat.AreasDefinitionFilename
                                = _node.Attributes["areas_definition"].InnerText;
                            String definitionPath = Path.Combine(SceneSerializer.RootPath, newMat.AreasDefinitionFilename);
                            TraceLogger.TraceVerbose("Loading AreasDefinitionFilename: " + newMat.AreasDefinitionFilename);
                            newMat.LoadAreasDefinition(definitionPath);
                        }
                    }
                    else if (_node.Name.ToUpper() == "FONT")
                    {
                        asset = new IceFont();
                        scene.Fonts.Add(asset as IceFont);
                        TraceLogger.TraceInfo("Loading Font");
                    }
                    else if (_node.Name.ToUpper() == "EFFECT")
                    {
						#if !XNATOUCH
                        asset = CreateEffectInstance(_node.Attributes["type"].InnerText);
                        scene.Effects.Add(asset as IceEffect);
                        TraceLogger.TraceInfo("Loading Effect");
#endif
                    }
                    else if (_node.Name.ToUpper() == "TILESHEET")
                    {
                        TileSheet newTileSheet = LoadTileSheet(_node, scene);
                        asset = newTileSheet;
                        scene.TileSheets.Add(newTileSheet);                       
                        TraceLogger.TraceInfo("Loading TileSheet");
                    }
                    asset.Scope = AssetScope.Local;
                    if (scene == SceneManager.GlobalDataHolder)
                    {
                        asset.Scope = AssetScope.Global;
                    }
                    asset.Parent = scene;
                    asset.Name = _node.Attributes["name"].InnerText;
                    _lastValidName = asset.Name;
                    if (_node.Attributes.GetNamedItem("location") != null)
                    {
                        asset.Filename = _node.Attributes["location"].InnerText;
                    }
                    else
                    {
                        asset.Filename = "";
                    }
                    TraceLogger.TraceInfo("Name : " + asset.Name);
                    TraceLogger.TraceVerbose("FileName : " + asset.Filename);
                    TraceLogger.TraceVerbose("Scope : " + asset.Scope.ToString());
                }
            }
            catch (Exception err)
            {
                if (err != null)
                {
                    #if(WINDOWS)
                    Trace.TraceError("ERROR In Load Assets - " + _lastValidName);
                    #endif
                    throw new ArgumentException("Error in load materials: " + err.Message);
                }
            }
        }
Exemple #49
0
 /// <summary>
 /// 场景被替换时操作
 /// </summary>
 /// <param name="next"></param>
 public virtual void OnReplaced(SceneBase next)
 {
 }
Exemple #50
0
 private static TileSheet LoadTileSheetFromNode(XmlNode _node, SceneBase scene, SceneItem item)
 {
     if (_node.Attributes.GetNamedItem("tileSheetSource") != null
         && _node.Attributes.GetNamedItem("tileSheetRef") != null)
     {
         String tileScope = _node.Attributes["tileSheetSource"].InnerText;
         String tileRef = _node.Attributes["tileSheetRef"].InnerText;
         TileSheet returnTilesheet = null;
         if (tileScope.ToUpper() == "LOCAL")
         {
             returnTilesheet = scene.GetTileSheet(tileRef);
         }
         else if (tileScope.ToUpper() == "GLOBAL")
         {
             returnTilesheet = SceneManager.GlobalDataHolder.GetTileSheet(tileRef);
         }
         if (returnTilesheet != null)
         {
             return returnTilesheet;
         }
         else
         {
             throw new Exception("The SceneItem \"" + item.Name + "\" is trying to use an invalid TileSheet: ["
                 + tileScope.ToUpper() + "] \"" + tileRef + "\"");
         }
     }
     else
     {
         return null;
     }
 }
Exemple #51
0
        private static XmlNode WriteAssets(XmlDocument doc, SceneBase scene)
        {
            XmlNode assetsNode = doc.CreateElement(NodeNames.ASSETS);
            XmlNode assetNode = null;
            foreach (Material mat in scene.Materials)
            {
                assetNode = doc.CreateElement(NodeNames.MATERIAL);
                WriteMaterial(doc, assetNode, mat);
                assetsNode.AppendChildIfNotNull(assetNode);
            }
            foreach (IceFont font in scene.Fonts)
            {
                assetNode = doc.CreateElement(NodeNames.FONT);
                SerializeAsset(doc, assetNode, font);
                assetsNode.AppendChildIfNotNull(assetNode);
            }
			#if !XNATOUCH
            foreach (IceEffect mat in scene.Effects)
            {
                assetNode = doc.CreateElement("Effect");
                SerializeAsset(doc, assetNode, mat);
                string name = mat.Effects[0].GetType().Name;
                assetNode.Attributes.Append(doc.CreateAttribute("type")).InnerText = mat.GetType().FullName;
                assetsNode.AppendChildIfNotNull(assetNode);
            }
#endif
            foreach (TileSheet tileSheet in scene.TileSheets)
            {
                assetNode = doc.CreateElement(NodeNames.TILESHEET);
                WriteTileSheet(assetNode, doc, tileSheet);
                assetsNode.AppendChildIfNotNull(assetNode);
            }
            return assetsNode;
        }
Exemple #52
0
 private static Material LoadMaterialFromNode(XmlNode _node, SceneBase scene, SceneItem item)
 {
     String _materialSource = _node.Attributes["materialSource"].InnerText;
     String _materialRef = _node.Attributes["materialRef"].InnerText;
     Material _returnMaterial = null;
     if (_materialSource.ToUpper() == "LOCAL")
     {
         _returnMaterial = scene.GetMaterial(_materialRef);
     }
     else if (_materialSource.ToUpper() == "GLOBAL")
     {
         _returnMaterial = SceneManager.GlobalDataHolder.GetMaterial(_materialRef);
     }
     else if (_materialSource.ToUpper() == "EMBEDDED")
     {
         _returnMaterial = SceneManager.GetEmbeddedMaterial(_materialRef);
     }
     if (_returnMaterial != null)
     {
         return _returnMaterial;
     }
     else
     {
         throw new Exception("The SceneItem \"" + item.Name + "\" is trying to use an invalid material: ["
             + _materialSource.ToUpper() + "] \"" + _materialRef + "\"");
     }
 }
Exemple #53
0
        private static void LoadSceneComponents(XmlDocument doc, SceneBase scene)
        {
            XmlNode _componentsNode = doc.SelectSingleNode("IceScene/Components");
            if (_componentsNode == null)
                return;

            List<IceSceneComponent> _components = new List<IceSceneComponent>();
            foreach (XmlNode _compNode in _componentsNode.ChildNodes)
            {
                TraceLogger.TraceInfo("Loading Scene Component Of Type" + _compNode.Name);

                IceSceneComponent _comp = CreateSceneComponentInstance(_compNode.Name);
                if (_comp != null)
                {
                    foreach (XmlNode nd1 in _compNode)
                    {
                        SetProperty(nd1.Name, _comp, _compNode);
                    }

                    _comp.SetOwner(scene as IceScene);
                    _components.Add(_comp);
                }
            }
            scene.SceneComponents = _components;
        }
Exemple #54
0
        private static void LoadEmitter(XmlNode emitterNode, ParticleEffect particle, SceneBase scene)
        {
            try
            {
                TraceLogger.TraceInfo("Beginning LoadEmitter");

                particle.Emitter = new IceCream.SceneItems.ParticlesClasses.Emitter();


                XmlDocument doc = new XmlDocument();
                doc.LoadXml(emitterNode.OuterXml);
                XmlReaderSettings sett = new XmlReaderSettings();
                StringReader stringReader = new StringReader(emitterNode.OuterXml);
                XmlTextReader xmlReader = new XmlTextReader(stringReader);

                XmlSerializer ser = new XmlSerializer(typeof(Emitter));
                particle.Emitter = (Emitter)ser.Deserialize(xmlReader);

                XmlNode _types = emitterNode.SelectSingleNode("ParticleTypes");
                if (_types != null)
                {
                    int i = 0;
                    foreach (XmlNode _type in _types.ChildNodes)
                    {
                        ParticleType ptype = particle.Emitter.ParticleTypes[i];
                        XmlNode _matNode = _type.SelectSingleNode("Material");
                        if (_matNode != null)
                        {
                            ptype.Material = GetMaterialAssetFromNode(_matNode, scene);
                            if (ptype.Material == null)
                                throw new Exception("Material Not Found For " + particle.Name);
                        }
                        else
                        {
                            ptype.Material = SceneManager.GetEmbeddedParticleMaterial();
                            TraceLogger.TraceWarning("Particle Effect Node Type Has No Material Set");
                        }
                        i++;
                    }
                }
                TraceLogger.TraceInfo("Ending LoadEmitter");
            }
            catch (Exception err)
            {
                TraceLogger.TraceError("Error Occurred In LoadEmitter" + Environment.NewLine + err.ToString());
                throw err;
            }
        }
Exemple #55
0
        private static void LoadSceneItems(XmlDocument doc, SceneBase scene)
        {
            try
            {
                XmlNode _el = doc.SelectSingleNode("IceScene/SceneItems");
                LoadSceneCollection(scene, _el, scene.SceneItems);

            }
            catch (Exception err)
            {
                throw new ArgumentException("Error in load scene items: " + err);
            }
        }
Exemple #56
0
        private static void LoadSceneCollection(SceneBase scene, XmlNode _el, List<SceneItem> sceneitems)
        {
            try
            {
                int _count = _el.ChildNodes.Count;
                int _current = 0;

                foreach (XmlNode _node in _el.ChildNodes)
                {
                    _current++;
                    int perc = (int)((double)_current / (double)_count * 100);
                    FireStatusUpdate(string.Format("Loading Scene Item {0}/{1}", _current, _count), perc);

                    SceneItem _item = null;
                    //string _type = _node.Name;
                    _item = LoadSceneItem(_node, scene as IceScene);
                    sceneitems.Add(_item);
                }
            }
            catch (Exception e)
            {
                TraceLogger.TraceError("Error occurred in LoadSceneCollection" + Environment.NewLine + e.ToString());
                throw;
            }
        }
Exemple #57
0
        private static TextItem LoadTextItem(XmlNode node, SceneBase scene)
        {
            TraceLogger.TraceInfo("Loading TextItem");
            TextItem _textItem = new TextItem();
            LoadBaseSceneItem(node, _textItem);

            _textItem.Font = LoadFontFromNode(node, scene);

            SetProperty("Text", _textItem, node);
            SetProperty("AutoCenterPivot", _textItem, node);
            SetProperty("Shadow", _textItem, node);
            SetProperty("Tint", _textItem, node);
            return _textItem;
        }
Exemple #58
0
 private static AnimatedSprite LoadAnimatedSprite(XmlNode _node, SceneBase scene)
 {
     try
     {
         TraceLogger.TraceInfo("Beginning Serialize AnimatedSprite");
         AnimatedSprite _sprite = new AnimatedSprite();
         LoadBaseSceneItem(_node, _sprite);
         SetIAnimationDirectorProperties(_node, _sprite);
         _sprite.Material = GetMaterialAssetFromNode(_node, scene);
         TraceLogger.TraceInfo("Loading AnimationInfo Data");
         XmlNode _anList = _node.SelectSingleNode("Animations");
         if (_anList != null)
         {
             foreach (XmlNode item in _anList.ChildNodes)
             {
                 _sprite.AddAnimation(GetAnimationInfoFromNode(item));
             }
         }
         TraceLogger.TraceInfo("Ending Serialize AnimatedSprite");
         return _sprite;
     }
     catch (Exception err)
     {
         string errMessage = "Error Occurred In LoadAnimatedSprite";
         errMessage += Environment.NewLine + _node.InnerText;
         TraceLogger.TraceError(errMessage);
         throw new InvalidOperationException(errMessage, err);
     }
 }
Exemple #59
0
 private static Sprite LoadSprite(XmlNode _node, SceneBase scene)
 {
     TraceLogger.TraceInfo("Loading Sprite");
     Sprite _sprite = new Sprite();
     LoadBaseSceneItem(_node, _sprite);
     _sprite.Material = LoadMaterialFromNode(_node, scene, _sprite);
     if (_node.Attributes.GetNamedItem("materialArea") != null)
     {
         _sprite.MaterialArea = _node.Attributes["materialArea"].InnerText;
     }
     else
     {
         SetProperty("SourceRectangle", _sprite, _node);
     }
     return _sprite;
 }
Exemple #60
0
        private static IceFont LoadFontFromNode(XmlNode _node, SceneBase scene)
        {
            string _materialSource = _node.Attributes["fontSource"].InnerText;
            if (_materialSource.ToUpper() == "LOCAL")
                return scene.GetFont(_node.Attributes["fontRef"].InnerText);
            else if (_materialSource.ToUpper() == "GLOBAL")
                return SceneManager.GlobalDataHolder.GetFont(_node.Attributes["fontRef"].InnerText);
            else if (_materialSource.ToUpper() == "EMBEDDED")
                return SceneManager.GetEmbeddedFont(_node.Attributes["fontRef"].InnerText);
            else
                return null;

        }