Ejemplo n.º 1
0
        protected override void OnUpdate()
        {
            var activeScene = GetSingleton <ActiveScene>();
            var gameState   = GetSingleton <GameStateData>();
            var input       = World.GetExistingSystem <InputSystem>();

            if (activeScene.Value == Scenes.Title &&
                InputUtil.GetInputDown(input))
            {
                EntityManager.DestroyEntity(m_CellsQuery);

                AudioUtils.PlaySound(EntityManager, AudioTypes.StartGame);

                activeScene.Value = Scenes.Game;
                SetSingleton(activeScene);

                gameState.State  = GameState.Spawn;
                gameState.Hearts = 3;
                SetSingleton(gameState);
            }
        }
        protected override JobHandle OnUpdate(JobHandle inputDeps)
        {
            var input        = World.GetExistingSystem <Tiny.Input.InputSystem>();
            var physicsWorld = World.GetExistingSystem <PhysicsWorldSystem>().PhysicsWorld;

            if (InputUtil.GetInputDown(input))
            {
                m_StartPosition = CameraUtil.ScreenPointToViewportPoint(EntityManager, InputUtil.GetInputPosition(input));
            }
            else if (InputUtil.GetInputUp(input))
            {
                var inputPos   = CameraUtil.ScreenPointToViewportPoint(EntityManager, InputUtil.GetInputPosition(input));
                var inputDelta = inputPos - m_StartPosition;

                var cameraMatrices = m_CameraQuery.ToComponentDataArray <CameraMatrices>(Allocator.TempJob);
                var resultPos      = CameraUtil.ViewPortPointToNearClipPoint(cameraMatrices[0], m_StartPosition);

                var activeInput = GetSingleton <ActiveInput>();
                activeInput.Value = GetSwapInputFromWorldPos(ref physicsWorld, resultPos, inputDelta);

                SetSingleton(activeInput);

                cameraMatrices.Dispose();
            }

            return(inputDeps);
        }