Пример #1
0
    void Start()
    {
        currentFacing = SpriteAnimDirectional.Facing.DW;
        _timer        = movementTime;

        _whereAmI = WorldGrid.GetGridPositionFromWorld(transform.position);
        animator  = new SpriteAnimDirectional(sp_walk_up, sp_walk_dw, sp_walk_lf, sp_walk_rg,
                                              movementTime / 2, GetComponent <SpriteRenderer>());
        animator.ChangeFacingDirection(currentFacing);

        transform.position = WorldGrid.GetWorldPositionFromGrid(_whereAmI);
    }
Пример #2
0
    Vector3Int getInputNormalized()
    {
        float y = Input.GetAxis("Vertical");
        float x = Input.GetAxis("Horizontal");

        if (x == 0 && y == 0)
        {
            return(new Vector3Int(0, 0, 0));
        }

        int nx = 0;

        if (x > 0)
        {
            nx = 1;
        }
        if (x < 0)
        {
            nx = -1;
        }

        if (nx != 0)
        {
            return(new Vector3Int(nx, 0, 0));
        }

        int ny = 0;

        if (y > 0)
        {
            ny = 1; currentFacing = SpriteAnimDirectional.Facing.UP;
        }
        if (y < 0)
        {
            ny = -1; currentFacing = SpriteAnimDirectional.Facing.DW;
        }

        return(new Vector3Int(0, ny, 0));
    }