UnityEngine.Mathf.Sign C# (CSharp) Method

Sign() public static method

public static Sign ( float f ) : float
f float
return float
        public static float Sign(float f)
        {
            return (double)f >= 0.0 ? 1f : -1f;
        }

Usage Example

コード例 #1
0
    int GetWrapedTable(int setSquare, int tempDir, int tableSize, int tableRows)
    {
        var tempSquare = (Math.Abs(tempDir) == 4) ? -1 * (int)Math.Sign(tempDir) : (Math.Abs(tempDir) % 5) * (int)Math.Sign(tempDir);

        if ((setSquare % tableRows) + tempSquare == -1 || (setSquare % tableRows) + tempSquare == tableRows)
        {
            tempSquare = (tableRows - 1) * ((((setSquare % tableRows) + tempSquare) == tableRows) ? -1 : 1);
        }

        setSquare += tempSquare;

        if (Math.Abs(tempDir) != 1 && Math.Abs(tempDir) != 0)
        {
            tempSquare = tableRows * (int)Math.Sign(tempDir);
            setSquare += tempSquare;
        }

        if (setSquare < 0)
        {
            setSquare = tableSize - Math.Abs(setSquare);
        }

        setSquare %= tableSize;

        return(setSquare);
    }
All Usage Examples Of UnityEngine.Mathf::Sign