Esempio n. 1
0
    public static bool Approach(ref float inVal, float inTarget, float inApproachSpeed)
    {
        Ross_Utils.Assert(inApproachSpeed >= 0);

        if (inVal < inTarget)
        {
            inVal += inApproachSpeed;
            if ((inVal) >= inTarget)
            {
                inVal = inTarget;
                return(true);
            }
        }
        else if (inVal > inTarget)
        {
            inVal -= inApproachSpeed;
            if ((inVal) <= inTarget)
            {
                inVal = inTarget;
                return(true);
            }
        }

        return(false);
    }
Esempio n. 2
0
        public void LoadGameData()
        {
#if UNITY_WEBPLAYER
            return;
#endif

            string path = pathForDocumentsFile(fileName);

            Debug.Log("try to load " + path);

            //if the file has not been made yet then set defaults and create it...
            if (!File.Exists(path))
            {
                Debug.Log("failed to load - Create GameSave File " + fileName);

                this.SetGameDataDefaults();
                FileStream newFile = new FileStream(path, FileMode.Create, FileAccess.Write);
                this.WriteGameDataToFile(newFile);
                newFile.Close();

                return;
            }

            //Otherwise just read it

            Ross_Utils.Log("Read GameSave File " + fileName);

            FileStream file = new FileStream(path, FileMode.Open, FileAccess.Read);
            this.ReadGameDataFromFile(file);
            file.Close();
        }
Esempio n. 3
0
 //---------------------------------------------
 void Update()
 {
     if (transitionTimer > 0.0f)
     {
         transitionTimer -= Time.deltaTime;
         if (transitionTimer <= 0.0f)
         {
             if (state == State.kShowing)
             {
                 transform.localPosition = shownPosition;
                 state = State.kShown;
             }
             else
             {
                 transform.localPosition = hiddenPosition;
                 state = State.kHidden;
             }
         }
         else
         {
             float ratio = 1.0f - transitionCurve.Evaluate(transitionTimer / transitionDuration);
             transform.localPosition = Ross_Utils.GetPositionBetween(ratio, moveFrom, moveTo);
         }
     }
 }
Esempio n. 4
0
    public static float GetRandBetween(float inValMin, float inValMax)
    {
        int min    = (int)(inValMin * 10000.0f);
        int max    = (int)(inValMax * 10000.0f);
        int outInt = min + (Ross_Utils.GetRand((max - min)));

        return(((float)outInt) / 10000.0f);
    }
Esempio n. 5
0
        //----------------------------------------------
        public AchievementDetails GetAchievementDetails(Profile.Enum2 inAchievement)
        {
            for (int i = 0; i < achievementDetailsList.Length; i++)
            {
                if (achievementDetailsList[i].achievementType == inAchievement)
                {
                    return(achievementDetailsList[i]);
                }
            }

            Ross_Utils.Assert(false);

            return(achievementDetailsList[0]);
        }
Esempio n. 6
0
        public void SaveGameData()
        {
                #if UNITY_WEBPLAYER
            return;
                #endif

            if (logOn)
            {
                Ross_Utils.Log("Write to GameSave File " + fileName);
            }

            string     path = this.pathForDocumentsFile(fileName);
            FileStream file = new FileStream(path, FileMode.Open, FileAccess.Write);
            this.WriteGameDataToFile(file);
            file.Close();
        }
Esempio n. 7
0
    public static Vector2 GetPositionWithinCircle(float circleRadius)
    {
        float distThing = 1000000000.0f;
        float sqrThing  = circleRadius * circleRadius;
        float xPos;
        float yPos;

        do
        {
            xPos = Ross_Utils.GetRandBetween(-circleRadius, circleRadius);
            yPos = Ross_Utils.GetRandBetween(-circleRadius, circleRadius);

            distThing = Ross_Utils.GetSqrDistance(new Vector2(0, 0), new Vector2(xPos, yPos));
        }while(distThing > sqrThing);

        return(new Vector2(xPos, yPos));
    }
Esempio n. 8
0
    public static int GetNearestThing(Vector2 headPos, Vector2[] positionArray, int numItems)
    {
        float nearestDistanceSqr = -1.0f;
        int   nearestItem        = -1;

        for (int i = 0; i < numItems; i++)
        {
            float sqrDist = Ross_Utils.GetSqrDistance(headPos, positionArray[i]);

            if ((nearestItem == -1) || (sqrDist < nearestDistanceSqr))
            {
                nearestItem        = i;
                nearestDistanceSqr = sqrDist;
            }
        }

        return(nearestItem);
    }
Esempio n. 9
0
    public static float GetCosInterpolation(float inVal, float inMin, float inMax)
    {
        if (inVal < inMin)
        {
            inVal = inMin;
        }

        if (inVal > inMax)
        {
            inVal = inMax;
        }

        float range = inMax - inMin;

        Ross_Utils.Assert(range != 0.0f);

        float ratio = (inMax - inVal) / (inMax - inMin);

        ratio *= 4095.999f;

        Ross_Utils.Assert(initialised);

        return(preCalculatedCos[(int)ratio]);
    }
Esempio n. 10
0
 public static float GetRandomRotation()
 {
     return(Ross_Utils.GetRandBetween(0.0f, 2.0f * Mathf.PI));
 }
Esempio n. 11
0
    //-----------------------------------------------------------------------------
    public void StartThrob()
    {
        Ross_Utils.Log("Throb: Start Throb 0");

        this.StartThrobMultiple(1);
    }