public override async ETTask Run(EventType.AppStart args) { Game.Scene.AddComponent <ConfigComponent>(); StartProcessConfig processConfig = StartProcessConfigCategory.Instance.Get(Game.Options.Process); Game.Scene.AddComponent <TimerComponent>(); Game.Scene.AddComponent <OpcodeTypeComponent>(); Game.Scene.AddComponent <MessageDispatcherComponent>(); Game.Scene.AddComponent <CoroutineLockComponent>(); // 发送普通actor消息 Game.Scene.AddComponent <ActorMessageSenderComponent>(); // 发送location actor消息 Game.Scene.AddComponent <ActorLocationSenderComponent>(); // 访问location server的组件 Game.Scene.AddComponent <LocationProxyComponent>(); Game.Scene.AddComponent <ActorMessageDispatcherComponent>(); // 数值订阅组件 Game.Scene.AddComponent <NumericWatcherComponent>(); Game.Scene.AddComponent <NetInnerComponent, IPEndPoint>(processConfig.InnerIPPort); var processScenes = StartSceneConfigCategory.Instance.GetByProcess(Game.Options.Process); foreach (StartSceneConfig startConfig in processScenes) { await SceneFactory.Create(Game.Scene, startConfig.SceneId, startConfig.Zone, startConfig.Name, startConfig.Type, startConfig); } }
protected override async ETTask Run(EventType.AppStart args) { Game.Scene.AddComponent <ConfigComponent>(); await ConfigComponent.Instance.LoadAsync(); StartProcessConfig processConfig = StartProcessConfigCategory.Instance.Get(Game.Options.Process); Game.Scene.AddComponent <TimerComponent>(); Game.Scene.AddComponent <OpcodeTypeComponent>(); Game.Scene.AddComponent <MessageDispatcherComponent>(); Game.Scene.AddComponent <SessionStreamDispatcher>(); Game.Scene.AddComponent <CoroutineLockComponent>(); // 发送普通actor消息 Game.Scene.AddComponent <ActorMessageSenderComponent>(); // 发送location actor消息 Game.Scene.AddComponent <ActorLocationSenderComponent>(); // 访问location server的组件 Game.Scene.AddComponent <LocationProxyComponent>(); Game.Scene.AddComponent <ActorMessageDispatcherComponent>(); // 数值订阅组件 Game.Scene.AddComponent <NumericWatcherComponent>(); Game.Scene.AddComponent <NetThreadComponent>(); Game.Scene.AddComponent <NavmeshComponent, Func <string, byte[]> >(RecastFileReader.Read); switch (Game.Options.AppType) { case AppType.Server: { Game.Scene.AddComponent <NetInnerComponent, IPEndPoint, int>(processConfig.InnerIPPort, SessionStreamDispatcherType.SessionStreamDispatcherServerInner); var processScenes = StartSceneConfigCategory.Instance.GetByProcess(Game.Options.Process); foreach (StartSceneConfig startConfig in processScenes) { await SceneFactory.Create(Game.Scene, startConfig.Id, startConfig.InstanceId, startConfig.Zone, startConfig.Name, startConfig.Type, startConfig); } break; } case AppType.Watcher: { StartMachineConfig startMachineConfig = WatcherHelper.GetThisMachineConfig(); WatcherComponent watcherComponent = Game.Scene.AddComponent <WatcherComponent>(); watcherComponent.Start(Game.Options.CreateScenes); Game.Scene.AddComponent <NetInnerComponent, IPEndPoint, int>(NetworkHelper.ToIPEndPoint($"{startMachineConfig.InnerIP}:{startMachineConfig.WatcherPort}"), SessionStreamDispatcherType.SessionStreamDispatcherServerInner); break; } case AppType.GameTool: break; } if (Game.Options.Console == 1) { Game.Scene.AddComponent <ConsoleComponent>(); } }
public void StartGame() { Scene zoneScene = SceneFactory.CreateZoneScene(1, "Game", Game.Scene); Game.EventSystem.PublishAsync(new EventType.AppStartInitFinish() { ZoneScene = zoneScene }).Coroutine(); }
protected override async ETTask Run(EventType.AppStart args) { Game.Scene.AddComponent <ConfigComponent>(); ConfigComponent.GetAllConfigBytes = LoadConfigHelper.GetAllConfigBytes; ConfigComponent.GetOneConfigBytes = LoadConfigHelper.GetOneConfigBytes; await ConfigComponent.Instance.LoadAsync(); StartProcessConfig processConfig = StartProcessConfigCategory.Instance.Get(Game.Options.Process); Game.Scene.AddComponent <TimerComponent>(); Game.Scene.AddComponent <OpcodeTypeComponent>(); Game.Scene.AddComponent <MessageDispatcherComponent>(); Game.Scene.AddComponent <CoroutineLockComponent>(); // 发送普通actor消息 Game.Scene.AddComponent <ActorMessageSenderComponent>(); // 发送location actor消息 Game.Scene.AddComponent <ActorLocationSenderComponent>(); // 访问location server的组件 Game.Scene.AddComponent <LocationProxyComponent>(); Game.Scene.AddComponent <ActorMessageDispatcherComponent>(); // 数值订阅组件 Game.Scene.AddComponent <NumericWatcherComponent>(); Game.Scene.AddComponent <NetThreadComponent>(); Game.Scene.AddComponent <NetInnerComponent, IPEndPoint>(processConfig.InnerIPPort); var processScenes = StartSceneConfigCategory.Instance.GetByProcess(Game.Options.Process); foreach (StartSceneConfig startConfig in processScenes) { await SceneFactory.Create(Game.Scene, startConfig.InstanceId, startConfig.Zone, startConfig.Name, startConfig.Type, startConfig); } switch (Game.Options.AppType) { case AppType.Server: break; case AppType.Watcher: break; } if (Game.Options.Console == 1) { Game.Scene.AddComponent <ConsoleComponent>(); } }
protected override async ETTask Run(EventType.AppStart args) { // FunctionCallback.AdsGetAllConfigBytes = LoadConfigHelper.AdsLoadAllConfigBytes; // 注册热更层回调 Game.Hotfix.Update = Update; Game.Hotfix.LateUpdate = LateUpdate; Game.Hotfix.OnApplicationQuit = OnApplicationQuit; Game.Scene.AddComponent <TimerComponent>(); Game.Scene.AddComponent <CoroutineLockComponent>(); Game.Scene.AddComponent <FUIPackageComponent>(); // 加载配置 ---资源加载需要更改为addressables,暂时注释 @yzx 2021.5.20 // Game.Scene.AddComponent<ResourcesComponent>(); // ResourcesComponent.Instance.LoadBundle("config.unity3d"); // ResourcesComponent.Instance.UnloadBundle("config.unity3d"); // await ConfigComponent.Instance.LoadAsync(); Game.Scene.AddComponent <AdsResComponent>(); Game.Scene.AddComponent <ConfigComponent>(); ConfigComponent.AdsGetAllConfigBytes = LoadConfigHelper.AdsLoadAllConfigBytes; await ConfigComponent.Instance.AdsLoadAsync("Config"); // Game.Scene.AddComponent <OpcodeTypeComponent>(); Game.Scene.AddComponent <MessageDispatcherComponent>(); Game.Scene.AddComponent <NetThreadComponent>(); Game.Scene.AddComponent <ZoneSceneManagerComponent>(); Game.Scene.AddComponent <GlobalComponent>(); Game.Scene.AddComponent <FUIComponent>(); // 添加AI组件 ---资源加载需要更改为addressables,暂时注释 @yzx 2021.5.20 // Game.Scene.AddComponent<AIDispatcherComponent>(); // ResourcesComponent.Instance.LoadBundle("unit.unity3d"); Scene zoneScene = await SceneFactory.CreateZoneScene(1, "Process"); await Game.EventSystem.Publish(new EventType.AppStartInitFinish() { ZoneScene = zoneScene }); }
public static async ETTask <Scene> NewRobot(this RobotCase self, int zone, string name) { Scene zoneScene = null; try { zoneScene = SceneFactory.CreateZoneScene(zone, name, self); await LoginHelper.Login(zoneScene, ConstValue.LoginAddress, zone.ToString(), zone.ToString()); await EnterMapHelper.EnterMapAsync(zoneScene); Log.Debug($"create robot ok: {zone}"); return(zoneScene); } catch (Exception e) { zoneScene?.Dispose(); throw new Exception($"RobotCase create robot fail, zone: {zone}", e); } }
private static async ETTask <Scene> NewRobot(this RobotCase self) { int zone = self.GetParent <RobotCaseComponent>().GetN(); Scene zoneScene = null; try { zoneScene = SceneFactory.CreateZoneScene(zone, $"Robot_{zone}", self); await LoginHelper.Login(zoneScene, ConstValue.LoginAddress, zone.ToString(), zone.ToString()); await EnterMapHelper.EnterMapAsync(zoneScene); Log.Debug($"create robot ok: {zone}"); return(zoneScene); } catch (Exception e) { zoneScene?.Dispose(); throw new Exception($"RobotCase create robot fail, zone: {zone}", e); } }
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); }
protected override async ETTask Run(EventType.AppStart args) { Game.Scene.AddComponent <ConfigComponent>(); await ConfigComponent.Instance.LoadAsync(); //读取StartProcessConfig中id为Game.Options.Process(这里值为1)的整行配置 //ET6.0由于使用了protobuffer作为导表工具,所以请去Excel文件夹查看原数据 StartProcessConfig processConfig = StartProcessConfigCategory.Instance.Get(GlobalDefine.Options.Process); Game.Scene.AddComponent <TimerComponent>(); Game.Scene.AddComponent <OpcodeTypeComponent>(); Game.Scene.AddComponent <MessageDispatcherComponent>(); Game.Scene.AddComponent <CoroutineLockComponent>(); // 发送普通actor消息 Game.Scene.AddComponent <ActorMessageSenderComponent>(); // 发送location actor消息 Game.Scene.AddComponent <ActorLocationSenderComponent>(); // 访问location server的组件 Game.Scene.AddComponent <LocationProxyComponent>(); Game.Scene.AddComponent <ActorMessageDispatcherComponent>(); // 数值订阅组件 Game.Scene.AddComponent <NumericWatcherComponent>(); Game.Scene.AddComponent <NetThreadComponent>(); //根据自身的类型来决定要添加的组件 switch (GlobalDefine.Options.AppType) { case AppType.Server: { //是一个Sever就添加一个内网组件,用于内网通信 Game.Scene.AddComponent <NetInnerComponent, IPEndPoint>(processConfig.InnerIPPort); //以GloabDefine.Options.Process为凭证获取自己要添加的Scene //注意在StartSceneConfig.xlsx中有两份配置,第一份是给Server用的,第二份是给Robot用的 List <StartSceneConfig> processScenes = StartSceneConfigCategory.Instance.GetByProcess(GlobalDefine.Options.Process); foreach (StartSceneConfig startConfig in processScenes) { await SceneFactory.Create(Game.Scene, startConfig.Id, startConfig.InstanceId, startConfig.Zone, startConfig.Name, startConfig.Type, startConfig); } break; } case AppType.Watcher: { //是一个守护进程就额外添加一个WatcherComponent,守护进程可以用来负责拉起和管理全部的进程 StartMachineConfig startMachineConfig = WatcherHelper.GetThisMachineConfig(); WatcherComponent watcherComponent = Game.Scene.AddComponent <WatcherComponent>(); watcherComponent.Start(GlobalDefine.Options.CreateScenes); Game.Scene.AddComponent <NetInnerComponent, IPEndPoint>(NetworkHelper.ToIPEndPoint($"{startMachineConfig.InnerIP}:{startMachineConfig.WatcherPort}")); break; } case AppType.GameTool: break; } if (GlobalDefine.Options.Console == 1) { Game.Scene.AddComponent <ConsoleComponent>(); } }