private IEnumerator gameOver() { SceneSystem.ChangeScene("GameOver"); //等待上升动画 yield return(new WaitForSeconds(2)); GameMessageManager.ResetGameMessage(); while (true) { yield return(0); if (GameMessageManager.GetGameMessage(GameMessage.Start)) { BackToMenu(); break; } } yield return(0); }
private void SetDropDownLayout() { SceneSystem.SetFocus(_dropdown); // Dropdown won't cover the entire screen now. _dropdownBox.SetAttachedProperty(CanvasPanel.AnchorProperty, CanvasPanel.Anchor.TopLeft); _dropdownBox.SetAttachedProperty(CanvasPanel.AutoSizeProperty, true); // Force the dropdown to our width _dropdownBox.FixedWidth = ContentRectangle.Width; // Measure the box. var m = _dropdownBox.Measure(); // Figure out where, vertically, the box should be placed. var y = Math.Min(ContentRectangle.Bottom, SceneSystem.BoundingBox.Height - m.Y); // Set the position on the gui canvas. _dropdownBox.SetAttachedProperty(CanvasPanel.PositionProperty, new Vector2(ContentRectangle.Left, y)); }
public SceneRenderer(GameSettingsAsset gameSettings) { if (gameSettings == null) { throw new ArgumentNullException(nameof(gameSettings)); } // Initialize services Services = new ServiceRegistry(); ContentManager = new ContentManager(Services); var renderingSettings = gameSettings.Get <RenderingSettings>(); GraphicsDevice = GraphicsDevice.New(DeviceCreationFlags.None, new[] { renderingSettings.DefaultGraphicsProfile }); var graphicsDeviceService = new GraphicsDeviceServiceLocal(Services, GraphicsDevice); EffectSystem = new EffectSystem(Services); GraphicsContext = new GraphicsContext(new CommandList(GraphicsDevice), new ResourceGroupAllocator(GraphicsDevice)); Services.AddService(typeof(GraphicsContext), GraphicsContext); SceneSystem = new SceneSystem(Services); // Create game systems GameSystems = new GameSystemCollection(Services); GameSystems.Add(new GameFontSystem(Services)); GameSystems.Add(new UISystem(Services)); GameSystems.Add(EffectSystem); GameSystems.Add(SceneSystem); GameSystems.Initialize(); // Fake presenter // TODO GRAPHICS REFACTOR: This is needed be for render stage setup GraphicsDevice.Presenter = new RenderTargetGraphicsPresenter(GraphicsDevice, Texture.New2D(GraphicsDevice, renderingSettings.DefaultBackBufferWidth, renderingSettings.DefaultBackBufferHeight, renderingSettings.ColorSpace == ColorSpace.Linear ? PixelFormat.R8G8B8A8_UNorm_SRgb : PixelFormat.R8G8B8A8_UNorm, TextureFlags.ShaderResource | TextureFlags.RenderTarget), PixelFormat.D24_UNorm_S8_UInt); SceneSystem.MainRenderFrame = RenderFrame.FromTexture(GraphicsDevice.Presenter.BackBuffer, GraphicsDevice.Presenter.DepthStencilBuffer); }
protected override void OnSystemAdd() { physicsSystem = (Bullet2PhysicsSystem)Services.GetServiceAs <IPhysicsSystem>(); if (physicsSystem == null) { physicsSystem = new Bullet2PhysicsSystem(Services); var game = Services.GetServiceAs <IGame>(); game?.GameSystems.Add(physicsSystem); } debugShapeRendering = Services.GetServiceAs <PhysicsShapesRenderingService>(); if (debugShapeRendering == null) { debugShapeRendering = new PhysicsShapesRenderingService(Services); var game = Services.GetServiceAs <IGame>(); game?.GameSystems.Add(debugShapeRendering); } Simulation = physicsSystem.Create(this); sceneSystem = Services.GetSafeServiceAs <SceneSystem>(); }
public TestCameraProcessor() { var services = new ServiceRegistry(); // Create entity manager and camera entityManager = new CustomEntityManager(services); // Create graphics compositor graphicsCompositor = new GraphicsCompositor(); sceneSystem = new SceneSystem(services) { GraphicsCompositor = graphicsCompositor }; services.AddService(sceneSystem); var graphicsDevice = GraphicsDevice.New(DeviceCreationFlags.Debug); services.AddService <IGraphicsDeviceService>(new GraphicsDeviceServiceLocal(graphicsDevice)); services.AddService(new EffectSystem(services)); services.AddService(new GraphicsContext(graphicsDevice)); context = RenderContext.GetShared(services); context.PushTagAndRestore(SceneSystem.Current, sceneSystem); }
private IEnumerator playScene(string sceneName) { SceneSystem.ChangeScene(sceneName); GameMessageManager.ResetGameMessage(); //胜利判定 while (true) { yield return(0); if (GameMessageManager.GetGameMessage(GameMessage.Win)) { break; } if (GameMessageManager.GetGameMessage(GameMessage.Lose)) { yield return(gameOver()); break; } } }
public void Initialize() { LoadSurfaces(); LoadFont(); BackBuffer = new RenderWindow(new BackBuffer(Program.Window, Program.Window.getTrueWidth(), Program.Window.getTrueHeight(), 0, 0).GetHandle()); _bgColor = new Color(25, 25, 25); _input = new Input(); BackBuffer.MouseButtonPressed += _input.MouseDown; BackBuffer.MouseButtonReleased += _input.MouseUp; BackBuffer.MouseMoved += _input.MouseMove; BackBuffer.KeyPressed += _input.KeyPress; BackBuffer.KeyReleased += _input.KeyRelease; BackBuffer.SetKeyRepeatEnabled(true); Card.BlankID = GetSurfaceIndex("Cover", SurfaceType.Card); Scene = new SceneSystem(); }
public override void Start() { var scene = new Scene(); AddSceneContent(scene); // add Camera var camEntity = new Entity(); var camComponent = new CameraComponent(); camEntity.Add(camComponent); scene.Entities.Add(camEntity); // transform cam pos camEntity.Transform.Position = new Vector3(0.0f, 0.0f, 5.0f); var angle = (float)Math.PI / -2; camEntity.Transform.Rotation = Quaternion.RotationZ(angle); // Create Scenesystem var sceneSystem = new SceneSystem(Services) { SceneInstance = new SceneInstance(Services, scene) }; sceneSystem.Name = "OffscreeScenesystem"; var renderTargetloaded = Content.Load <Texture>("RenderTexture"); //var renderTarget = Helpers.CreateRenderTarget(Game.GraphicsDevice, PixelFormat.R8G8B8A8_UNorm_SRgb, 1024, 1024); // works also, but this is not set in GS's Material var offscreencompositorFromCode = Helpers.CreateOffscreenCompositor(false, renderTargetloaded, camComponent); sceneSystem.GraphicsCompositor = offscreencompositorFromCode; // add scenesystem to Game, so it gets called Game.GameSystems.Add(sceneSystem); }
protected override void OnUpdate(GameTime Time) { // Create a copy of our systems and entities so we can update without worry of disposed ones. // We can of course easily optimize this if need be. var EntitiesCopy = new Entity[_Entities.Count]; var SystemsCopy = new SceneSystem[_Systems.Count]; _Entities.CopyTo(EntitiesCopy, 0); _Systems.CopyTo(SystemsCopy, 0); foreach (var Entity in EntitiesCopy) { if (!Entity.IsDisposed) { Entity.Update(Time); } } foreach (var System in SystemsCopy) { if (!System.IsDisposed) { System.Update(Time); } } }
protected override void OnSystemAdd() { try { physicsSystem = (Bullet2PhysicsSystem)Services.GetSafeServiceAs <IPhysicsSystem>(); } catch (ServiceNotFoundException) { physicsSystem = new Bullet2PhysicsSystem(Services); var game = Services.GetSafeServiceAs <IGame>(); game.GameSystems.Add(physicsSystem); } simulation = physicsSystem.Create(this); var gfxDevice = Services.GetSafeServiceAs <IGraphicsDeviceService>()?.GraphicsDevice; if (gfxDevice != null) { debugShapeRendering = new PhysicsDebugShapeRendering(gfxDevice); } sceneSystem = Services.GetSafeServiceAs <SceneSystem>(); }
private void CreateEventHandlers() { // Create a new scene system to handle the events. this.SceneSystem = new SceneSystem(); // For mouse related events, just pass off the coords to the scene system. this.DrawingSurface.MouseButtonPressed += (sender, e) => { this.SceneSystem.MouseDown(e.Button.ToString().ToLower(), e.X, e.Y); }; this.DrawingSurface.MouseButtonReleased += (sender, e) => { this.SceneSystem.MouseUp(e.Button.ToString().ToLower(), e.X, e.Y); }; this.DrawingSurface.MouseMoved += (sender, e) => { this.SceneSystem.MouseMove(e.X, e.Y); }; // For key related events, pass off the filtered keyname to the scene system. this.DrawingSurface.KeyPressed += (sender, e) => { this.SceneSystem.KeyDown(this.FilterKey(e)); }; // When the close button is pressed, set the game flag to 'closing' so // the application can begin to close. this.DrawingSurface.Closed += (sender, e) => { switch (Game.State) { case GameState.Game: Game.SetGameState(GameState.MainMenu); break; default: Game.SetGameFlag(GameFlag.Closing); break; } }; }
public virtual void notifyConstructDone() { if (mGameFramework == null) { mGameFramework = GameFramework.instance; mCommandSystem = mGameFramework.getSystem <CommandSystem>(); mAudioManager = mGameFramework.getSystem <AudioManager>(); mGameSceneManager = mGameFramework.getSystem <GameSceneManager>(); mCharacterManager = mGameFramework.getSystem <CharacterManager>(); mLayoutManager = mGameFramework.getSystem <GameLayoutManager>(); mKeyFrameManager = mGameFramework.getSystem <KeyFrameManager>(); mGlobalTouchSystem = mGameFramework.getSystem <GlobalTouchSystem>(); mShaderManager = mGameFramework.getSystem <ShaderManager>(); mDataBase = mGameFramework.getSystem <DataBase>(); mCameraManager = mGameFramework.getSystem <CameraManager>(); mResourceManager = mGameFramework.getSystem <ResourceManager>(); mLayoutSubPrefabManager = mGameFramework.getSystem <LayoutSubPrefabManager>(); mApplicationConfig = mGameFramework.getSystem <ApplicationConfig>(); mFrameConfig = mGameFramework.getSystem <FrameConfig>(); mObjectManager = mGameFramework.getSystem <ObjectManager>(); mInputManager = mGameFramework.getSystem <InputManager>(); mSceneSystem = mGameFramework.getSystem <SceneSystem>(); } }
protected void CollisionStarted() { activated = true; // Play a sound effect sfxInstance?.Play(); // Add a visual effect var effectMatrix = Matrix.Translation(Entity.Transform.WorldMatrix.TranslationVector); this.SpawnPrefabInstance(CoinGetEffect, null, 3, effectMatrix); Func <Task> cleanupTask = async() => { await Game.WaitTime(TimeSpan.FromMilliseconds(3000)); Game.RemoveEntity(Entity.GetParent()); }; Script.AddTask(cleanupTask); _gameManager ??= SceneSystem.GetGameManagerFromRootScene(); _gameManager.CoinCollected++; }
/// <summary> /// Resolves camera to the one contained in slot <see cref="Camera"/>. /// </summary> internal virtual CameraComponent ResolveCamera() { if (Camera == null && !cameraSlotResolutionFailed) { Logger.Warning($"{nameof(SceneCameraRenderer)} [{Id}] has no camera set. Make sure to set camera to the renderer via the Graphic Compositor Editor."); } cameraSlotResolutionFailed = Camera == null; if (cameraSlotResolutionFailed) { return(null); } var camera = Camera?.Camera; if (camera == null && !cameraResolutionFailed) { // no slot set, try to set one automatically SceneSystem ss = ServiceRegistry.instance?.GetService <SceneSystem>(); GraphicsCompositor gc = ss?.GraphicsCompositor; if (gc != null) { var id = gc.Cameras[0].ToSlotId(); camera = SetFirstCamera(ref id, ss.SceneInstance.RootScene.Entities); } if (camera == null) { Logger.Warning($"{nameof(SceneCameraRenderer)} [{Id}] has no camera assigned to its {nameof(CameraComponent.Slot)}[{Camera.Name}]. Make sure a camera is enabled and assigned to the corresponding {nameof(CameraComponent.Slot)}."); } } cameraResolutionFailed = camera == null; return(camera); }
/// <inheritdoc /> public override void Initialize() { base.Initialize(); var gameSettings = Services.GetService <IGameSettingsService>()?.Settings; if (gameSettings != null) { InitializeSettingsFromGameSettings(gameSettings); } else { // Initial build settings BuildSettings = ObjectFactoryRegistry.NewInstance <NavigationMeshBuildSettings>(); IncludedCollisionGroups = CollisionFilterGroupFlags.AllFilter; Groups = new List <NavigationMeshGroup> { ObjectFactoryRegistry.NewInstance <NavigationMeshGroup>(), }; } sceneSystem = Services.GetSafeServiceAs <SceneSystem>(); scriptSystem = Services.GetSafeServiceAs <ScriptSystem>(); }
public ScenePostUpdateSystem(IServiceRegistry registry, SceneSystem sceneSystem) : base(registry) { Enabled = true; _sceneSystem = sceneSystem; }
public void RePosition() { CardPositionList.Clear(); if (PlayerCard.Count <= 0) { return; } Vector2 screen = SceneSystem.GetInstance().ScreenSize; Vector2 cardDistance = Vector2.zero; Vector2 startPoint = Vector2.zero; Vector2 minusDistance = Vector2.zero; Vector2 increateDistance = Vector2.zero; Vector3 angle = Vector3.zero; // 카드의 각도 float increaseAngle = 0; // 카드가 추가될때 증가되는 각도 //if (PlayerPlace == PlayerTag.PLAYER_BOTTOM) // minusDistance.x = screen.x / 24 * PlayerCard.Count / 2 - 1.2f; //else // minusDistance.y switch (PlayerPlace) { case PlayerTag.PLAYER_BOTTOM: { cardDistance.x = 0.44f; minusDistance.x = screen.x / 24 * PlayerCard.Count / 2 - 1.2f; startPoint = new Vector2(-0.84f, -7.8f); } break; case PlayerTag.PLAYER_TOP: { cardDistance.x = 0.19f; minusDistance.x = screen.x / 20 * PlayerCard.Count / 6 - 1.2f; increateDistance.y = PlayerCard.Count * 0.01f; increaseAngle = 1; startPoint = new Vector2(-1, 10); } break; case PlayerTag.PLAYER_LEFT_DOWN: case PlayerTag.PLAYER_LEFT_UP: { cardDistance.y = 0.19f; minusDistance.y = screen.x / 20 * PlayerCard.Count / 6 - 1.2f; increateDistance.x = -PlayerCard.Count * 0.01f; angle.z = 90; increaseAngle = 1; if (PlayerPlace == PlayerTag.PLAYER_LEFT_DOWN) { startPoint = new Vector2(-5, -3); } else if (PlayerPlace == PlayerTag.PLAYER_LEFT_UP) { startPoint = new Vector2(-5, 3.5f); } } break; case PlayerTag.PLAYER_RIGHT_DOWN: case PlayerTag.PLAYER_RIGHT_UP: { cardDistance.y = 0.19f; minusDistance.y = screen.x / 20 * PlayerCard.Count / 6 - 1.2f; increateDistance.x = PlayerCard.Count * 0.01f; angle.z = -90; increaseAngle = -1; if (PlayerPlace == PlayerTag.PLAYER_RIGHT_DOWN) { startPoint = new Vector2(5, -3); } else if (PlayerPlace == PlayerTag.PLAYER_RIGHT_UP) { startPoint = new Vector2(5, 3.5f); } } break; } for (int i = 0; i < PlayerCard.Count; i++) { screen = startPoint + cardDistance * i - minusDistance; screen += -Mathf.Sin(180 / PlayerCard.Count * i * Mathf.Deg2Rad) * increateDistance; PlayerCard[i].transform.DOMove(screen, 0.5f); PlayerCard[i].transform.DORotate(Vector3.forward * (i - PlayerCard.Count / 2) * increaseAngle + angle, 0.1f); PlayerCard[i].SetSortingOrder(i); CardPositionList.Add(screen); } }
public override void Update() { // HACK: should probably not rely on accessing this UI component directly. if (_inGameScreenPageHandler == null) { var uiManager = SceneSystem.GetUIManagerFromRootScene(); _inGameScreenPageHandler = uiManager.TopPageHandler as InGameScreenPageHandler; if (_inGameScreenPageHandler == null) { // UI not loaded yet return; } } if (!_inGameScreenPageHandler.IsTopMostScreen) { // Don't process any input, since it's probably in a sub-menu! return; } if (Input.HasMouse) { ClickResult clickResult; Utils.ScreenPositionToWorldPositionRaycast(Input.MousePosition, Camera, this.GetSimulation(), out clickResult); var isMoving = (Input.IsMouseButtonDown(MouseButton.Left) && lastClickResult.Type == ClickType.Ground && clickResult.Type == ClickType.Ground); var isHighlit = (!isMoving && clickResult.Type == ClickType.LootCrate); // Character continuous moving if (isMoving) { lastClickResult.WorldPosition = clickResult.WorldPosition; MoveDestinationEventKey.Broadcast(lastClickResult); } // Object highlighting if (isHighlit) { var modelComponentA = Highlight?.Get <ModelComponent>(); var modelComponentB = clickResult.ClickedEntity.Get <ModelComponent>(); if (modelComponentA != null && modelComponentB != null) { var materialCount = modelComponentB.Model.Materials.Count; modelComponentA.Model = modelComponentB.Model; modelComponentA.Materials.Clear(); for (int i = 0; i < materialCount; i++) { modelComponentA.Materials.Add(i, HighlightMaterial); } modelComponentA.Entity.Transform.UseTRS = false; modelComponentA.Entity.Transform.LocalMatrix = modelComponentB.Entity.Transform.WorldMatrix; } } else { var modelComponentA = Highlight?.Get <ModelComponent>(); if (modelComponentA != null) { modelComponentA.Entity.Transform.LocalMatrix = Matrix.Scaling(0); } } } // Mouse-based camera rotation. Only enabled after you click the screen to lock your cursor, pressing escape cancels this foreach (var pointerEvent in Input.PointerEvents.Where(x => x.EventType == PointerEventType.Pressed)) { ClickResult clickResult; if (Utils.ScreenPositionToWorldPositionRaycast(pointerEvent.Position, Camera, this.GetSimulation(), out clickResult)) { lastClickResult = clickResult; MoveDestinationEventKey.Broadcast(clickResult); if (ClickEffect != null && clickResult.Type == ClickType.Ground) { this.SpawnPrefabInstance(ClickEffect, null, 1.2f, Matrix.RotationQuaternion(Quaternion.BetweenDirections(Vector3.UnitY, clickResult.HitResult.Normal)) * Matrix.Translation(clickResult.WorldPosition)); } } } }
private IEnumerator beforeStart() { AudioSystem.Play(Setter.setting.audioStart); SceneSystem.ChangeScene("BeforeStart"); yield return(new WaitForSeconds(2)); }
protected override void OnSystemRemove() { _sceneSystem = null; }
protected override void OnCreate() { sceneSystem = World.GetOrCreateSystem <SceneSystem>(); }
public ThumbnailGenerator(EffectCompilerBase effectCompiler) { // create base services Services = new ServiceRegistry(); Services.AddService(MicrothreadLocalDatabases.ProviderService); ContentManager = new ContentManager(Services); Services.AddService <IContentManager>(ContentManager); Services.AddService(ContentManager); GraphicsDevice = GraphicsDevice.New(); GraphicsContext = new GraphicsContext(GraphicsDevice); GraphicsCommandList = GraphicsContext.CommandList; Services.AddService(GraphicsContext); sceneSystem = new SceneSystem(Services); Services.AddService(sceneSystem); fontSystem = new GameFontSystem(Services); Services.AddService(fontSystem.FontSystem); Services.AddService <IFontFactory>(fontSystem.FontSystem); GraphicsDeviceService = new GraphicsDeviceServiceLocal(Services, GraphicsDevice); Services.AddService(GraphicsDeviceService); var uiSystem = new UISystem(Services); Services.AddService(uiSystem); var physicsSystem = new Bullet2PhysicsSystem(Services); Services.AddService <IPhysicsSystem>(physicsSystem); gameSystems = new GameSystemCollection(Services) { fontSystem, uiSystem, physicsSystem }; Services.AddService <IGameSystemCollection>(gameSystems); Simulation.DisableSimulation = true; //make sure we do not simulate physics within the editor // initialize base services gameSystems.Initialize(); // create remaining services EffectSystem = new EffectSystem(Services); Services.AddService(EffectSystem); gameSystems.Add(EffectSystem); gameSystems.Add(sceneSystem); EffectSystem.Initialize(); // Mount the same database for the cache EffectSystem.Compiler = EffectCompilerFactory.CreateEffectCompiler(effectCompiler.FileProvider, EffectSystem); // Deactivate the asynchronous effect compilation ((EffectCompilerCache)EffectSystem.Compiler).CompileEffectAsynchronously = false; // load game system content gameSystems.LoadContent(); // create the default fonts var fontItem = OfflineRasterizedSpriteFontFactory.Create(); fontItem.FontType.Size = 22; DefaultFont = OfflineRasterizedFontCompiler.Compile(fontSystem.FontSystem, fontItem, true); // create utility members nullGameTime = new GameTime(); SpriteBatch = new SpriteBatch(GraphicsDevice); UIBatch = new UIBatch(GraphicsDevice); // create the pipeline SetUpPipeline(); }
protected override void OnCreate() { RequireSingletonForUpdate <SceneLoadInfo>(); this.sceneSystem = World.GetOrCreateSystem <SceneSystem>(); }
void onMain() { SceneSystem.changeScene("Main"); }
/// <summary> /// 初始化外部系统 /// </summary> static void initializeSystems() { gameSys = gameSys ?? GameSystem.Get(); sceneSys = sceneSys ?? SceneSystem.Get(); gameSer = gameSer ?? GameService.Get(); }
private void CreateEventHandlers() { // Create a new scene system to handle the events. this.SceneSystem = new SceneSystem(); // For mouse related events, just pass off the coords to the scene system. this.DrawingSurface.MouseButtonPressed += (sender, e) => { // Is it the left mouse button? if (e.Button == Mouse.Button.Left) { // Are we currently trying to place a tower? if (this.HoverSurfaceName != null) { int x = e.X / 60; int y = e.Y / 59; // Figure out if it's out of bounds. if (x >= 0 && x <= 15) { if (y >= 0 && y <= 10) { for (int i = 0; i < DataManager.Map.Towers.Count; i++) { var tower = DataManager.Map.Towers[i]; if (tower.X == x && tower.Y == y) { return; } } if (DataManager.Map.mapArray[x, y].Placable) { switch (this.HoverSurfaceName) { case "tower1": if (DataManager.Board.Money >= TeslaTower.TowerCost) { DataManager.Map.Towers.Add(new TeslaTower(x, y)); DataManager.Board.RemoveMoney(TeslaTower.TowerCost); } break; case "tower2": if (DataManager.Board.Money >= SyndraTower.TowerCost) { DataManager.Map.Towers.Add(new SyndraTower(x, y)); DataManager.Board.RemoveMoney(SyndraTower.TowerCost); } break; } } } } } } // Pass off the coords to the UI system this.SceneSystem.MouseDown(e.Button.ToString().ToLower(), e.X, e.Y); }; this.DrawingSurface.MouseButtonReleased += (sender, e) => { this.SceneSystem.MouseUp(e.Button.ToString().ToLower(), e.X, e.Y); }; this.DrawingSurface.MouseMoved += (sender, e) => { this.SceneSystem.MouseMove(e.X, e.Y); // Save the position of the mouse. this.MouseX = e.X; this.MouseY = e.Y; }; // For key related events, pass off the filtered keyname to the scene system. this.DrawingSurface.KeyPressed += (sender, e) => { this.SceneSystem.KeyDown(this.FilterKey(e)); }; // When the close button is pressed, set the game flag to 'closing' so // the application can begin to close. this.DrawingSurface.Closed += (sender, e) => { switch (Game.State) { case GameState.Game: Game.SetGameState(GameState.MainMenu); break; default: Game.SetGameFlag(GameFlag.Closing); break; } }; }
private void Awake() { Instance = this; DontDestroyOnLoad(gameObject); FrameRate = m_FrameRate; TimeScale = m_TimeScale; RunInBackground = m_RunInBackground; SleepTimeout = m_SleepTimeout; if (!string.IsNullOrEmpty(m_LoggerTypeName)) { Type loggerType = Type.GetType(m_LoggerTypeName); ILogger logger = (ILogger)Activator.CreateInstance(loggerType); LogSystem = SystemManager.RegisterSystem(new LogSystem(logger)); LogSystem.LogLevel = m_LogLevel; LogSystem.TraceColor = ColorUtility.ToHtmlStringRGBA(m_TraceLogColor); LogSystem.DebugColor = ColorUtility.ToHtmlStringRGBA(m_DebugLogColor); LogSystem.InfoColor = ColorUtility.ToHtmlStringRGBA(m_InfoLogColor); LogSystem.WarnColor = ColorUtility.ToHtmlStringRGBA(m_WarnLogColor); LogSystem.ErrorColor = ColorUtility.ToHtmlStringRGBA(m_ErrorLogColor); LogSystem.FatalColor = ColorUtility.ToHtmlStringRGBA(m_FatalLogColor); } if (m_LuaPackagePaths != null) { for (int i = 0; i < m_LuaPackagePaths.Length; ++i) { m_LuaPackagePaths[i] = GetPath(m_LuaPackagePaths[i]); } } if (!string.IsNullOrEmpty(m_ResourceHolderTypeName) && !string.IsNullOrEmpty(m_ResourceDecoderTypeName)) { Type holderType = Type.GetType(m_ResourceHolderTypeName); IResourceHolder holder = (IResourceHolder)Activator.CreateInstance(holderType); Type decoderType = Type.GetType(m_ResourceDecoderTypeName); IResourceDecoder decoder = (IResourceDecoder)Activator.CreateInstance(decoderType); Type dependencyType = Type.GetType(m_ResourceDependencyManifestTypeName); IDependencyManifest dependencyManifest = (IDependencyManifest)Activator.CreateInstance(dependencyType); ResourceSystem = SystemManager.RegisterSystem(new ResourceSystem(m_ResourceLoaderComponent, holder, decoder, dependencyManifest)); ResourceSystem.EditorPath = GetPath(m_EditorPath); ResourceSystem.InternalPath = GetPath(m_InternalPath); ResourceSystem.ReadOnlyPath = GetPath(m_ReadOnlyPath); ResourceSystem.PersistentPath = GetPath(m_PersistentPath); } LuaSystem = SystemManager.RegisterSystem(new LuaSystem(m_LuaPackagePaths)); FsmSystem = SystemManager.RegisterSystem(new FsmSystem()); TimerSystem = SystemManager.RegisterSystem(new TimerSystem()); if (!string.IsNullOrEmpty(m_EventKeyTypeName)) { Type eventSystemType = typeof(EventSystem <>); Type eventKeyType = Type.GetType(m_EventKeyTypeName); eventSystemType = eventSystemType.MakeGenericType(eventKeyType); ISystem eventSystem = (ISystem)Activator.CreateInstance(eventSystemType); EventSystem = SystemManager.RegisterSystem(eventSystem); } if (!string.IsNullOrEmpty(m_UICreaterTypeName)) { Type type = Type.GetType(m_UICreaterTypeName); IUICreater creater = (IUICreater)Activator.CreateInstance(type); UISystem = SystemManager.RegisterSystem(new UISystem(creater, m_UIRoot)); if (m_UIDefaultGroups != null) { for (int i = 0; i < m_UIDefaultGroups.Length; ++i) { UISystem.AddGroup(m_UIDefaultGroups[i].Name, m_UIDefaultGroups[i].Depth); } } } if (m_DownloaderComponent != null) { DownloadSystem = SystemManager.RegisterSystem(new DownloadSystem(m_DownloaderComponent)); DownloadSystem.DownloadTimeout = m_DownloadTimeout; } NetworkSystem = SystemManager.RegisterSystem(new NetworkSystem()); HttpSystem = SystemManager.RegisterSystem(new HttpSystem(m_WebRequesterComponent)); if (!string.IsNullOrEmpty(m_DataTableParserTypeName)) { Type parserType = Type.GetType(m_DataTableParserTypeName); IDataTableParser parser = (IDataTableParser)Activator.CreateInstance(parserType); DataTableSystem = SystemManager.RegisterSystem(new DataTableSystem(parser)); } if (!string.IsNullOrEmpty(m_SettingHandlerTypeName)) { Type handlerType = Type.GetType(m_SettingHandlerTypeName); ISettingHandler handler = (ISettingHandler)Activator.CreateInstance(handlerType); SettingSystem = SystemManager.RegisterSystem(new SettingSystem(handler)); } if (!string.IsNullOrEmpty(m_LocalizationParserTypeName)) { Type parserType = Type.GetType(m_LocalizationParserTypeName); ILocalizationParser parser = (ILocalizationParser)Activator.CreateInstance(parserType); LocalizationSystem = SystemManager.RegisterSystem(new LocalizationSystem(parser)); LocalizationSystem.Language = m_LocalizationLanguage; } if (m_EnabledProcedureTypeNames != null && m_EnabledProcedureTypeNames.Length > 0 && !string.IsNullOrEmpty(m_StartProcedureTypeName)) { IProcedure[] procedures = new IProcedure[m_EnabledProcedureTypeNames.Length]; for (int i = 0; i < m_EnabledProcedureTypeNames.Length; ++i) { IProcedure procedure = null; Type type = Type.GetType(m_EnabledProcedureTypeNames[i]); if (type == null) { procedure = new LuaProcedure(m_EnabledProcedureTypeNames[i]); } else { procedure = (IProcedure)Activator.CreateInstance(type); } procedures[i] = procedure; } ProcedureSystem = SystemManager.RegisterSystem(new ProcedureSystem(procedures)); ProcedureSystem.Start(m_StartProcedureTypeName); } if (m_DebugFormTypeNames != null && m_DebugFormTypeNames.Length > 0) { DebugSystem = SystemManager.RegisterSystem(new DebugSystem()); for (int i = 0; i < m_DebugFormTypeNames.Length; ++i) { if (string.IsNullOrEmpty(m_DebugFormTypeNames[i])) { throw new ArgumentNullException("invalid debug form"); } Type debugFormType = Type.GetType(m_DebugFormTypeNames[i]); IDebugForm debugForm = (IDebugForm)Activator.CreateInstance(debugFormType); DebugSystem.RegisterDebugForm(debugForm); } } if (!string.IsNullOrEmpty(m_AudioCreaterTypeName)) { Type createrType = Type.GetType(m_AudioCreaterTypeName); ISounderCreater creater = (ISounderCreater)Activator.CreateInstance(createrType); AudioSystem = SystemManager.RegisterSystem(new AudioSystem(creater)); AudioSystem.MaxSameAudioCount = m_MaxSameAudioCount; AudioSystem.SounderRoot = m_SounderRoot; } EntitySystem = SystemManager.RegisterSystem(new EntitySystem()); if (!string.IsNullOrEmpty(m_SceneLoaderTypeName)) { Type loaderType = Type.GetType(m_SceneLoaderTypeName); ISceneLoader loader = (ISceneLoader)Activator.CreateInstance(loaderType); SceneSystem = SystemManager.RegisterSystem(new SceneSystem(loader)); } }
protected override void OnCreate() { RequireSingletonForUpdate <TeleportPlayerTimer>(); this.sceneSystem = World.GetOrCreateSystem <SceneSystem>(); }
public static GameEntity GetInputTarget(Vector3 screenPos, SceneSystem sceneSystem, Camera camera) { var gameObject = GetInputTarget(screenPos, camera); return(gameObject != null?sceneSystem.GetEntityWithView(gameObject) : null); }
protected override void OnSystemAdd() { _sceneSystem = Services.GetSafeServiceAs <SceneSystem>(); }