示例#1
0
    //BUG BUG BUG !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
    //only update compass after level have been loaded, ner during load



    public void setCompass(float Angle)
    {
        Vector3 pos = compassStrip.anchoredPosition3D;

        latitudeCompass = BenjasMath.keepAngle0to360(Angle);
        xposCompass     = BenjasMath.map(latitudeCompass, 0, 360, xPosAtZero, xPosAt360, false);
        pos.x           = xposCompass;
        compassStrip.anchoredPosition3D = pos;
    }
示例#2
0
    public void setBacon(float Angle)
    {
        Vector3 pos = baconOne.anchoredPosition3D;

        angleBacon = BenjasMath.keepAngleBetween(Angle, -180, 180);

        xposBacon = BenjasMath.map(angleBacon, -clampBaconAngleAt, clampBaconAngleAt, -clampBaconAt, clampBaconAt, true);
        //center around 0 degrees
        pos.x = xposBacon;
        baconOne.anchoredPosition3D = pos;
    }
    private Vector3 getHandAngle(float value, float min, float max, float minAngle, float maxAngle, float currentAngle)
    {
        float targetAngle = BenjasMath.map(value, min, max, minAngle, maxAngle);

        if (instrumentMaxDegreesPerSec > 0)
        {
            targetAngle = Mathf.MoveTowardsAngle(currentAngle, targetAngle, instrumentMaxDegreesPerSec * Time.deltaTime);
        }

        return(new Vector3(0, 0, targetAngle));
    }
    public void updatespeedo()
    {
        if (glider != null)
        {
            sppedoSmoothing = Mathf.Clamp(sppedoSmoothing, 0, 0.999999f);
            if (ignoreVerticalSpeed)
            {
                speedoValue = Mathf.Lerp(glider.speedHorrizontal, speedoValue, sppedoSmoothing);
            }
            else
            {
                speedoValue = Mathf.Lerp(glider.speed, speedoValue, sppedoSmoothing);
            }
            speedoHand.localEulerAngles = getHandAngle(speedoValue, speedoMin, speedoMax, speedoMinAngle, speedoMaxAngle, speedoHand.localEulerAngles.z);
            speedDigits.text            = Mathf.FloorToInt(speedoValue).ToString() + " " + speedUnit;

            //adaptive smoothing depending on height
            altChangeSmoothingMinMax.x = Mathf.Clamp(altChangeSmoothingMinMax.x, 0, 0.999999f);
            altChangeSmoothingMinMax.y = Mathf.Clamp(altChangeSmoothingMinMax.y, 0, 0.999999f);
            altChangeSmoothing         = BenjasMath.map(altitudeValue
                                                        , altChangeSmoothingAltLimits.x, altChangeSmoothingAltLimits.y
                                                        , altChangeSmoothingMinMax.x, altChangeSmoothingMinMax.y);
            //apply values
            altitudeValue  = Mathf.Lerp(glider.altitude, altitudeValue, altChangeSmoothing);
            altChangeValue = Mathf.Lerp(glider.altChange, altChangeValue, altChangeSmoothing);
            altChangeHand.localEulerAngles = getHandAngle(altChangeValue, altChangeMin, altChangeMax, altChangeMinAngle, altChangeMaxAngle, altChangeHand.localEulerAngles.z);

            int    alt      = Mathf.FloorToInt(altitudeValue);
            string altsring = alt.ToString();
            altDigitsRed.text   = altsring;
            altDigitsBlack.text = altsring;
            if (alt < 10)
            {
                altsring = "0" + altsring;
            }
            if (alt < 100)
            {
                altsring = "0" + altsring;
            }
            //if (alt < 1000) altsring = "0" + altsring;
            altDigitsWhite.text = altsring;
            altDigitsUnit.text  = altUnit;
        }
    }
    private void updateMap(Vector3 coordinates)
    {
        positionMap   = mapPointer.anchoredPosition3D;
        positionWorld = coordinates;

        //Debug.Log("map" +positionMap.x);

        positionMap.x = BenjasMath.map(positionWorld.x,
                                       SWworld.x, NEworld.x,
                                       mapMinScaled.x, mapMaxScaled.x,
                                       clampMin.x, clampMax.x);
        //Debug.Log(positionMap.x);
        positionMap.y = BenjasMath.map(positionWorld.z,
                                       SWworld.z, NEworld.z,
                                       mapMinScaled.y, mapMaxScaled.y,
                                       clampMin.y, clampMax.y);

        mapPointer.anchoredPosition3D = positionMap;
    }