コード例 #1
0
ファイル: MouseInBorderRTS.cs プロジェクト: naaturaz/SM
    /// <summary>
    /// return         //mouse and key directions only if they dont conflict...
    /// if mouse going right and keyboard up will return an 'UpRight' direction
    /// </summary>
    /// <param name="dir"></param>
    /// <returns></returns>
    private Dir ReturnComposeDirectionWithKeyBoard(Dir dir)
    {
        if (UInput.IfHorizontalKeysIsPressed() && dir == Dir.Up)
        {
            if (UInput.HorizVal() > 0)
            {
                dir = Dir.UpRight;
            }
            else if (UInput.HorizVal() < 0)
            {
                dir = Dir.UpLeft;
            }
        }
        else if (UInput.IfHorizontalKeysIsPressed() && dir == Dir.Down)
        {
            if (UInput.HorizVal() > 0)
            {
                dir = Dir.DownRight;
            }
            else if (UInput.HorizVal() < 0)
            {
                dir = Dir.DownLeft;
            }
        }

        if (UInput.IfVerticalKeyIsPressed() && dir == Dir.Right)
        {
            if (UInput.VertiVal() > 0)
            {
                dir = Dir.UpRight;
            }
            else if (UInput.VertiVal() < 0)
            {
                dir = Dir.DownRight;
            }
        }
        else if (UInput.IfVerticalKeyIsPressed() && dir == Dir.Left)
        {
            if (UInput.VertiVal() > 0)
            {
                dir = Dir.UpLeft;
            }
            else if (UInput.VertiVal() < 0)
            {
                dir = Dir.DownLeft;
            }
        }
        return(dir);
    }
コード例 #2
0
    public static float ResponsiveInputAxisTo(float normalizeTo, Dir axis, float currentValue, Dir direction)
    {
        if (
            direction == Dir.Left || direction == Dir.Right ||
            (UInput.IfHorizontalKeysIsPressed() && axis == Dir.Horizontal && direction == Dir.None))
        {
            currentValue = FindMathSign(currentValue, normalizeTo, direction);
        }
        else if (
            direction == Dir.Up || direction == Dir.Down ||
            (UInput.IfVerticalKeyIsPressed() && axis == Dir.Vertical && direction == Dir.None))
        {
            currentValue = FindMathSign(currentValue, normalizeTo, direction);
        }
        else
        {
            currentValue = 0;
        }

        return(currentValue);
    }