Ejemplo n.º 1
0
        public static async ETTask <Scene> Create(Entity parent, long id, int zone, string name, SceneType sceneType, StartSceneConfig startSceneConfig = null)
        {
            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 <NetOuterComponent, string>(startSceneConfig.OuterAddress);
                break;

            case SceneType.Gate:
                scene.AddComponent <NetOuterComponent, string>(startSceneConfig.OuterAddress);
                scene.AddComponent <PlayerComponent>();
                scene.AddComponent <GateSessionKeyComponent>();
                break;

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

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

            return(scene);
        }
Ejemplo n.º 2
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;

            Log.Info($"create scene: {sceneType} {name} {zone}");
            Scene scene = EntitySceneFactory.CreateScene(id, instanceId, zone, sceneType, name, parent);

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

            switch (scene.SceneType)
            {
            case SceneType.Robot:
                scene.AddComponent <RobotManagerComponent>();
                break;
            }

            return(scene);
        }
Ejemplo n.º 3
0
        public static Scene CreateZoneScene(int zone, string name)
        {
            Scene zoneScene = EntitySceneFactory.CreateScene(Game.IdGenerater.GenerateId(), zone, SceneType.Zone, name, Game.Scene);

            ResourcesComponent.Instance.LoadBundle("Role.unity3d");
            ResourcesComponent.Instance.LoadBundle("Shell.unity3d");
            ResourcesComponent.Instance.LoadBundle("Trap.unity3d");
            ResourcesComponent.Instance.LoadBundle("Tower.unity3d");
            ResourcesComponent.Instance.LoadBundle("Trigger.unity3d");

            zoneScene.AddComponent <ZoneSceneFlagComponent>();
            zoneScene.AddComponent <NetKcpComponent>();
            zoneScene.AddComponent <SceneChangeComponent>();
            zoneScene.AddComponent <DOperaComponent>();
            zoneScene.AddComponent <PVPComponent, bool>(true);
            zoneScene.AddComponent <GamerComponent>();
            zoneScene.AddComponent <DUnitComponent>();

            // mainScene.AddComponent<AIComponent, int>(1);

            // 初始化UI层
            zoneScene.AddComponent <UIEventComponent>();
            zoneScene.AddComponent <UIComponent>();

            return(zoneScene);
        }
Ejemplo n.º 4
0
        public static Scene CreateCurrentScene(long id, int zone, string name, CurrentScenesComponent currentScenesComponent)
        {
            Scene currentScene = EntitySceneFactory.CreateScene(id, IdGenerater.Instance.GenerateInstanceId(), zone, SceneType.Current, name, currentScenesComponent);

            currentScenesComponent.Scene = currentScene;

            Game.EventSystem.Publish(currentScene, new EventType.AfterCreateCurrentScene());
            return(currentScene);
        }
Ejemplo n.º 5
0
        public static Scene CreateZoneScene(long id, int zone, string name)
        {
            Scene zoneScene = EntitySceneFactory.CreateScene(id, zone, SceneType.Zone, name, Game.Scene);

            zoneScene.AddComponent <NetOuterComponent>();
            zoneScene.AddComponent <ResourcesComponent>();
            zoneScene.AddComponent <PlayerComponent>();
            zoneScene.AddComponent <UnitComponent>();

            return(zoneScene);
        }
Ejemplo n.º 6
0
        public static async ETTask <Scene> CreateZoneScene(long id, int zone, string name)
        {
            Scene zoneScene = EntitySceneFactory.CreateScene(id, zone, SceneType.Zone, name, Game.Scene);

            zoneScene.AddComponent <NetOuterComponent>();
            zoneScene.AddComponent <PlayerComponent>();
            zoneScene.AddComponent <UnitComponent>();

            await Game.EventSystem.Publish(new EventType.AfterCreateZoneScene());

            return(zoneScene);
        }
Ejemplo n.º 7
0
        public static async ETTask <Scene> CreateClientScene(int zone, string name, Entity parent)
        {
            await ETTask.CompletedTask;

            Scene clientScene = EntitySceneFactory.CreateScene(zone, SceneType.Client, name, parent);

            clientScene.AddComponent <ClientSceneFlagComponent>();

            clientScene.AddComponent <CurrentScenesComponent>();
            clientScene.AddComponent <ObjectWait>();
            clientScene.AddComponent <PlayerComponent>();

            Game.EventSystem.Publish(clientScene, new EventType.AfterCreateClientScene());
            return(clientScene);
        }
Ejemplo n.º 8
0
        public static async ETTask <Scene> CreateZoneScene(int zone, string name)
        {
            Scene zoneScene = EntitySceneFactory.CreateScene(Game.IdGenerater.GenerateId(), zone, SceneType.Zone, name, Game.Scene);

            zoneScene.AddComponent <ZoneSceneFlagComponent>();
            zoneScene.AddComponent <NetKcpComponent>();
            zoneScene.AddComponent <UnitComponent>();

            // UI层的初始化
            await Game.EventSystem.Publish(new EventType.AfterCreateZoneScene()
            {
                ZoneScene = zoneScene
            });

            return(zoneScene);
        }
Ejemplo n.º 9
0
        public static Scene CreateZoneScene(int zone, string name, Entity parent)
        {
            Scene zoneScene = EntitySceneFactory.CreateScene(Game.IdGenerater.GenerateInstanceId(), zone, SceneType.Zone, name, parent);

            zoneScene.AddComponent <ZoneSceneFlagComponent>();
            zoneScene.AddComponent <NetKcpComponent, int>(SessionStreamDispatcherType.SessionStreamDispatcherClientOuter);
            zoneScene.AddComponent <CurrentScenesComponent>();
            zoneScene.AddComponent <ObjectWait>();
            zoneScene.AddComponent <PlayerComponent>();

            Game.EventSystem.Publish(new EventType.AfterCreateZoneScene()
            {
                ZoneScene = zoneScene
            });
            return(zoneScene);
        }
Ejemplo n.º 10
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.Router:
                scene.AddComponent <RouterComponent, IPEndPoint, string>(startSceneConfig.OuterIPPort,
                                                                         startSceneConfig.StartProcessConfig.InnerIP
                                                                         );
                break;

            case SceneType.RouterManager:
                scene.AddComponent <HttpComponent, string>($"http://{startSceneConfig.OuterIPPort}/");
                break;

            case SceneType.Realm:
                scene.AddComponent <NetKcpComponent, IPEndPoint, int>(startSceneConfig.InnerIPOutPort, CallbackType.SessionStreamDispatcherServerOuter);
                break;

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

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

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

            case SceneType.Robot:
                scene.AddComponent <RobotManagerComponent>();

                break;
            }

            return(scene);
        }
Ejemplo n.º 11
0
        public static async ETTask <Scene> CreateZoneScene(int zone, string name, Entity parent)
        {
            Scene zoneScene = EntitySceneFactory.CreateScene(Game.IdGenerater.GenerateInstanceId(), zone, SceneType.Zone, name, parent);

            zoneScene.AddComponent <ZoneSceneFlagComponent>();
            zoneScene.AddComponent <NetKcpComponent, int>(SessionStreamDispatcherType.SessionStreamDispatcherClientOuter);
            zoneScene.AddComponent <UnitComponent>();
            zoneScene.AddComponent <AIComponent, int>(1);

            // UI层的初始化
            await Game.EventSystem.PublishAsync(new EventType.AfterCreateZoneScene()
            {
                ZoneScene = zoneScene
            });

            return(zoneScene);
        }
Ejemplo n.º 12
0
        public static async ETTask <Scene> CreateZoneScene(int zone, string name)
        {
            Scene zoneScene = EntitySceneFactory.CreateScene(Game.IdGenerater.GenerateId(), zone, SceneType.Zone, name, Game.Scene);

            zoneScene.AddComponent <ZoneSceneFlagComponent>();
            zoneScene.AddComponent <NetKcpComponent>();
            zoneScene.AddComponent <UnitComponent>();


            // 添加AI组件          ---资源加载需要更改为addressables,暂时注释 @yzx 2021.5.20
            // zoneScene.AddComponent<AIComponent, int>(1);

            // UI层的初始化
            await Game.EventSystem.Publish(new EventType.AfterCreateZoneScene()
            {
                ZoneScene = zoneScene
            });

            return(zoneScene);
        }