コード例 #1
0
        /// <summary>
        /// 指定Id
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        private static Unit CreateUnitWithIdBase(long id)
        {
            Unit result = ComponentFactory.CreateWithId <Unit>(id);

            Game.Scene.GetComponent <UnitComponent>().Add(result);
            return(result);
        }
コード例 #2
0
        /// <summary>
        /// 指定Id
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        private static Unit CreateUnitWithIdBase(long id)
        {
            Unit result = ComponentFactory.CreateWithId <Unit>(id);

            UnitComponent.Instance.Add(result);
            return(result);
        }
コード例 #3
0
ファイル: PlayerFactory.cs プロジェクト: mrcece/ETCore
        public static Player Create(long id)
        {
            Player          player          = ComponentFactory.CreateWithId <Player>(id);
            PlayerComponent playerComponent = Game.Scene.GetComponent <PlayerComponent>();

            playerComponent.Add(player);
            return(player);
        }
コード例 #4
0
ファイル: UnitFactory.cs プロジェクト: mrcece/ETCore
        public static Unit Create(long id, GameObject go)
        {
            Unit unit = ComponentFactory.CreateWithId <Unit, GameObject>(id, go);
            //unit.AddComponent<CharacterMoveComponent>();
            UnitComponent unitComponent = Game.Scene.GetComponent <UnitComponent>();

            unitComponent.Add(unit);
            return(unit);
        }
コード例 #5
0
ファイル: UnitFactory.cs プロジェクト: mrcece/ETCore
        public static Unit Create(long id, string type = "Skeleton")
        {
            GameObject prefab = UnitResources.Get($"{type}");
            GameObject go     = UnityEngine.Object.Instantiate(prefab);
            Unit       unit   = ComponentFactory.CreateWithId <Unit, GameObject>(id, go);
            //unit.AddComponent<FrameMoveComponent>();

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

            unitComponent.Add(unit);
            return(unit);
        }
コード例 #6
0
ファイル: Init_2.cs プロジェクト: coculate/MyETDemo
    public async void OnLogin()
    {
        SessionWrap sessionWrap = null;

        try
        {
            IPEndPoint connetEndPoint = NetworkHelper.ToIPEndPoint(GlobalConfigComponent.Instance.GlobalProto.Address);
            string     text           = pname.text;
            string     pass           = password.text;

            Session session = Game.Scene.GetComponent <NetOuterComponent>().Create(connetEndPoint);
            sessionWrap = new SessionWrap(session);
            R2C_Login r2CLogin = (R2C_Login)await sessionWrap.Call(new C2R_Login()
            {
                Account = text, Password = pass
            });

            sessionWrap.Dispose();

            connetEndPoint = NetworkHelper.ToIPEndPoint(r2CLogin.Address);
            Session gateSession = Game.Scene.GetComponent <NetOuterComponent>().Create(connetEndPoint);
            Game.Scene.AddComponent <SessionWrapComponent>().Session = new SessionWrap(gateSession);
            Game.Scene.AddComponent <SessionComponent>().Session     = gateSession;
            G2C_LoginGate g2CLoginGate = (G2C_LoginGate)await SessionWrapComponent.Instance.Session.Call(new C2G_LoginGate()
            {
                Key = r2CLogin.Key
            });

            Log.Info("登陆gate成功!");
            uiLogin.SetActive(false);
            uiLobby.SetActive(true);

            // 创建Player
            Player          player          = ComponentFactory.CreateWithId <Player>(g2CLoginGate.PlayerId);
            PlayerComponent playerComponent = Game.Scene.GetComponent <PlayerComponent>();
            playerComponent.MyPlayer = player;

            //Game.Scene.GetComponent<UIComponent>().Create(UIType.UILobby);
            //Game.Scene.GetComponent<UIComponent>().Remove(UIType.UILogin);
        }
        catch (Exception e)
        {
            sessionWrap?.Dispose();
            Log.Error(e);
        }
    }
コード例 #7
0
        public static Unit Create(long id, string name)
        {
            //  GameObject obj = new GameObject();
            // obj.name = name;
            UnitComponent unitComponent = Game.Scene.GetComponent <UnitComponent>();

            Unit unit = ComponentFactory.CreateWithId <Unit>(id);

            unit.name = name;
            //InistanceObj
            //     unit.GameObject = obj;
            //  GameObject parent = GameObject.Find($"/Global/Unit");
            //  unit.GameObject.transform.SetParent(parent.transform, false);
            //   unit.AddComponent<AnimatorComponent>();

            //   unit.AddComponent<FrameMoveComponent>();
            unitComponent.Add(unit);
            return(unit);
        }
コード例 #8
0
ファイル: Program.cs プロジェクト: ihaiucom/learn.ET_Window
        static void Main(string[] args)
        {
            // 异步方法全部会回掉到主线程
            OneThreadSynchronizationContext contex = new OneThreadSynchronizationContext();

            SynchronizationContext.SetSynchronizationContext(contex);

            //AssemblyTypes(typeof(Game).Assembly);
            //AssemblyTypes(typeof(StageScene).Assembly);

            Game.EventSystem.Add(DLLType.Model, typeof(Stage).Assembly);


            Component willRemove = null;

            Stage stage1 = ComponentFactory.CreateWithId <Stage, ulong, string>(1, 1001, "关卡一");
            Stage stage2 = ComponentFactory.CreateWithId <Stage, ulong, string>(2, 1002, "关卡二");

            stage1.AddComponent <UnitMoveSystem>();
            stage2.AddComponent <UnitMoveSystem>();

            War.StageManager.Add(stage1);
            War.StageManager.Add(stage2);

            Unit unit = ComponentFactory.CreateWithParent <Unit, string>(stage1, "单位1");

            unit.AddComponent <UnitMoveComponent>();
            stage1.AddUnit(unit);

            unit = ComponentFactory.Create <Unit, string>("单位2");
            unit.AddComponent <UnitMoveComponent>();
            stage1.AddUnit(unit);

            willRemove = unit;


            unit = ComponentFactory.Create <Unit, string>("单位B1");
            unit.AddComponent <UnitMoveComponent>();
            stage2.AddUnit(unit);


            while (true)
            {
                try
                {
                    contex.Update();
                    Game.EventSystem.Update();

                    if (willRemove != null)
                    {
                        willRemove.Dispose();
                        willRemove = null;

                        unit = ComponentFactory.CreateWithParent <Unit, string>(stage1, "单位A11");
                        unit.AddComponent <UnitMoveComponent>();
                        stage1.AddUnit(unit);

                        unit = ComponentFactory.CreateWithParent <Unit, string>(stage1, "单位A12");
                        unit.AddComponent <UnitMoveComponent>();
                        stage1.AddUnit(unit);
                    }

                    Log.Info("--------------------");
                    Thread.Sleep(2000);
                }
                catch (Exception e)
                {
                    Log.Error(e);
                }
            }
        }