protected override void OnUpdate()
        {
            _input = World.GetExistingSystem <InputSystem>();

            switch (Process)
            {
            case true:
            {
                PositionCurrent = CameraUtil.ScreenPointToWorldPoint(World, InputUtil.GetInputPosition(_input));
                if (InputUtil.GetInputUp(_input))
                {
                    PositionUp = PositionCurrent;
                    Process    = false;
                    OnEndProses();
                }

                break;
            }

            case false when InputUtil.GetInputDown(_input):
                PositionDown = CameraUtil.ScreenPointToWorldPoint(World, InputUtil.GetInputPosition(_input));

                Process = true;
                OnStartProses();
                break;
            }
        }
        protected override void OnUpdate()
        {
            _input = World.GetExistingSystem <InputSystem>();
            var physicsWorld = World.GetExistingSystem <PhysicsWorldSystem>().PhysicsWorld;

            if (InputUtil.GetInputUp(_input))
            {
                float2 pos    = CameraUtil.ScreenPointToWorldPoint(World, InputUtil.GetInputPosition(_input));
                Entity entity = DrawBordersSystem.GetInputEntity(physicsWorld, pos);
                if (entity == Entity.Null)
                {
                    return;
                }
                ButtonsType buttonsType = EntityManager.GetComponentData <ButtonsComponent>(entity).ButtonsType;
                Button(buttonsType);
            }
        }
Exemple #3
0
    public override void OnUpdate(float deltaTime)
    {
        if (InputUtil.GetInputDown())
        {
            _startPosition = Camera.main.ScreenToWorldPoint(new Vector3(InputUtil.GetInputPosition().x, InputUtil.GetInputPosition().y, 7));
        }
        else if (InputUtil.GetInputUp())
        {
            var inputPos   = Camera.main.ScreenToWorldPoint(new Vector3(InputUtil.GetInputPosition().x, InputUtil.GetInputPosition().y, 7));
            var inputDelta = inputPos - _startPosition;

            var     inputData          = _inputFilter.Select <InputData>();
            ref var inputDataComponent = ref inputData.GetComponent(0);

            //Нужна ли тут физика?
            inputDataComponent.Entity     = GetCellFromInput(_startPosition);
            inputDataComponent.DeltaInput = inputDelta;
        }
        protected override void OnUpdate()
        {
            //Get the keyboard input data
            var inputAxis = new float2(0, 0);
            var input     = World.GetOrCreateSystem <InputSystem>();

            if (input.GetKey(KeyCode.A) || input.GetKey(KeyCode.LeftArrow))
            {
                inputAxis.x = -1;
            }
            if (input.GetKey(KeyCode.D) || input.GetKey(KeyCode.RightArrow))
            {
                inputAxis.x = 1;
            }

            bool isTouch = false;

            if (input.IsTouchSupported())
            {
                //Get the touch input data
                Touch touch = input.GetTouch(0);
                isTouch = input.TouchCount() > 0 && touch.phase == TouchState.Moved;
                if (isTouch)
                {
                    var pos = CameraUtil.ScreenPointToWorldPoint(World, InputUtil.GetInputPosition(input));
                    if (_oldPos != null)
                    {
                        inputAxis = (pos - (float2)_oldPos) * (touch.deltaX < 0 ? 1 : -1);
                    }
                    _oldPos = pos;
                }
                else
                {
                    _oldPos = null;
                }
            }


            Entities.ForEach((ref PlayerInputComponent playerInput) =>
            {
                playerInput.InputAxis = inputAxis;
                playerInput.IsTouch   = isTouch;
            }).WithBurst().Run();
        }