コード例 #1
0
        public void Awake()
        {
            UI ui = this.GetEntity <UI>();

            ResourcesComponent resourcesComponent = Game.Scene.GetComponent <ResourcesComponent>();

            resourcesComponent.LoadBundle("LandlordCreateRoom.unity3d");
            GameObject bundleGameObject   = resourcesComponent.GetAsset <GameObject>("LandlordCreateRoom.unity3d", "LandlordCreateRoom");
            GameObject LandlordCreateRoom = UnityEngine.Object.Instantiate(bundleGameObject);

            LandlordCreateRoom.layer = LayerMask.NameToLayer(LayerNames.UI);

            LandlordCreateRoom.transform.SetParent(Hotfix.Scene.GetComponent <UIComponent>().GetCanvas(ui), false);
            mRc = LandlordCreateRoom.GetComponent <ReferenceCollector>();
            Hide();
            Button btn_close = mRc.Get <GameObject>("btn_close").GetComponent <Button>();

            btn_close.onClick.Add(() =>
            {
                Hide();
            });

            Button btn_ok = mRc.Get <GameObject>("btn_ok").GetComponent <Button>();

            btn_ok.onClick.Add(() =>
            {
                SessionComponent.Instance.Session.Send(new C2G_CreateLandlordRoom());
            });
        }
コード例 #2
0
        public void Awake(GameObject parent)
        {
            microphone = Game.Scene.GetComponent <MicrophoneComponent>();
            res        = ETModel.Game.Scene.GetComponent <ResourcesComponent>();
            res.LoadBundle(UICowCowAB.CowCow_Prefabs);
            res.LoadBundle(UICowCowAB.CowCow_Texture);
            GameObject ab = (GameObject)res.GetAsset(UICowCowAB.CowCow_Prefabs, UICowCowType.CowCowGameSetting);

            this.GameObject = UnityEngine.Object.Instantiate(ab);
            this.GameObject.transform.SetParent(parent.transform, false);
            this.GameObject.name = UICowCowType.CowCowGameSetting;

            ReferenceCollector rc = this.GameObject.GetComponent <ReferenceCollector>();

            uiVoiceSetting = rc.Get <GameObject>("UIVoiceSetting").GetComponent <CanvasGroup>();
            musicSlider    = rc.Get <GameObject>("MusicSlider").GetComponent <Slider>();
            soundSlider    = rc.Get <GameObject>("SoundSlider").GetComponent <Slider>();
            musicSwitchBtn = rc.Get <GameObject>("MusicSwitchButton").GetComponent <Button>();
            soundSwitchBtn = rc.Get <GameObject>("SoundSwitchButton").GetComponent <Button>();
            Button helpBtn    = rc.Get <GameObject>("HelpBtn").GetComponent <Button>();
            Button comfirmBtn = rc.Get <GameObject>("ComfirmBtn").GetComponent <Button>();

            uiHelp = rc.Get <GameObject>("UIHelp").GetComponent <CanvasGroup>();
            Button hCloseBtn = rc.Get <GameObject>("HCloseBtn").GetComponent <Button>();

            musicSlider.onValueChanged.Add(OnMusicSlider);
            soundSlider.onValueChanged.Add(OnSoundSlider);
            musicSwitchBtn.onClick.Add(OnMusicSwitch);
            soundSwitchBtn.onClick.Add(OnSoundSwitch);
            helpBtn.onClick.Add(OnHelp);
            comfirmBtn.onClick.Add(OnComfirm);
            hCloseBtn.onClick.Add(OnHClose);
        }
コード例 #3
0
        public static async ETVoid EnterMainAsync()
        {
            try
            {
                //1.获取资源
                ResourcesComponent resourcesComponent = ETModel.Game.Scene.GetComponent <ResourcesComponent>();
                await resourcesComponent.LoadBundleAsync("unit.unity3d");

                await ETModel.Game.Scene.GetComponent <ResourcesComponent>().LoadBundleAsync("main.unity3d");

                using (SceneChangeComponent sceneChangeComponent = ETModel.Game.Scene.AddComponent <SceneChangeComponent>())
                {
                    await sceneChangeComponent.ChangeSceneAsync(SceneType.Main);

                    Log.Debug("场景加载进度:" + sceneChangeComponent.Process);
                }

                Game.Scene.AddComponent <MainComponent>();

                Game.EventSystem.Run(EventIdType.EnterMainFinish);
            }
            catch (System.Exception e)
            {
                Log.Error(e);
            }
        }
コード例 #4
0
        public static UI Create()
        {
            try
            {
                //从模型层的资源组件,然后加载Login的AB包
                ResourcesComponent resourcesComponent = ETModel.Game.Scene.GetComponent <ResourcesComponent>();
                resourcesComponent.LoadBundle(UIType.UIMainPanel.StringToAB());                   //StringToAB() 变小写加unity3d  如:uilogin.unity3d

                //拿到预制体
                GameObject bundleGameObject = (GameObject)resourcesComponent.GetAsset(UIType.UIMainPanel.StringToAB(), UIType.UIMainPanel);
                GameObject gameObject       = UnityEngine.Object.Instantiate(bundleGameObject);

                //通过组件化工厂创建UI
                UI ui = ComponentFactory.Create <UI, string, GameObject>(UIType.UIMainPanel, gameObject, false);

                //添加UILogin的逻辑组件
                ui.AddComponent <UIMainPanelComponent>();
                return(ui);
            }
            catch (Exception e)
            {
                Log.Error(e);
                return(null);
            }
        }
コード例 #5
0
        public UI Create(Scene scene, string type, GameObject parent)
        {
            try
            {
                //加载AB包
                ResourcesComponent resourcesComponent = ETModel.Game.Scene.GetComponent <ResourcesComponent>();
                resourcesComponent.LoadBundle($"{type}.unity3d");

                //加载大厅界面预设并生成实例
                GameObject bundleGameObject = (GameObject)resourcesComponent.GetAsset($"{type}.unity3d", $"{type}");
                GameObject lobby            = UnityEngine.Object.Instantiate(bundleGameObject);

                //设置UI层级,只有UI摄像机可以渲染
                lobby.layer = LayerMask.NameToLayer(LayerNames.UI);
                UI ui = ComponentFactory.Create <UI, GameObject>(lobby);

                ui.AddComponent <LandlordsLobbyComponent>();
                return(ui);
            }
            catch (Exception e)
            {
                Log.Error(e.ToStr());
                return(null);
            }
        }
コード例 #6
0
ファイル: UIComponent.cs プロジェクト: allexc123/ET
        public void OpenPanelAsync(UIEnum panel, Action openFinish = null, object param = null)
        {
            PanelType panelType = uiTypes[panel];
            string    prefab    = panelType.uiPrefab;

            if (this.uis.ContainsKey(prefab))
            {
                return;
            }
            ResourcesComponent resourcesComponent = ETModel.Game.Scene.GetComponent <ResourcesComponent>();

            resourcesComponent.LoadBundle(prefab.StringToAB());
            GameObject bundleGameObject = (GameObject)resourcesComponent.GetAsset(prefab.StringToAB(), prefab);

            resourcesComponent.UnloadBundle(prefab.StringToAB());
            GameObject gameObject = UnityEngine.Object.Instantiate(bundleGameObject);

            UI ui = ComponentFactory.Create <UI, string, GameObject>(prefab, gameObject, false);

            UIBase uibase = (UIBase)ui.AddComponent(panelType.panelType);

            uibase.OnInit(param);

            this.uis.Add(ui.Name, ui);
            ui.GameObject.transform.SetParent(this.Root.transform, false);
            uibase.OnShow(param);


            //Add(ui);

            if (openFinish != null)
            {
                openFinish();
            }
        }
コード例 #7
0
        private static async ETVoid EnterBattleAsync()
        {
            try
            {
                // 加载Unit资源
                ResourcesComponent resourcesComponent = ETModel.Game.Scene.GetComponent <ResourcesComponent>();

                // 加载场景资源
                await resourcesComponent.LoadBundleAsync("battle.unity3d");

                // 切换到Battle场景
                using (SceneChangeComponent sceneChangeComponent = Game.Scene.AddComponent <SceneChangeComponent>())
                {
                    await sceneChangeComponent.ChangeSceneAsync(SceneType.Battle);

                    Game.EventSystem.Run(EventIdType.EnterBattlefieldFinish);
                }

                Game.EventSystem.Run(EventIdType.GMCreateTank, 10000);

                // G2C_EnterMap g2CEnterMap = await ETModel.SessionComponent.Instance.Session.Call(new C2G_EnterMap()) as G2C_EnterMap;
                // PlayerComponent.Instance.MyPlayer.UnitId = g2CEnterMap.UnitId;
                //
                // Game.Scene.AddComponent<OperaComponent>();
                //
                // // 逻辑层不应该去调用UI,逻辑层只关心逻辑并且抛出事件,由UI层自己去订阅事件
                // Game.EventSystem.Run(EventIdType.EnterMapFinish);
            }
            catch (Exception e)
            {
                Log.Error(e);
            }
        }
コード例 #8
0
ファイル: UIRoom_Factory.cs プロジェクト: suziye123/MyET
        public UI Create(Scene scene, string type, GameObject parent)
        {
            try
            {
                Debug.Log("UIRoom_Factory");
                ResourcesComponent resourcesComponent = ETModel.Game.Scene.GetComponent <ResourcesComponent>();
                AltasComponent     altasComponent     = Game.Scene.GetComponent <AltasComponent>();
                resourcesComponent.LoadBundle($"{ type}.unity3d");
                GameObject bundleGameObject = (GameObject)resourcesComponent.GetAsset($"{type}.unity3d", $"{type}");
                GameObject obj = UnityEngine.Object.Instantiate(bundleGameObject);
                UI         ui  = ComponentFactory.Create <UI, GameObject>(obj);
                ui.AddUiComponent <UIRoom_Component>();

                //加载扑克图集
                resourcesComponent.LoadBundle($"{AltasType.PukeAltas}.unity3d");
                GameObject AltasGameObject = (GameObject)resourcesComponent.GetAsset($"{AltasType.PukeAltas}.unity3d", $"{AltasType.PukeAltas}");
                GameObject Altas           = UnityEngine.Object.Instantiate(AltasGameObject, altasComponent.ParentAltas.transform);
                altasComponent.AddAltas(AltasType.PukeAltas, Altas);


                //加载字体图集
                resourcesComponent.LoadBundle($"{AltasType.FontAltas}.unity3d");
                GameObject FontAltasGameObject = (GameObject)resourcesComponent.GetAsset($"{AltasType.FontAltas}.unity3d", $"{AltasType.FontAltas}");
                GameObject FontAltas           = UnityEngine.Object.Instantiate(FontAltasGameObject, altasComponent.ParentAltas.transform);
                altasComponent.AddAltas(AltasType.FontAltas, FontAltas);

                return(ui);
            }
            catch (Exception e)
            {
                Debug.LogError(e.Message);
                return(null);
            }
        }
コード例 #9
0
        private async ETVoid EnterMapAsync()
        {
            try
            {
                // 加载Unit资源
                ResourcesComponent resourcesComponent = ETModel.Game.Scene.GetComponent <ResourcesComponent>();
                await resourcesComponent.LoadBundleAsync($"unit.unity3d");

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

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

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

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

                Game.Scene.AddComponent <OperaComponent>();
                Game.Scene.GetComponent <UIComponent>().Remove(UIType.UILobby);
            }
            catch (Exception e)
            {
                Log.Error(e);
            }
        }
コード例 #10
0
        /// <summary>
        /// 通过item的类型获得不同的bundle包
        /// </summary>
        /// <param name="itemType"></param>
        /// <returns></returns>
        private GameObject GetItemBundleByType(string itemType)
        {
            ResourcesComponent resourcesComponent = ETModel.Game.Scene.GetComponent <ResourcesComponent>();

            resourcesComponent.LoadBundle($"{itemType}.unity3d");
            return((GameObject)resourcesComponent.GetAsset($"{itemType}.unity3d", $"{itemType}"));
        }
コード例 #11
0
ファイル: GamerFactory.cs プロジェクト: 510264505/ETCow
        /// <summary>
        /// 创建预制体
        /// </summary>
        public static GameObject Create(string abName)
        {
            ResourcesComponent rc = ETModel.Game.Scene.GetComponent <ResourcesComponent>();
            GameObject         ab = (GameObject)rc.GetAsset(UICowCowAB.CowCow_Prefabs, abName);

            return(UnityEngine.Object.Instantiate(ab));
        }
コード例 #12
0
        /// <summary>
        /// 进入地图
        /// </summary>
        /// <returns></returns>
        public static async ETVoid EnterMapAsync(int MapSizeX, int MapSizeY)
        {
            try
            {
                // 加载Unit资源
                ResourcesComponent resourcesComponent = ETModel.Game.Scene.GetComponent <ResourcesComponent>();
                await resourcesComponent.LoadBundleAsync($"unit.unity3d");

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

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

                Game.Scene.AddComponent <MapGridOperaComponent>();
                Game.EventSystem.Run(ETDemoEventIdType.EnterMapFinish, MapSizeX, MapSizeY);
            }
            catch (Exception e)
            {
                Log.Error(e);
            }
        }
コード例 #13
0
ファイル: OutSpaceHelper.cs プロジェクト: luwenyiCC/ET
        public static async ETVoid EnterOutSpaceAsync()
        {
            try
            {
                // 加载Unit资源
                ResourcesComponent resourcesComponent = ETModel.Game.Scene.GetComponent <ResourcesComponent>();
                await resourcesComponent.LoadBundleAsync($"unit.unity3d");

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

                // 切换到outspace场景
                using (SceneChangeComponent sceneChangeComponent = ETModel.Game.Scene.AddComponent <SceneChangeComponent>())
                {
                    await sceneChangeComponent.ChangeSceneAsync(SceneType.OutSpace);
                }

                G2C_EnterOutSpace g2CEnterMap = await ETModel.SessionComponent.Instance.Session.Call(new C2G_EnterOutSpace()) as G2C_EnterOutSpace;

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

                Game.Scene.AddComponent <OutSpaceComponent>();

                Game.EventSystem.Run(EventIdType.LobbyFinish);
                Game.EventSystem.Run(EventIdType.Init_UI_OutSpace);
            }
            catch (Exception e)
            {
                Log.Error(e);
            }
        }
コード例 #14
0
        protected override void Run(ETModel.Session session, Actor_CreateUnits message)
        {
            // 加载Unit资源
            ResourcesComponent resourcesComponent = ETModel.Game.Scene.GetComponent <ResourcesComponent>();

            resourcesComponent.LoadBundle($"Unit.unity3d");

            UnitComponent unitComponent = ETModel.Game.Scene.GetComponent <UnitComponent>();

            foreach (UnitInfo unitInfo in message.Units)
            {
                if (unitComponent.Get(unitInfo.UnitId) != null)
                {
                    continue;
                }
                Unit unit = UnitFactory.Create(unitInfo.UnitId);
                unit.Position = new Vector3(unitInfo.X / 1000f, 0, unitInfo.Z / 1000f);
                unit.hero     = (Hero)Game.Scene.GetComponent <ConfigComponent>().Get(typeof(Hero), 1);
                Log.Debug($"config {JsonHelper.ToJson(unit.hero)}");
                unit.IntPos = new VInt3(unitInfo.X, 0, unitInfo.Z);

                if (PlayerComponent.Instance.MyPlayer.UnitId == unit.Id)
                {
                    ETModel.Game.Scene.GetComponent <CameraComponent>().Unit = unit;
                }
            }

            Game.Scene.AddComponent <OperaComponent>();
        }
コード例 #15
0
        public async ETVoid RunAsync()
        {
            // 加载Unit资源
            ResourcesComponent resourcesComponent = ETModel.Game.Scene.GetComponent <ResourcesComponent>();

            // 加载场景资源

            await resourcesComponent.LoadBundleAsync(AssetBundleName.Unit);

            await resourcesComponent.LoadBundleAsync(AssetBundleName.Battle);



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



            C2B_LoadAssetFinish msg = new C2B_LoadAssetFinish();

            ETModel.SessionComponent.Instance.Session.Send(msg);
        }
コード例 #16
0
ファイル: MapHelper.cs プロジェクト: FUCKINGLIFE/Push-Pop
        public static async ETVoid EnterMapAsync()
        {
            try
            {
                // 加载Unit资源
                ResourcesComponent resourcesComponent = ETModel.Game.Scene.GetComponent <ResourcesComponent>();
                await resourcesComponent.LoadBundleAsync($"player.unity3d");

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

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

                Game.Scene.AddComponent <OperaComponent>();
                Game.Scene.AddComponent <PlatformComponent>();

                Player          player          = PlayerFactory.Create(IdGenerater.GenerateId());
                PlayerComponent playerComponent = Game.Scene.GetComponent <PlayerComponent>();
                playerComponent.MyPlayer = player;

                Game.EventSystem.Run(EventIdType.EnterMapFinish);
            }
            catch (Exception e)
            {
                Log.Error(e);
            }
        }
コード例 #17
0
ファイル: Init.cs プロジェクト: a395338563/THClimbTwoer
    private void Awake()
    {
#if UNITY_EDITOR
        //暂时先这样加载Hotfix
        byte[] d = (dll as TextAsset).bytes;
        byte[] m = (mdb as TextAsset).bytes;
#else
        string path = Application.streamingAssetsPath + "/code";
        Debug.Log(path);
        var       a = AssetBundle.LoadFromFile(path);
        TextAsset t = a.LoadAsset <TextAsset>("Hotfix.dll.bytes");
        byte[]    d = (t as TextAsset).bytes;
        byte[]    m = (mdb as TextAsset).bytes;
#endif
        Assembly hotfix = Assembly.Load(d, m);

        //读取Hotfix的内容,虽然很奇怪但是就这样吧
        THClimbTower.TileFactory.Instance.Add(hotfix);
        THClimbTower.CardFactory.Instance.Add(hotfix);
        THClimbTower.EnemyFatory.Instance.Add(hotfix);
        THClimbTower.EnemyTeamFactory.Instance.Add(hotfix);
        THClimbTower.EventFactory.Instance.Add(hotfix);
        THClimbTower.CharactorConfigFactory.Instance.Add(hotfix);

        UIManagerComponent ui = Game.Scene.AddComponent <UIManagerComponent>();
        ui.Add(hotfix);
        ui.Awake();
        ui.LoadSence(IninScene);

        ResourcesComponent r = Game.Scene.AddComponent <ResourcesComponent>();
        r.LoadBundle("code");
    }
コード例 #18
0
ファイル: ResourceUtil.cs プロジェクト: araya/ET-Plus
        public static T Load <T>(string assetName) where T : class
        {
            ResourcesComponent resourcesComponent = ETModel.Game.Scene.GetComponent <ResourcesComponent>();

            resourcesComponent.LoadBundle(assetName.StringToAB());
            return(resourcesComponent.GetAsset(assetName.StringToAB(), assetName) as T);
        }
コード例 #19
0
ファイル: MyGameHelper.cs プロジェクト: Avatarchik/Miracle
        /// <summary>
        /// 联网demo的切换场景
        /// </summary>
        /// <returns></returns>
        public static async ETVoid EnterMyGameAsync()
        {
            try
            {
                // 获取加载ResourcesComponent组件   加载Unit资源(放一些模型)
                ResourcesComponent resourcesComponent = ETModel.Game.Scene.GetComponent <ResourcesComponent>();
                await resourcesComponent.LoadBundleAsync($"unit.unity3d");   //异步加载

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

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

                //发送消息到服务器
                G2C_EnterMyGame g2CEnterMyGame = await ETModel.SessionComponent.Instance.Session.Call(new C2G_EnterMyGame()) as G2C_EnterMyGame;

                //把自己的ID设置为刚生成传过来的ID
                PlayerComponent.Instance.MyPlayer.UnitId = g2CEnterMyGame.UnitId;

                Game.Scene.AddComponent <OperaComponent>();

                Game.EventSystem.Run(EventIdType.ChoiceCharacterFinish);
            }
            catch (Exception e)
            {
                Log.Error(e);
            }
        }
コード例 #20
0
        public HotfixTestObj()
        {
            ResourcesComponent resourcesComponent = ICE.Game.Scene.GetComponent <ResourcesComponent>();

            resourcesComponent.LoadBundle("Cube".StringToAB().BundleNameToLower());
            GameObject prefab = resourcesComponent.GetAsset("Cube".StringToAB().BundleNameToLower(), "Cube") as GameObject;
            GameObject cube1  = GameObject.Instantiate(prefab);

            cube1.name = "111";
            GameObject = cube1;

            //moveComponent = ComponentFactory.Create<MoveComponent, GameObject>(GameObject);
            //moveComponent.GameObject.transform.SetParent(GameObject.transform, false);
            //rotationComponent = ComponentFactory.Create<RotationComponent, GameObject>(GameObject);
            //rotationComponent.GameObject.transform.SetParent(GameObject.transform, false);
            //scaleComponent = ComponentFactory.Create<ScaleComponent, GameObject>(GameObject);
            //scaleComponent.GameObject.transform.SetParent(GameObject.transform, false);

            var actor1 = Helper.AddHActor(cube1);

            Helper.AddHComponent <CubeComponent>(actor1);
            Helper.AddHComponent <CubeComponent2>(actor1);

            GameObject cube2 = GameObject.Instantiate(prefab);

            cube2.name = "222";
            var actor2 = Helper.AddHActor(cube2);

            Helper.AddHComponent <CubeComponent2>(actor2);

            //resourcesComponent.UnLoadBundle("Cube".StringToAB().BundleNameToLower());
        }
コード例 #21
0
        Unit CreateMap(ResourcesComponent resourcesComponent, string abName, UnitComponent unitComponent,
                       int MapSizeX, int MapSizeY)
        {
            GameObject bundleGameObjectMapGrid =
                (GameObject)resourcesComponent.GetAsset(abName.StringToAB(), "MapGrid");
            // 添加格子
            Unit        mapGridUnit = null;
            MapGridData mapGridData = new MapGridData();

            mapGridData.ABName = abName;
            for (int x = 0; x < MapSizeX; x++)
            {
                for (int y = 0; y < MapSizeY; y++)
                {
                    GameObject gameObjectGrid = UnityEngine.Object.Instantiate(bundleGameObjectMapGrid);
                    gameObjectGrid.name = string.Format("Grid[{0}][{1}]", x, y);
                    // 创建地图格子实体
                    int id = gameObjectGrid.GetHashCode();// x * 1000 + y;
                    Log.Debug("创建地图格子实体:{0} ", id);
                    mapGridUnit = ETModel.ComponentFactory.CreateWithId <ETModel.Unit, GameObject>(
                        id, gameObjectGrid);
                    // 添加地图格子组件
                    mapGridData.GridX  = x;
                    mapGridData.GridY  = y;
                    mapGridData.BgName = "Desert";
                    MapGridComponent mapGridComponent = ETModel.ComponentFactory.CreateWithParent <MapGridComponent, MapGridData>(
                        mapGridUnit, mapGridData);
                    mapGridUnit.AddComponent(mapGridComponent);
                    // add
                    unitComponent.Add(mapGridUnit);
                }
            }
            return(mapGridUnit);
        }
コード例 #22
0
    public Task <AssetBundle> LoadAsync(string path, Action <float> updateProgress = null)
    {
        this.updateProgress = updateProgress;
        this.tcs            = new TaskCompletionSource <AssetBundle>();
        AbPath = path;
        ResourcesComponent resComponent = ResourcesComponent.instance;

        if (resComponent.DicABRequest.ContainsKey(path))
        {
            if (resComponent.DicABRequest[path] == null)
            {
                resComponent.DicABRequest.Remove(path);
            }
            else if (resComponent.DicABRequest[path].assetBundle == null)
            {
                resComponent.DicABRequest.Remove(path);
            }
            else
            {
                this.request = resComponent.DicABRequest[path];
                return(this.tcs.Task);
            }
        }
        this.request = AssetBundle.LoadFromFileAsync(path);
        if (!resComponent.DicABRequest.ContainsKey(AbPath))
        {
            resComponent.DicABRequest.Add(AbPath, this.request);
        }
        return(this.tcs.Task);
    }
コード例 #23
0
        public UI Create(Scene scene, string type, GameObject gameObject)
        {
            try
            {
                Debug.Log("14124");

                //获取资源管理组件
                ResourcesComponent resourcesComponent = ETModel.Game.Scene.GetComponent <ResourcesComponent>();
                //加载对应的Ab资源包并加载
                resourcesComponent.LoadBundle($"{type}.unity3d");
                //获取对象资源物体
                GameObject bundleGameObject = (GameObject)resourcesComponent.GetAsset($"{type}.unity3d", $"{type}");
                //创建对象UI
                GameObject lobby = UnityEngine.Object.Instantiate(bundleGameObject);
                //设定UI层
                lobby.layer = LayerMask.NameToLayer(LayerNames.UI);
                //调用组件工厂创建UI lobby大厅
                UI ui = ComponentFactory.Create <UI, GameObject>(lobby);

                //给该ui挂载UI大厅组件
                ui.AddComponent <MyUILobbyComponent>();
                //组装完毕返回出去
                return(ui);
            }
            catch (Exception e)
            {
                Log.Error(e);
                return(null);
            }
        }
コード例 #24
0
        protected override void Run(ETModel.Session session, Actor_CreateUnits message)
        {
            // 加载Unit资源
            ResourcesComponent resourcesComponent = ETModel.Game.Scene.GetComponent <ResourcesComponent>();

            resourcesComponent.LoadBundle($"Unit.unity3d");

            UnitComponent unitComponent = ETModel.Game.Scene.GetComponent <UnitComponent>();

            foreach (UnitInfo unitInfo in message.Units)
            {
                if (unitComponent.Get(unitInfo.UnitId) != null)
                {
                    continue;
                }
                Unit unit = ETModel.ComponentFactory.CreateWithId <Unit>(unitInfo.UnitId);
                unitComponent.Add(unit);
                //Unit unit = UnitFactory.Create(unitInfo.UnitId);
                //unit.Position = new Vector3(unitInfo.X / 1000f, 0, unitInfo.Z / 1000f);
                //unit.IntPos = new VInt3(unitInfo.X, 0, unitInfo.Z);

                if (PlayerComponent.Instance.MyPlayer.Id == unit.Id)
                {
                    unit.AddComponent <UnitEntityComponent, bool>(true);
                    ETModel.Game.Scene.AddComponent <MapGridComponent>();
                }
                else
                {
                    unit.AddComponent <UnitStateComponent>();
                    unit.AddComponent <UnitEntityComponent, bool>(false);
                }
            }

            //Game.Scene.AddComponent<OperaComponent>();
        }
コード例 #25
0
        protected override void Run(Session session, Actor_CreateUnits message)
        {
            // 加载Unit资源
            ResourcesComponent resourcesComponent = Game.Scene.GetComponent <ResourcesComponent>();

            resourcesComponent.LoadBundle($"Unit.unity3d");

            UnitComponent unitComponent = Game.Scene.GetComponent <UnitComponent>();

            foreach (UnitInfo unitInfo in message.Units)
            {
                if (unitComponent.Get(unitInfo.UnitId) != null)
                {
                    continue;
                }
                Unit unit = UnitFactory.Create(unitInfo.UnitId);
                unit.Position = new Vector3(unitInfo.X / 1000f, 0, unitInfo.Z / 1000f);
                unit.IntPos   = new VInt3(unitInfo.X, 0, unitInfo.Z);

                if (PlayerComponent.Instance.MyPlayer.UnitId == unit.Id)
                {
                    Game.Scene.GetComponent <CameraComponent>().Unit = unit;
                }
            }

            Hotfix.Scene.AddComponent <OperaComponent>();
        }
コード例 #26
0
        public static UI Create()
        {
            try
            {
                //获取主工程的ResourcesComponent组件
                ResourcesComponent resourcesComponent = ETModel.Game.Scene.
                                                        GetComponent <ResourcesComponent>();
                //加载AB
                resourcesComponent.LoadBundle(UIType.UILogin.StringToAB());
                //获取资源
                GameObject bundleGameObject = (GameObject)resourcesComponent.
                                              GetAsset(UIType.UILogin.StringToAB(), UIType.UILogin);
                //克隆物体
                GameObject gameObject = UnityEngine.Object.Instantiate(bundleGameObject);

                //创建实体,并且内部调用了Awake方法
                UI ui = ComponentFactory.Create <UI, string, GameObject>(UIType.UILogin, gameObject, false);
                //给实体增加组件
                ui.AddComponent <UILoginComponent>();
                return(ui);
            }
            catch (Exception e)
            {
                Log.Error(e);
                return(null);
            }
        }
コード例 #27
0
ファイル: MapHelper.cs プロジェクト: x1766233/DCET
        public static async ETVoid EnterMapAsync(string sceneName)
        {
            try
            {
                // 加载Unit资源
                ResourcesComponent resourcesComponent = DCET.Model.Game.Scene.GetComponent <ResourcesComponent>();
                await resourcesComponent.LoadBundleAsync($"unit.unity3d");

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

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

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

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

                Game.Scene.AddComponent <OperaComponent>();

                Game.EventSystem.Run(EventIdType.EnterMapFinish);
            }
            catch (Exception e)
            {
                Log.Error(e);
            }
        }
コード例 #28
0
        public static void UnloadLoungeIconBundle()
        {
            ResourcesComponent resourcesComponent = ETModel.Game.Scene.GetComponent <ResourcesComponent>();

            resourcesComponent.UnloadBundle(ResourcesPathType.Image, imageIconBundleName);
            imageLoungeIconBundle = null;
        }
コード例 #29
0
        public static async ETTask <GameObject> LoadLoungeIconBundle()
        {
            ResourcesComponent resourcesComponent = ETModel.Game.Scene.GetComponent <ResourcesComponent>();

            imageLoungeIconBundle = await resourcesComponent.LoadAssetAsync(ResourcesPathType.Image, imageIconBundleName) as GameObject;

            return(imageLoungeIconBundle);
        }
コード例 #30
0
ファイル: UnitResources.cs プロジェクト: mrcece/ETCore
        public static UnityEngine.Object[] GetAll(string asName)
        {
            ResourcesComponent resourcesComponent = Game.Scene.GetComponent <ResourcesComponent>();
            GameObject         bundleGameObject   = (GameObject)resourcesComponent.GetAsset(asName + ".unity3d", "Unit");

            UnityEngine.Object[] prefabs = bundleGameObject.GetAll <GameObject>();
            return(prefabs);
        }