Ejemplo n.º 1
0
    // 登记所有的场景处理器
    private static void RegisterScene()
    {
        SceneM.RegisterScene(CombatScene.GetSceneName(), new CombatScene());
        SceneM.RegisterScene(MainTownScene.GetSceneName(), new MainTownScene());
        SceneM.RegisterScene(ViewStageScene.GetSceneName(), new ViewStageScene());
        SceneM.RegisterScene(TreasureScene.GetSceneName(), new TreasureScene());

        SceneM.RegisterLoadingAnim(CombatScene.GetSceneName(), new LoadingMainTown());
        SceneM.RegisterLoadingAnim(MainTownScene.GetSceneName(), new LoadingMainTown());
        SceneM.RegisterLoadingAnim(ViewStageScene.GetSceneName(), new LoadingMainTown());
        SceneM.RegisterLoadingAnim(TreasureScene.GetSceneName(), new LoadingMainTown());
    }
Ejemplo n.º 2
0
 /// <summary>
 /// 0702 获取所有已造建筑回应
 /// </summary>
 /// <param name="Info"></param>
 void CanCombat(int nErrorCode)
 {
     DataCenter.AntiRegisterHooks((int)gate.Command.CMD.CMD_702, CanCombat);
     if (nErrorCode == 0)
     {
         NGUIUtil.DebugLog("2:收到702 获取所有建筑请求 回应" + Time.time, "yellow");
         SceneM.Load(CombatScene.GetSceneName(), false, null, false);
     }
     else
     {
         Debug.Log("获取数据失败:" + nErrorCode.ToString());
     }
 }
Ejemplo n.º 3
0
    void ClickCombat(UIButton sender)
    {
        CounterPartInfo Info = StageDC.GetCounterPartInfo();

        if (Info == null)
        {
            return;
        }
        if (m_type != StageType.Normal)
        {
            int Times = StageDC.GetPassStageTimes(m_type, m_stageid);
            if (Times >= Info.times)
            {
                NGUIUtil.ShowTipWndByKey("88800031", 2);
                return;
            }
        }
        if (StageDC.GetPveMode() == PVEMode.Defense)
        {
            SoundPlay.PlayBackGroundSound("bgm_battle_loop", true, false);
            ShipCanvasInfo     Canvas   = new ShipCanvasInfo();
            List <SoldierInfo> lSoldier = new List <SoldierInfo>();
            List <ShipPutInfo> lBuild   = new List <ShipPutInfo>();
            ShipPlanDC.SetCurShipPlan(PlanType.Default);
            ShipPlan Plan = ShipPlanDC.GetCurShipPlan();
            Plan.GetShipCansInfoPlan(ref Canvas, ref lSoldier, ref lBuild);
            CmCarbon.SetDefenseMap(Canvas);
            CmCarbon.SetDefenseBuild(lBuild);
            CmCarbon.SetDefenseSoldier(lSoldier);
            CmCarbon.SetDefenseFloor(UserDC.GetDeckLevel());
            CmCarbon.SetDefenseUserInfo(Info, null);
            List <int> l = new List <int>();
            foreach (SoldierInfo s in lSoldier)
            {
                l.Add(s.ID);
            }
            sender.enabled = false;
            //DataCenter.RegisterHooks((int)gate.Command.CMD.CMD_702, CanCombat);
            //StageDC.SendStageAttackRequest(m_stageid, l, 0);
            SceneM.Load(CombatScene.GetSceneName(), false, false);
        }
        else
        {
            sender.enabled = false;
            //SoldierDC.Send_SoldierBattleListRequest(0);
            //DataCenter.RegisterHooks((int)gate.Command.CMD.CMD_214, LoadStage);
            SceneM.Load(CombatScene.GetSceneName(), false, false);
        }
    }
Ejemplo n.º 4
0
 //private AsyncOperation async;
 /// <summary>
 /// 资源载入入口
 /// </summary>
 public override IEnumerator Load()
 {
     async = Application.LoadLevelAsync(CombatScene.GetSceneName());
     return(null);
     //yield return async;
 }
Ejemplo n.º 5
0
 void LoadStage(int nErrorCode)
 {
     SceneM.Load(CombatScene.GetSceneName(), false, false);
     DataCenter.AntiRegisterHooks((int)gate.Command.CMD.CMD_214, LoadStage);
 }
Ejemplo n.º 6
0
    // 异步载入场景
    private static IEnumerator NonsyncLoad(string sceneName, ILoading loading)
    {
        App.log.Trace("SceneM.cs", "开始异步载入场景{0}", sceneName);



        // 取得载入器
        IScene scene = sceneLoadControl[sceneName];

        s_preScene      = s_CurIScene;
        s_loadingIScene = scene;

        // 1 播放开始载入的动画,并等待其播放完毕
        if (loading != null)
        {
            App.log.Trace("SceneM.cs", "播放载入开始动画");
            loading.FadeIn();
            while (loading.IsFadingIn())
            {
                yield return(null);
            }
        }

        // 欲载入的处理
        scene.PrepareLoad();


        // 2 产生事件并清理旧的场景
        if (eventUnload != null)
        {
            eventUnload(s_preScene);
        }
        if (s_preScene != null)
        {
            s_preScene.Clear();
        }



        // 3 载入新的场景
        scene.Load();

        if (sceneLoadingAnim.ContainsKey(sceneName))
        {
            sceneLoadingAnim[sceneName].SetAsyncLoading(scene.AsyncLoading);
        }

        if (sceneLoadControl.ContainsKey(CombatScene.GetSceneName()))
        {
            IScene sceneCombat = sceneLoadControl[CombatScene.GetSceneName()];
            // 清理内存资源
            if (scene != sceneCombat && s_preScene != sceneCombat)
            {
                Resources.UnloadUnusedAssets();
                System.GC.Collect();
            }
        }

        // 1 播放开始载入的动画,并等待其播放完毕
        if (loading != null)
        {
            App.log.Trace("SceneM.cs", "播放载入开始动画");
            loading.Load();
            while (loading.IsLoading())
            {
                yield return(null);
            }
        }
        yield return(new WaitForMSeconds(100f));


        // 等待载入完成
        while (!scene.IsEnd())
        {
            yield return(null);
        }

        // 场景载入完成(一定要在load完毕后才能替换,此时的环境才能称得上载入完成)
        s_CurIScene = scene;


        bLoading = false;

        // 6 发出载入完毕的事件
        if (eventLoaded != null)
        {
            eventLoaded(scene);
        }
        //载入完成。
        scene.BuildScene();
        scene.Start();

        // 4 播放载入完成的动画,并等待其播放完毕
        if (loading != null)
        {
            App.log.Trace("SceneM.cs", "播放载入完成动画");
            loading.FadeOut();
            while (loading.IsFadingOut())
            {
                yield return(null);
            }

            loading.TryDestroy();
        }

        // 载入完成
        App.log.Trace("SceneM.cs", "异步载入场景{0}完成", sceneName);
    }