protected override async ETTask Run(Session session, M2C_CreateUnits message)
        {
            UnitComponent unitComponent = Game.Scene.GetComponent <UnitComponent>();

            foreach (UnitInfo unitInfo in message.Units)
            {
                if (unitComponent.Get(unitInfo.UnitId) != null)
                {
                    continue;
                }
                Unit unit = UnitFactory.Create(Game.Scene, unitInfo);
            }

            await ETTask.CompletedTask;
        }
Esempio n. 2
0
        protected override async ETVoid Run(Session session, M2C_CreateUnits message)
        {
            UnitComponent unitComponent = session.Domain.GetComponent <UnitComponent>();

            foreach (UnitInfo unitInfo in message.Units)
            {
                if (unitComponent.Get(unitInfo.UnitId) != null)
                {
                    continue;
                }
                Unit unit = UnitFactory.Create(session.Domain, unitInfo.UnitId);
                unit.Position = new Vector3(unitInfo.X, unitInfo.Y, unitInfo.Z);
            }

            await ETTask.CompletedTask;
        }
Esempio n. 3
0
        protected override async ETVoid Run(Session session, M2C_CreateUnits message)
        {
            Log.Debug("我收到了 创建Unit的服务器消息");

            UnitComponent unitComponent = session.Domain.GetComponent <UnitComponent>();

            foreach (UnitInfo unitInfo in message.Units)
            {
                if (unitComponent.Get(unitInfo.UnitId) != null)
                {
                    continue;
                }
                Unit unit = UnitFactory.Create(session.Domain, unitInfo);
            }

            await ETTask.CompletedTask;
        }
Esempio n. 4
0
        protected override async ETTask Run(Session session, C2G_EnterMap request, G2C_EnterMap response, Action reply)
        {
            Player player = session.GetComponent <SessionPlayerComponent>().GetMyPlayer();

            // 在Gate上动态创建一个Map Scene,把Unit从DB中加载放进来,然后传送到真正的Map中,这样登陆跟传送的逻辑就完全一样了
            GateMapComponent gateMapComponent = player.AddComponent <GateMapComponent>();

            gateMapComponent.Scene = await SceneFactory.Create(gateMapComponent, "GateMap", SceneType.Map);

            Scene scene = gateMapComponent.Scene;

            // 这里可以从DB中加载Unit
            Unit unit = UnitFactory.Create(scene, player.Id, UnitType.Player);

            unit.AddComponent <UnitGateComponent, long>(session.InstanceId);

            StartSceneConfig startSceneConfig = StartSceneConfigCategory.Instance.GetBySceneName(session.DomainZone(), "Map1");

            response.MyId = player.Id;
            reply();

            // 开始传送
            await TransferHelper.Transfer(unit, startSceneConfig.InstanceId, startSceneConfig.Name);
        }