コード例 #1
0
ファイル: SceneFactory.cs プロジェクト: sybgithub/ET
        public static async ETTask <Scene> Create(Entity parent, long id, int zone, string name, SceneType sceneType, StartSceneConfig startSceneConfig = null)
        {
            await ETTask.CompletedTask;
            Scene scene = EntitySceneFactory.CreateScene(id, zone, sceneType, name);

            scene.Parent = parent;

            scene.AddComponent <MailBoxComponent, MailboxType>(MailboxType.UnOrderMessageDispatcher);

            switch (scene.SceneType)
            {
            case SceneType.Realm:
                scene.AddComponent <NetKcpComponent, IPEndPoint>(startSceneConfig.OuterIPPort);
                break;

            case SceneType.Gate:
                scene.AddComponent <NetKcpComponent, IPEndPoint>(startSceneConfig.OuterIPPort);
                scene.AddComponent <PlayerComponent>();
                scene.AddComponent <GateSessionKeyComponent>();
                break;

            case SceneType.Map:
                scene.AddComponent <UnitComponent>();
                //scene.AddComponent<RecastPathComponent>();
                break;

            case SceneType.Location:
                scene.AddComponent <LocationComponent>();
                break;
            }

            return(scene);
        }
コード例 #2
0
ファイル: SceneFactory.cs プロジェクト: fotocj007/ETBomb
        public static async ETTask <Scene> Create(Entity parent, long id, int zone, string name, SceneType sceneType,
                                                  StartSceneConfig startSceneConfig = null)
        {
            await ETTask.CompletedTask;
            Scene scene = EntitySceneFactory.CreateScene(id, zone, sceneType, name);

            scene.Parent = parent;

            scene.AddComponent <MailBoxComponent, MailboxType>(MailboxType.UnOrderMessageDispatcher);

            var zoneConfig = StartZoneConfigCategory.Instance.Get(zone);

            switch (scene.SceneType)
            {
            case SceneType.Realm:
                scene.AddComponent <NetOuterComponent, string>(startSceneConfig.OuterAddress);
                scene.AddComponent <DBComponent, string, string>(zoneConfig.DBConnection, zoneConfig.DBName);
                break;

            case SceneType.Gate:
                scene.AddComponent <NetOuterComponent, string>(startSceneConfig.OuterAddress);
                scene.AddComponent <GateSessionKeyComponent>();
                scene.AddComponent <DBComponent, string, string>(zoneConfig.DBConnection, zoneConfig.DBName);
                break;

            case SceneType.Map:
                scene.AddComponent <DBComponent, string, string>(zoneConfig.DBConnection, zoneConfig.DBName);
                break;

            case SceneType.Location:
                scene.AddComponent <LocationComponent>();
                scene.AddComponent <RoomManager>();
                break;
            }

            return(scene);
        }
コード例 #3
0
        public static async ETTask <Scene> Create(Entity parent, long id, long instanceId, int zone, string name, SceneType sceneType, StartSceneConfig startSceneConfig = null)
        {
            await ETTask.CompletedTask;
            Scene scene = EntitySceneFactory.CreateScene(id, instanceId, zone, sceneType, name, parent);

            scene.AddComponent <MailBoxComponent, MailboxType>(MailboxType.UnOrderMessageDispatcher);

            switch (scene.SceneType)
            {
            case SceneType.Realm:
                scene.AddComponent <NetKcpComponent, IPEndPoint, int>(new IPEndPoint(IPAddress.Any, startSceneConfig.OuterPort), SessionStreamDispatcherType.SessionStreamDispatcherServerOuter);
                break;

            case SceneType.Gate:
                scene.AddComponent <NetKcpComponent, IPEndPoint, int>(startSceneConfig.InnerIPOutPort, SessionStreamDispatcherType.SessionStreamDispatcherServerOuter);
                scene.AddComponent <PlayerComponent>();
                scene.AddComponent <GateSessionKeyComponent>();
                break;

            case SceneType.Map:
                scene.AddComponent <UnitComponent>();
                scene.AddComponent <AOISceneComponent, int>(9);
                break;

            case SceneType.Location:
                scene.AddComponent <LocationComponent>();
                break;

            case SceneType.Router:
                Log.Debug("Router:" + startSceneConfig.OuterPort);
                scene.AddComponent <RouterServiceComponent, IPEndPoint>(new IPEndPoint(IPAddress.Any, startSceneConfig.OuterPort));
                scene.AddComponent <RouterServiceInnerComponent>();
                break;
            }

            return(scene);
        }