protected override void OnUpdate() { var config = World.TinyEnvironment().GetConfigData <GameConfig>(); if (!EntityManager.Exists(World.TinyEnvironment().GetEntityByName("Food")) && config.FoodExist == false) { SceneService.LoadSceneAsync(config.FoodSceneReference); config.FoodExist = true; World.TinyEnvironment().SetConfigData(config); } var shouldSpawn = false; Entities.ForEach((Entity snakeEntity, ref SnakeHead snake, ref Translation snakeTransform) => { float3 snakeTrans = snakeTransform.Value; float3 foodTrans = new float3(); Entities.ForEach((Entity foodEntity, ref FoodTag foodTag, ref Translation foodTransform) => { foodTrans = foodTransform.Value; if (math.distance(snakeTrans, foodTrans) < 1) { MoveFood(foodEntity); shouldSpawn = true; } }); if (shouldSpawn) { snake.GrowTail = true; } }); }
static void Main(string[] args) { Orm.Instance.InitAsync().Wait(); Settings.Init(); MusicService.Init(); var mode = new VideoMode(800, 600); Window = new RenderWindow(mode, "Helen", Styles.Titlebar | Styles.Close); Window.Closed += (sender, args) => Close(args); Window.SetVerticalSyncEnabled(Settings.Instance.Vsync); // Services. SceneService.Init(Window); Fonts.Init(); Navigate(SceneService.TitleScene); while (Window.IsOpen) { lock (_lock) { CurrentScene.Progress(); Window.DispatchEvents(); Window.Clear(Color.Black); Window.Draw(CurrentScene); Window.Display(); } } }
/// <summary> /// Unloads a (non indestructable) scene at a certain index /// </summary> /// <param name="entityManager">Reference to the entitymanager instance</param> /// <param name="sceneNumber">The index of the LoadedScenesArray (only accessible if kept manualy)</param> /// <returns>A bool to mark the correct unloading of the scene</returns> private static bool UnloadScene(EntityManager entityManager, int sceneNumber) { Debug.Log("Unloading a scene"); try { NativeArray <ScenesLoaded> scenesLoaded = entityManager.GetBuffer <ScenesLoaded>(_sceneHandler).ToNativeArray(Allocator.Temp); if (!entityManager.HasComponent <Indestructable>(scenesLoaded[sceneNumber].referenceEntity)) { SceneService.UnloadSceneInstance(scenesLoaded[sceneNumber].referenceEntity); GetScenesLoadedBuffer(entityManager).RemoveAt(sceneNumber); var currentScene = entityManager.GetComponentData <SceneStatistics>(_sceneHandler); currentScene.currentScenesLoaded = entityManager.GetBuffer <ScenesLoaded>(_sceneHandler).Length; entityManager.SetComponentData(_sceneHandler, currentScene); scenesLoaded.Dispose(); return(true); } } catch (Exception e) { Debug.Log(e.ToString()); } return(false); }
static IEnumerator StartRoutine(QuickStartSettings settings) { SimulationWorldSystem.ClearAllSimulationWorlds(); SceneService.Load(Assets.emptyScene.name, LoadSceneMode.Additive, LocalPhysicsMode.Physics3D); yield return(null); // wait for scene load PlayerProfileService.Instance.SetPlayerProfile(settings.localProfileId); switch (settings.playMode) { case QuickStartSettings.PlayMode.Local: yield return(StartLocal(settings)); break; case QuickStartSettings.PlayMode.OnlineClient: yield return(StartClient(settings)); break; case QuickStartSettings.PlayMode.OnlineServer: yield return(StartServer(settings)); break; } SceneService.UnloadAsync(Assets.emptyScene); }
protected override void OnUpdate() { bool destroyAllShips = false; Entities.WithAll <ButtonDestroyShips>().ForEach((Entity entity, ref PointerInteraction pointerInteraction) => { if (pointerInteraction.clicked) { destroyAllShips = true; } }); if (destroyAllShips) { var env = World.TinyEnvironment(); var allyShips = env.GetConfigBufferData <AllyShips>().Reinterpret <SceneReference>().ToNativeArray(Unity.Collections.Allocator.Temp); for (int i = 0; i < allyShips.Length; i++) { SceneService.UnloadAllSceneInstances(allyShips[i]); } allyShips.Dispose(); var enemyShips = env.GetConfigBufferData <EnemyShips>().Reinterpret <SceneReference>().ToNativeArray(Unity.Collections.Allocator.Temp); for (int i = 0; i < enemyShips.Length; i++) { SceneService.UnloadAllSceneInstances(enemyShips[i]); } enemyShips.Dispose(); } }
private void OnLevelSet(Level level) { if (IsLevelStarted) { Log.Error("Cannot start another level (not yet implemented)"); return; } IsLevelStarted = true; PresentationHelpers.PresentationWorld.GetExistingSystem <TickSimulationSystem>().UnpauseSimulation(LEVEL_NOT_STARTED); if (Game.PlayingAsMaster) { // load simulation scenes PresentationHelpers.SubmitInput(new SimCommandLoadScene() { SceneName = SimManagersScene.SceneName }); foreach (SceneInfo scene in level.SimulationScenes) { PresentationHelpers.SubmitInput(new SimCommandLoadScene() { SceneName = scene.SceneName }); } } // instantiate presentation Game.InstantiateGameplayPresentationSystems(); // load presentation scenes foreach (SceneInfo scene in level.PresentationScenes) { SceneService.LoadAsync(scene.SceneName); } }
private void Start() { // Initialize loader loader = new ZenjectSceneLoader(this.GetComponent <SceneContext>(), this.GetComponentInParent <ProjectKernel>()); // If there is no instance of this class, set it. if (Instance == null) { Instance = this; if (SplashObj != null) { _canvasObj = Instantiate(SplashObj); _canvasObj.transform.SetParent(transform); _canvasObj.transform.position = Vector3.zero; _splashCanvasGroup = _canvasObj.GetComponentInChildren <CanvasGroup>(); _canvasObj.GetComponent <Canvas>().sortingOrder = 999; DontDestroyOnLoad(SplashObj); } Instance.StartCoroutine(LoadLevelFadeIn(DEFAULT_SCENE.Trim(), true, false)); } else { Debug.LogError("There is already a SceneController in the scene."); Destroy(this); } }
private void Start() { // If there is no instance of this class, set it. if (Instance == null) { DontDestroyOnLoad(gameObject); // Don't destroy this object Instance = this; if (SplashObj != null) { _canvasObj = Instantiate(SplashObj); _canvasObj.transform.SetParent(transform); _canvasObj.transform.position = Vector3.zero; _splashCanvasGroup = _canvasObj.GetComponent <CanvasGroup>(); _canvasObj.GetComponent <Canvas>().sortingOrder = 999; DontDestroyOnLoad(SplashObj); } BlackOverlay.GetComponent <Canvas>().sortingOrder = 998; Instance.StartCoroutine(LoadNextLevelFadeIn()); } else { Debug.LogError("There is already a SceneController in the scene."); Destroy(this); } }
public void GetAllScenes(HttpListenerContext context) { var request = context.Request; var response = context.Response; // 验证token string token = request.QueryString["token"]; if (!UserHandler.ValidateToken(token)) { ResponseTokenInvalid(context); return; } Dictionary <string, object> result = new Dictionary <string, object>(); result.Add("code", 0); List <object> data = new List <object>(); result.Add("data", data); List <Scene> scenes = SceneService.GetAllScenes(); for (int i = 0; i < scenes.Count; i++) { Scene scene = scenes[i]; data.Add(scene.ToJson()); } Response(context, result); }
IEnumerator SceneBuilder() { SceneService sceneSrv = GameContext.sceneSrv; sceneSrv.CreateSceneObj(cfgScene); _SetLoadPercent(5); yield return(new WaitForSeconds(1)); sceneSrv.LoadMapRes(); _SetLoadPercent(20); yield return(new WaitForSeconds(1)); sceneSrv.LoadMapInfo(); _SetLoadPercent(50); yield return(new WaitForSeconds(1)); UserObj user = null; sceneSrv.AddUserSelf(user); UserObj userOther = null; sceneSrv.AddUserOther(userOther); NpcObj npc = null; sceneSrv.AddNpcObj(npc); _SetLoadPercent(80); yield return(new WaitForSeconds(1)); sceneSrv.LoadStory(); sceneSrv.LoadUI(); _SetLoadPercent(100); yield return(new WaitForSeconds(1)); }
protected override void OnUpdate() { if (!SceneService.AreStartupScenesLoaded(World)) { return; } #if DEBUG var countEntsStart = GetNumEntities(); #endif Entity eMainView = FindMainViewNode(); if (eMainView == Entity.Null) { // we only build a default graph if there are no existing nodes - otherwise assume they are already built RenderDebug.Log("Auto building default render graph"); eMainView = BuildDefaultRenderGraph(1920, 1080); } // build light nodes for lights that have no node associated BuildAllLightNodes(eMainView); #if DEBUG var countEntsEnd = GetNumEntities(); if (countEntsEnd != countEntsStart) { RenderDebug.LogFormatAlways("Render graph builder added entities (was {0}, now {1})", countEntsStart, countEntsEnd); } #endif //Disable Render graph builder system. We need to create it only once Enabled = false; }
public HttpResponseMessage SelectByProjectId(int sequenceId) { ItemsResponse <Scene> response = new ItemsResponse <Scene>(); response.Items = SceneService.SelectBySequenceId(sequenceId); return(Request.CreateResponse(HttpStatusCode.OK, response)); }
public HttpResponseMessage SelectById(int id) { ItemResponse <Scene> response = new ItemResponse <Scene>(); response.Item = SceneService.SelectById(id); return(Request.CreateResponse(HttpStatusCode.OK, response)); }
public HttpResponseMessage Delete(int id) { SceneService.Delete(id); SuccessResponse response = new SuccessResponse(); return(Request.CreateResponse(HttpStatusCode.OK, response)); }
private void InitializeGame() { SceneService.InitializeCamera(); IsPlayerInputAllowed = true; TileGridService.PopulateTilesGrid(); GamePieceGridService.FillEmptyGamePieceGridSlots(10, 0.5f); // they are all empty in the beginning }
protected override void OnUpdate() { bool btnOn = false; Entities.WithAll <BtnStartTag>().ForEach((Entity entity, ref PointerInteraction pointerInteraction) => { if (pointerInteraction.clicked) { Debug.LogAlways("btn ret click"); btnOn = true; } }); if (btnOn) { // 盤面生成. Entities.ForEach(( ref PuzzleGen gen ) => { gen.IsGenerate = true; }); // ポーズ解除. Entities.ForEach(( ref GameMngr mngr ) => { mngr.IsPause = false; }); // タイトルシーンアンロード. SceneReference panelBase = new SceneReference(); panelBase = World.TinyEnvironment().GetConfigData <PanelConfig>().TitleScn; SceneService.UnloadAllSceneInstances(panelBase); } }
protected override void OnUpdate() { var env = World.TinyEnvironment(); var inputSystem = World.GetExistingSystem <InputSystem>(); var puzzleConfig = env.GetConfigData <PuzzleConfiguration>(); if (!puzzleConfig.IsCompleted) { return; } var buttonReplayEntity = Entity.Null; Entities.WithAll <ButtonReplay>().ForEach((Entity entity) => { buttonReplayEntity = entity; }); if (!EntityManager.Exists(buttonReplayEntity)) { return; } var buttonReplayPointerInteraction = EntityManager.GetComponentData <PointerInteraction>(buttonReplayEntity); if (buttonReplayPointerInteraction.clicked || inputSystem.GetKeyDown(KeyCode.Return)) { // Reload the scene var buttonReplay = EntityManager.GetComponentData <ButtonReplay>(buttonReplayEntity); SceneService.UnloadAllSceneInstances(buttonReplay.SceneToLoad); SceneService.LoadSceneAsync(buttonReplay.SceneToLoad); puzzleConfig.IsCompleted = false; env.SetConfigData(puzzleConfig); } }
protected override void OnUpdate() { bool isReq = false; Entities.ForEach(( ref TargetGenInfo gen ) => { if (!gen.Initialized) { gen.Initialized = true; gen.GeneratedCnt = 0; isReq = true; return; } // isReq = gen.IsRequested; }); if (isReq) { int recycled = 0; Entities.ForEach((Entity entity, ref TargetInfo info) => { info.IsActive = true; info.Initialized = false; ++recycled; }); var env = World.TinyEnvironment(); SceneReference tarBase = env.GetConfigData <GameConfig>().TargetScn; for (int i = 0; i < 12 - recycled; i++) { SceneService.LoadSceneAsync(tarBase); } } }
static void StopRoutine() { if (s_currentRoutine != null) { SceneService.UnloadAsync(Assets.emptyScene); CoroutineLauncherService.Instance?.StopCoroutine(s_currentRoutine); } }
public virtual void Enter(GameStateParam[] parameters) { if (Definition.SceneToLoadOnEnter != null && !SceneService.IsLoadedOrBeingLoaded(Definition.SceneToLoadOnEnter)) { _sceneLoadPromise = SceneService.Load(Definition.SceneToLoadOnEnter, Definition.SceneLoadSettings); _sceneLoadPromise.OnComplete += OnDefaultSceneLoaded; } }
public void TestScene() { var service = new SceneService(sceneName => { Assert.AreEqual("TestScene", sceneName); }); service.ChangeScene("TestScene"); }
void OnExitDoorTriggerEnter(Collider2D col) { Debug.Log("OnExitDoorTriggerEnter: " + col.gameObject.name); player.SetPlayerVisible(false); player.SetPlayerPosition(Map01SceneController.playerSpawnPosition); SceneService.LoadScene <Map02SceneController, Map01SceneController, TransitionSceneController>(false, delegate(Map01SceneController obj) { player.SetPlayerVisible(true); player.SetFaceDirection(facing_direction.down); }); }
void Start() { sceneService = new SceneService(); sceneService.Init(); sceneService.OpenMap(1); if (isCombineMesh) { CombineMesh(); } }
private void LoadStartupScenes(TinyEnvironment environment) { using (var startupScenes = environment.GetConfigBufferData <StartupScenes>().ToNativeArray(Allocator.Temp)) { for (var i = 0; i < startupScenes.Length; ++i) { SceneService.LoadSceneAsync(m_World, startupScenes[i].SceneReference); } } }
public HttpResponseMessage Insert(SceneAddRequest model) { if (!ModelState.IsValid) { return(Request.CreateResponse(HttpStatusCode.BadRequest, ModelState)); } ItemResponse <int> response = new ItemResponse <int>(); response.Item = SceneService.Insert(model); return(Request.CreateResponse(HttpStatusCode.OK, response)); }
public SceneServiceTest() { var _sceneRepo = new Mock <ISceneRepository>(); var _backgroundRepo = new Mock <IVRBackgroundRepository>(); _sceneService = new SceneService(_sceneRepo.Object, _backgroundRepo.Object); _sceneRepo.Setup(x => x.GetScenesWithCourseId(0)).Returns(scenes); _sceneRepo.Setup(x => x.Get(0)).Returns(scene); _sceneRepo.Setup(x => x.GetSceneTitleWithSceneId(0)).Returns("Scene Title"); }
public HttpResponseMessage Update(SceneUpdateRequest model) { if (!ModelState.IsValid) { return(Request.CreateResponse(HttpStatusCode.BadRequest, ModelState)); } SceneService.Update(model); SuccessResponse response = new SuccessResponse(); return(Request.CreateResponse(HttpStatusCode.OK, response)); }
protected override void OnUpdate() { bool btnOn = false; Entities.WithAll <BtnRetryTag>().ForEach((Entity entity, ref PointerInteraction pointerInteraction) => { if (pointerInteraction.clicked) { //Debug.LogAlways("btn ret click"); btnOn = true; } }); if (btnOn) { var env = World.TinyEnvironment(); /*SceneService.UnloadAllSceneInstances( env.GetConfigData<GameConfig>().PrefabBlock ); * SceneService.UnloadAllSceneInstances( env.GetConfigData<GameConfig>().PrefabBlockStay ); * SceneService.UnloadAllSceneInstances( env.GetConfigData<GameConfig>().PrefabStar );*/ SceneService.UnloadAllSceneInstances(env.GetConfigData <GameConfig>().ResultScn); // 各種パラメータ初期化. Entities.ForEach(( ref FirstSetInfo info ) => { info.Initialized = false; }); Entities.ForEach(( ref InitBlockInfo info ) => { info.Initialized = false; }); // ポーズ解除 & 初期化. Entities.ForEach(( ref GameMngr mngr ) => { mngr.IsPause = false; mngr.Mode = GameMngrSystem.MdGame; mngr.Score = 0; mngr.GameTimer = 0; mngr.ModeTimer = 0; }); Entities.ForEach(( ref GeneratorInfo info ) => { info.Initialized = false; }); // スコア表示. Entities.WithAll <TextScoreTag>().ForEach(( Entity entity ) => { EntityManager.SetBufferFromString <TextString>(entity, "0"); }); } }
private static void LoadStartupScenes() { using (var startupScenes = m_Environment.GetConfigBufferData <StartupScenes>().ToNativeArray(Allocator.Temp)) { var em = m_World.EntityManager; for (var i = 0; i < startupScenes.Length; ++i) { SceneService.LoadSceneAsync(startupScenes[i].SceneReference); } } }
//dont destroy this instance void Awake() { if (instance == null) { instance = this; DontDestroyOnLoad(gameObject); } else if (instance != this) { Destroy(gameObject); } }