Exemplo n.º 1
0
        public static async ETVoid EnterMapAsync(string sceneName)
        {
            try
            {
                // 加载Unit资源
                ResourcesComponent resourcesComponent = ET.Game.Scene.GetComponent <ResourcesComponent>();
                await resourcesComponent.LoadBundleAsync($"unit.unity3d");

                // 加载场景资源
                await ET.Game.Scene.GetComponent <ResourcesComponent>().LoadBundleAsync("map.unity3d");

                // 切换到map场景
                using (SceneChangeComponent sceneChangeComponent = ET.Game.Scene.AddComponent <SceneChangeComponent>())
                {
                    await sceneChangeComponent.ChangeSceneAsync(sceneName);
                }

                G2C_EnterMap g2CEnterMap = await ET.SessionComponent.Instance.Session.Call(new C2G_EnterMap()) as G2C_EnterMap;

                PlayerComponent.Instance.MyPlayer.UnitId = g2CEnterMap.UnitId;

                Game.Scene.AddComponent <OperaComponent>();

                Game.EventSystem.Publish(new EventType.EnterMapFinish());
            }
            catch (Exception e)
            {
                Log.Error(e);
            }
        }
Exemplo n.º 2
0
 public static int Process(this SceneChangeComponent self)
 {
     if (self.loadMapOperation == null)
     {
         return(0);
     }
     return((int)(self.loadMapOperation.progress * 100));
 }
Exemplo n.º 3
0
        public static async ETTask ChangeSceneAsync(this SceneChangeComponent self, string sceneName)
        {
            self.tcs = ETTask.Create(true);
            // 加载map
            self.loadMapOperation = SceneManager.LoadSceneAsync(sceneName);

            await self.tcs;
        }
Exemplo n.º 4
0
 public static async ETTask ChangeSceneAsync(this SceneChangeComponent self, string sceneName)
 {
     self.tcs = new ETTaskCompletionSource();
     // 加载map
     self.loadMapOperation = SceneManager.LoadSceneAsync(sceneName);
     //this.loadMapOperation.allowSceneActivation = false;
     await self.tcs.Task;
 }