Exemple #1
0
    public bool GetOffset(out Int2 offset)
    {
        var x = Input.GetAxis("Horizontal");
        var y = Input.GetAxis("Vertical");

        offset = new Int2(0, 0);
        if (x < 0)
        {
            offset.Set(-1, offset.Y);
        }
        if (y < 0)
        {
            offset.Set(offset.X, -1);
        }
        if (x > 0)
        {
            offset.Set(1, offset.Y);
        }
        if (y > 0)
        {
            offset.Set(offset.X, 1);
        }
        //Debug.Log($"H: {Input.GetAxis("Horizontal")} ({offset.X}), V: {Input.GetAxis("Vertical")} ({offset.Y})");

        return(offset.X != 0 || offset.Y != 0);
    }
Exemple #2
0
        bool IInputService.GetCursorCoordinate(out Int2 coord)
        {
            coord = new Int2();

            if (Input.GetMouseButtonDown(0))
            {
                _mouseDown = true;
            }
            else
            if (Input.GetMouseButtonUp(0))
            {
                _mouseDown = false;
            }

            if (_mouseDown)
            {
                var worldPosition = _camera.ScreenToWorldPoint(Input.mousePosition);
                coord.Set(
                    Mathf.FloorToInt(worldPosition.x),
                    Mathf.FloorToInt(worldPosition.y)
                    );
                return(true);
            }
            return(false);
        }
    public Int2 GetTileAssetPosForDefaultState(Sorting _sorting, Rotation _rotation, Direction _direction)
    {
        Int2 _assetPosBL = AssetPositions.GetAssetPos(_rotation);

        Int2 _offset = new Int2();

        switch (_direction)
        {
        case Direction.TR:
            break;

        case Direction.TL:
            _offset.Set(1, 0);
            break;

        case Direction.BR:
            _offset.Set(0, 1);
            break;

        case Direction.BL:
            _offset.Set(1, 1);
            break;

        default:
            Debug.LogError(_direction + " hasn't been properly implemented yet!");
            break;
        }

        switch (_sorting)
        {
        case Sorting.Back:
            break;

        case Sorting.Front:
            _offset += new Int2(0, 2);
            break;

        default:
            Debug.LogError(_sorting + " hasn't been properly implemented yet!");
            break;
        }

        // Debug.Log(_direction + ", " + _sorting + ": " + _assetPosBL + ", " + _offset);
        return(_assetPosBL + _offset);
    }
Exemple #4
0
        bool IInputService.GetClickedCoordinate(out Int2 coord)
        {
            coord = new Int2();
            if (!Input.GetMouseButtonUp(0))
            {
                return(false);
            }
            var worldPosition = _camera.ScreenToWorldPoint(Input.mousePosition);

            coord.Set(
                Mathf.FloorToInt(worldPosition.x),
                Mathf.FloorToInt(worldPosition.y)
                );
            return(true);
        }