Beispiel #1
0
        public override async ETTask Run(EventType.AppStart args)
        {
            Game.Scene.AddComponent <TimerComponent>();


            // 下载ab包
            //await BundleHelper.DownloadBundle("1111");

            // 加载配置
            Game.Scene.AddComponent <ResourcesComponent>();

            ResourcesComponent.Instance.LoadBundle("config.unity3d");
            Game.Scene.AddComponent <ConfigComponent>();
            ResourcesComponent.Instance.UnloadBundle("config.unity3d");

            Game.Scene.AddComponent <OpcodeTypeComponent>();
            Game.Scene.AddComponent <MessageDispatcherComponent>();
            Game.Scene.AddComponent <UIEventComponent>();


            Scene zoneScene = await SceneFactory.CreateZoneScene(1, 0, "Game");

            await Game.EventSystem.Publish(new EventType.AppStartInitFinish()
            {
                ZoneScene = zoneScene
            });
        }
Beispiel #2
0
 public window()
 {
     Thread.CurrentThread.Name = "Primary - ";
     InitializeComponent();
     sf = new SceneFactory();
     //scene = new SingleSphere(this);
     //scene = sf.CreateMultipleSphere(this);
     //scene = sf.CreateBallsScene2(this);
     //scene = sf.CreateAmbientOcclusion(this);
     //scene = sf.CreateAreaLighting(this);
     //scene = sf.CreateObjectTest(this);
     //scene = sf.CreateEnvironmentLight(this);
     //scene = sf.CreateObjectsSSFloat(this);
     //scene = sf.CreateTriangleScene(this);
     //scene = sf.CreateTorusScene(this);
     //scene = sf.CreateSolidCylinderScene(this);
     //scene = sf.CreateSolidConeScene(this);
     //scene = sf.CreateAnnulusScene(this);
     //scene = sf.CreateBowlScene(this);
     //scene = sf.CreateInstanceScene(this);
     //scene = sf.CreateBeveledCylinderScene(this);
     //scene = sf.CreateRandomSpheres(this);
     //scene = sf.CreateGridAndTransformedObject1(this);
     //scene = sf.CreateGridAndTransformedObject2(this);
     //scene = sf.CreateTessellateSphere(this);
     //scene = sf.CreateReflectiveObjects(this);
     //scene = sf.CreateGlossyReflectorTest1(this);
     //scene = sf.CreatePathTracingTest(this);
     //scene = sf.CreatePerfectTransmitterTest(this);
     //scene = sf.CreateGlobalTraceTest(this);
     //scene = sf.CreateGlassWithLiquid(this);
     scene = sf.CreateEarthScene(this);
 }
Beispiel #3
0
    static public SceneFactory createFactory(GAME_SCENE_TYPE type, Type classType)
    {
        object[]     param   = new object[] { type, classType };    //构造器参数
        SceneFactory factory = Activator.CreateInstance(typeof(SceneFactory), param) as SceneFactory;

        return(factory);
    }
Beispiel #4
0
        /// <summary/>
        public static Visual3D[] MakeScene(Variation v)
        {
            v.AssertExistenceOf("Scene");

            string scene = v["Scene"];

            if (scene == "Explicit")
            {
                v.AssertExistenceOf("Visual0");
                return(MakeVisuals(v, "Visual"));
            }
            else if (scene == "VisualPerModel")
            {
                v.AssertExistenceOf("Visual0");
                Visual3D[] visuals = MakeVisuals(v, "Visual");
                ExpandModelGroups(visuals);
                return(visuals);
            }
            else
            {
                ModelVisual3D visual = new ModelVisual3D();
                visual.Content = SceneFactory.MakeScene(scene);
                return(new Visual3D[] { visual });
            }
        }
    public SceneFactory addFactory(Type classType, GAME_SCENE_TYPE type)
    {
        SceneFactory factory = SceneFactory.createFactory(type, classType);

        mFactoryList.Add(factory.getType(), factory);
        return(factory);
    }
Beispiel #6
0
        public async ETVoid RunAsync()
        {
            Game.Scene.AddComponent <ConfigComponent>();

            Options            options       = Game.Scene.GetComponent <Options>();
            StartProcessConfig processConfig = StartProcessConfigCategory.Instance.Get(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 <ConsoleComponent>();

            Game.Scene.AddComponent <NetInnerComponent, string>(processConfig.InnerAddress);

            var processScenes = StartSceneConfigCategory.Instance.GetByProcess(IdGenerater.Process);

            foreach (StartSceneConfig startConfig in processScenes)
            {
                await SceneFactory.Create(Game.Scene, startConfig.SceneId, startConfig.Zone, startConfig.Name, startConfig.Type, startConfig);
            }
        }
Beispiel #7
0
        // 场景切换协程
        public static async ETTask SceneChangeTo(Scene zoneScene, string sceneName, long sceneInstanceId)
        {
            // zoneScene.RemoveComponent<AIComponent>();
            zoneScene.AddComponent <KeyCodeComponent>();
            CurrentScenesComponent currentScenesComponent = zoneScene.GetComponent <CurrentScenesComponent>();

            currentScenesComponent.Scene?.Dispose(); // 删除之前的CurrentScene,创建新的
            Scene currentScene = SceneFactory.CreateCurrentScene(sceneInstanceId, zoneScene.Zone, sceneName, currentScenesComponent);

            currentScene.AddComponent <UnitComponent>();
            currentScene.AddComponent <AOISceneComponent, int>(6);
            // 可以订阅这个事件中创建Loading界面
            using (ListComponent <ETTask> tasks = ListComponent <ETTask> .Create())
            {
                tasks.Add(WaitChangeScene(zoneScene, sceneName)); //等收到消息并且地图创建完成
                tasks.Add(WaitCreateMyUnit(zoneScene));           // 等待CreateMyUnit的消息
                await ETTaskHelper.WaitAll(tasks);
            }
            M2C_CreateMyUnit m2CCreateMyUnit = waitCreateMyUnit.Message;

            UnitFactory.Create(currentScene, m2CCreateMyUnit.Unit);
            // zoneScene.AddComponent<AIComponent,int>(1);

            await Game.EventSystem.PublishAsync(new EventType.SceneChangeFinish()
            {
                ZoneScene = zoneScene, CurrentScene = currentScene
            });

            // 通知等待场景切换的协程
            zoneScene.GetComponent <ObjectWait>().Notify(new WaitType.Wait_SceneChangeFinish());
        }
Beispiel #8
0
        protected override async ETTask Run(EventType.AppStart args)
        {
            Game.Scene.AddComponent <TimerComponent>();
            Game.Scene.AddComponent <CoroutineLockComponent>();

            // 加载配置
            Game.Scene.AddComponent <ResourcesComponent>();
            ResourcesComponent.Instance.LoadBundle("config.unity3d");
            Game.Scene.AddComponent <ConfigComponent>();
            ConfigComponent.GetAllConfigBytes = LoadConfigHelper.LoadAllConfigBytes;
            await ConfigComponent.Instance.LoadAsync();

            ResourcesComponent.Instance.UnloadBundle("config.unity3d");

            Game.Scene.AddComponent <OpcodeTypeComponent>();
            Game.Scene.AddComponent <MessageDispatcherComponent>();

            Game.Scene.AddComponent <NetThreadComponent>();

            ResourcesComponent.Instance.LoadBundle("unit.unity3d");

            Scene zoneScene = await SceneFactory.CreateZoneScene(1, 1, "Game");

            await Game.EventSystem.Publish(new EventType.AppStartInitFinish()
            {
                ZoneScene = zoneScene
            });
        }
Beispiel #9
0
        // 场景切换协程
        public static async ETTask SceneChangeTo(Scene zoneScene, string sceneName, long sceneInstanceId)
        {
            zoneScene.RemoveComponent <AIComponent>();

            CurrentScenesComponent currentScenesComponent = zoneScene.GetComponent <CurrentScenesComponent>();

            currentScenesComponent.Scene?.Dispose(); // 删除之前的CurrentScene,创建新的
            Scene         currentScene  = SceneFactory.CreateCurrentScene(sceneInstanceId, zoneScene.Zone, sceneName, currentScenesComponent);
            UnitComponent unitComponent = currentScene.AddComponent <UnitComponent>();

            // 可以订阅这个事件中创建Loading界面
            Game.EventSystem.Publish(new EventType.SceneChangeStart()
            {
                ZoneScene = zoneScene
            });

            // 等待CreateMyUnit的消息
            WaitType.Wait_CreateMyUnit waitCreateMyUnit = await zoneScene.GetComponent <ObjectWait>().Wait <WaitType.Wait_CreateMyUnit>();

            M2C_CreateMyUnit m2CCreateMyUnit = waitCreateMyUnit.Message;
            Unit             unit            = UnitFactory.Create(currentScene, m2CCreateMyUnit.Unit);

            unitComponent.Add(unit);

            zoneScene.RemoveComponent <AIComponent>();

            Game.EventSystem.Publish(new EventType.SceneChangeFinish()
            {
                ZoneScene = zoneScene, CurrentScene = currentScene
            });

            // 通知等待场景切换的协程
            zoneScene.GetComponent <ObjectWait>().Notify(new WaitType.Wait_SceneChangeFinish());
        }
Beispiel #10
0
        protected override async ETTask Run(EventType.AppStart args)
        {
            Game.Scene.AddComponent <TimerComponent>();
            Game.Scene.AddComponent <CoroutineLockComponent>();

            // 加载配置
            Game.Scene.AddComponent <ResourcesComponent>();
            await ResourcesComponent.Instance.LoadBundleAsync("config.unity3d");

            Game.Scene.AddComponent <ConfigComponent>();
            ConfigComponent.Instance.Load();
            ResourcesComponent.Instance.UnloadBundle("config.unity3d");

            Game.Scene.AddComponent <OpcodeTypeComponent>();
            Game.Scene.AddComponent <MessageDispatcherComponent>();

            Game.Scene.AddComponent <NetThreadComponent>();
            Game.Scene.AddComponent <SessionStreamDispatcher>();
            Game.Scene.AddComponent <ZoneSceneManagerComponent>();

            Game.Scene.AddComponent <GlobalComponent>();
            Game.Scene.AddComponent <NumericWatcherComponent>();
            Game.Scene.AddComponent <AIDispatcherComponent>();
            await ResourcesComponent.Instance.LoadBundleAsync("unit.unity3d");

            Scene zoneScene = SceneFactory.CreateZoneScene(1, "Game", Game.Scene);

            await Game.EventSystem.PublishAsync(new EventType.AppStartInitFinish()
            {
                ZoneScene = zoneScene
            });
        }
Beispiel #11
0
        protected override async ETTask Run(EventType.AppStart args)
        {
            Game.Scene.AddComponent <TimerComponent>();
            Game.Scene.AddComponent <CoroutineLockComponent>();

            Game.Scene.AddComponent <ConfigComponent>();
            await ConfigComponent.Instance.LoadAsync();

            Game.Scene.AddComponent <OpcodeTypeComponent>();
            Game.Scene.AddComponent <MessageDispatcherComponent>();

            Game.Scene.AddComponent <NetThreadComponent>();

            Game.Scene.AddComponent <ZoneSceneManagerComponent>();

            Game.Scene.AddComponent <GlobalComponent>();

            Game.Scene.AddComponent <AIDispatcherComponent>();

            Scene zoneScene = await SceneFactory.CreateZoneScene(1, "Game", Game.Scene);

            //显示登陆界面
            await Game.EventSystem.Publish(new EventType.AppStartInitFinish()
            {
                ZoneScene = zoneScene
            });
        }
 public override void Run()
 {
     foreach (StartConfig startConfig in StartConfigComponent.Instance.StartConfig.List)
     {
         SceneConfig sceneConfig = startConfig.GetComponent <SceneConfig>();
         SceneFactory.Create(Game.Scene, startConfig.Id, sceneConfig.Name, sceneConfig.SceneType);
     }
 }
Beispiel #13
0
        public void GenerateNewScene()
        {
            SceneFactory factory = new SceneFactory(ActorFactory.Object);

            var scene = factory.Generate(new SceneTemplate(), "Default");

            Assert.NotNull(scene);
        }
Beispiel #14
0
    public void LoadAndStart(SceneFactory sceneFactory)
    {
        this.sceneFactory = sceneFactory;
        sceneFactory.PreloadAssets();

        currentScene = sceneFactory.GetFirstScene();
        currentScene.Setup(Time.time);
        SkipToScene(skipToSceneNumber);
    }
        public async ETVoid RunInner()
        {
            var processScenes = StartSceneConfigCategory.Instance.GetByProcess(IdGenerater.Process);

            foreach (StartSceneConfig startConfig in processScenes)
            {
                await SceneFactory.Create(Game.Scene, startConfig.SceneId, startConfig.Zone, startConfig.Name, startConfig.Type, startConfig);
            }
        }
Beispiel #16
0
 void LoadContent3()
 {
     gs.RootScene.AddUpdateSystem(new GameStateSystem());
     gs.RootScene.NewEntity().AddComponent(new GameStateComponent()).Enable();
     gs.RootScene.AddScene(SceneFactory.NewMenuScene(gs, "menu")).Enable();
     SoundManager.PlayMusic("Dance_Plague_of_2020");
     //SoundManager.PlayMusic("");
     InputManager.Reset();
 }
Beispiel #17
0
    // 添加一个场景工厂
    public void AddSceneFctory(SceneFactory factory)
    {
        if (mFactorys.ContainsKey(factory.GetSceneType()))
        {
            GameDebug.LogError("SceneManager contains same SceneFactory!");
            return;
        }

        mFactorys.Add(factory.GetSceneType(), factory);
    }
Beispiel #18
0
 public static void Main(string[] args)
 {
     for (int i = 0; i < 100; i++)
     {
         ISceneFactory sceneGenerator = new SceneFactory(new DefaultActorFactory());
         IScene        scene          = sceneGenerator.GetScene("Default", "None");
         IRenderable   renderable     = new ASCIIFileRenerer();
         renderable.RenderScene(scene);
     }
 }
Beispiel #19
0
        public void RenderMarblesAxis()
        {
            var scene  = SceneFactory.CreateMarblesAxisScene();
            var camera = new Camera(
                new PosVector(50.0, 30.0, 50.0),
                new PosVector(-0.1, 0.1, 0.0),
                new PosVector(0.0, 0.0, 1.0),
                50.0);

            Render(new PixelArray(RenderData.Width, RenderData.Height), scene, camera, "marblesaxis");
        }
Beispiel #20
0
    //----------------------------------------------------------------------------------------------
    protected GameScene createScene(GAME_SCENE_TYPE type)
    {
        SceneFactory factory = mSceneFactoryManager.getFactory(type);

        if (factory != null)
        {
            string name = factory.getClassType().ToString();
            return(factory.createScene(name));
        }
        return(null);
    }
Beispiel #21
0
        public void RenderBasics()
        {
            var scene  = SceneFactory.CreateBasicScene();
            var camera = new Camera(
                new PosVector(7.5, 7.5, 2.3),
                new PosVector(0.0, 0.0, 0.0),
                new PosVector(0.0, 0.0, 1.0),
                50.0);

            Render(new PixelArray(RenderData.Width, RenderData.Height), scene, camera, "basic");
        }
        public void SelectsWelcomeAndShowsWelcome()
        {
            // Arrange
            var factory = new SceneFactory();
            var welcome = factory.GetScene(SceneEnum.Welcome);

            // Act
            var result = welcome.Show();

            // Assert
            Assert.AreEqual("Welcome", result);
        }
        public void SelectsEndAndShowsEnd()
        {
            // Arrange
            var factory = new SceneFactory();
            var welcome = factory.GetScene(SceneEnum.End);

            // Act
            var result = welcome.Show();

            // Assert
            Assert.AreEqual("End", result);
        }
Beispiel #24
0
    public void AddDiedCount()
    {
        diedCount++;
        lives--;

        if (lives == 0)
        {
            currentState = SceneState.SummaryScreen;
            scene        = SceneFactory.Create(currentState);
            SceneManager.LoadScene(currentState.ToString());
        }
    }
Beispiel #25
0
 public void NextScene()
 {
     if (currentState == SceneState.SummaryScreen)
     {
         Init();
     }
     else
     {
         currentState++;
         scene = SceneFactory.Create(currentState);
     }
     SceneManager.LoadScene(currentState.ToString());
 }
Beispiel #26
0
 public void MainWindowIsNull()
 {
     SceneFactory target = new SceneFactory();
     Exception actual = null;
     try
     {
         Screen screen = target.CreateScene(null, 7);
     }
     catch (NullReferenceException e) {
         actual = e;
     }
     Assert.IsNotNull(actual);
 }
Beispiel #27
0
        private void RenderButton_OnClick(object sender, RoutedEventArgs e)
        {
            var scene  = SceneFactory.CreateBasicScene();
            var camera = new Camera(
                new PosVector(7.5, 7.5, 2.3),
                new PosVector(0.0, 0.0, 0.0),
                new PosVector(0.0, 0.0, 1.0),
                50.0);
            var pixelArray = new WpfPixelArray(Dispatcher, _renderData.Width, _renderData.Height);

            RenderImage.Source = pixelArray.WriteableBitmap;
            Render(pixelArray, scene, camera, "basic");
        }
Beispiel #28
0
    protected override void LoadContent()
    {
        var spriteRenderer = new SpriteRenderer(graphics, Content);
        prompt = new Prompt(spriteRenderer, Content);
        messageBox = new MessageBox(Content, spriteRenderer);
        var sounds = new Sounds();
        sceneManager = new SceneManager(new LoopTracker(sounds),
                                        new MessagePromptCoordinator(prompt, messageBox));
        var sceneFactory = new SceneFactory(sceneManager, spriteRenderer);

        // create the scene objects and preload their content
        sceneManager.LoadAndStart(sceneFactory);
    }
Beispiel #29
0
        //SystemReferences sys;
        //public GameStateSystem(SystemReferences sys) { this.sys = sys; }

        public override void Update(GameTime gameTime)
        {
            //ComponentGroup<GameStateComponent> gsc = scene.GetComponentGroup<GameStateComponent>();
            if (!scene.GetComponentGroup <GameStateComponent>().TryGetFirstEnabled(out GameStateComponent gsc))
            {
                return;
            }
            string request = gsc.Command;

            if (request == null)
            {
                return;
            }
            if (request == "danmaku")
            {
                scene.AddScene(SceneFactory.NewDanmakuScene(gs, "danmaku")).Enable();
                InputManager.Reset();
            }
            if (request == "options")
            {
                scene.AddScene(SceneFactory.NewOptionsScene(gs, "options")).Enable();
                InputManager.Reset();
            }
            if (request == "controls")
            {
                scene.AddScene(SceneFactory.NewControlsScene(gs, "controls")).Enable();
                InputManager.Reset();
            }
            if (request == "return")
            {
                scene.RemoveLastScene();
                InputManager.Reset();
            }
            if (request == "quit")
            {
                gs.Game.Exit();
            }

            /*
             * string[] parts = request.Split(' ');
             * if (parts.Length >= 2)
             * {
             *  if (parts[0] == "talk")
             *  {
             *      scene.AddScene(SceneFactory.NewTalkScene(gs, "talk", parts[1])).Enable();
             *  }
             * }
             */
            gsc.Command = null;
        }
Beispiel #30
0
 public void NegativIndex()
 {
     SceneFactory target = new SceneFactory();
     Exception actual = null;
     try
     {
         Screen screen = target.CreateScene(new StartUpViewModel(), -1);
     }
     catch (InvalidIndexExceptionForScene e)
     {
         actual = e;
     }
     Assert.IsNotNull(actual);
 }
Beispiel #31
0
    public void Init()
    {
        levelTime = new float[TOTAL_LEVEL];
        for (int i = 0; i < levelTime.Length; i++)
        {
            levelTime[i] = 0;
        }

        lives     = 10;
        diedCount = 0;
        score     = 0;
        moveCount = 0;

        currentState = SceneState.StartScreen;
        scene        = SceneFactory.Create(currentState);
    }
Beispiel #32
0
 internal void InjectDependencies(FearResourceManager resMan,
                                  Input fearInput,
                                  GameObjectFactory gameObjFactory,
                                  UpdateableFactory updateableFac,
                                  SceneFactory sceneFac,
                                  LightFactory lightFac,
                                  CameraFactory cameraFac)
 {
     resourceManager   = resMan;
     input             = fearInput;
     gameObjectFactory = gameObjFactory;
     updateableFactory = updateableFac;
     sceneFactory      = sceneFac;
     lightFactory      = lightFac;
     cameraFactory     = cameraFac;
 }