void Update()
    {
        float x = 0;
        float y = 0;
        float z = 0;

        if (xAxisEquation.equationType == Equation.EquationType.SQUARE)
        {
            ExponentialEquation eq = (ExponentialEquation)xAxisEquation;
            x = (float)(eq.outerCoefficient * Math.Pow(time * eq.innerCoefficient, eq.exponent));
        }
        else if (xAxisEquation.equationType == Equation.EquationType.SIN)
        {
            SineEquation eq = (SineEquation)xAxisEquation;
            x = (float)(eq.outerCoefficient * Math.Sin(time * eq.innerCoefficient));
        }
        else if (xAxisEquation.equationType == Equation.EquationType.LINEAR)
        {
            LinearEquation eq = (LinearEquation)xAxisEquation;
            x = (float)(eq.coefficient * time);
        }
        if (yAxisEquation.equationType == Equation.EquationType.SQUARE)
        {
            ExponentialEquation eq = (ExponentialEquation)yAxisEquation;
            y = (float)(eq.outerCoefficient * Math.Pow(time * eq.innerCoefficient, eq.exponent));
        }
        else if (yAxisEquation.equationType == Equation.EquationType.SIN)
        {
            SineEquation eq = (SineEquation)yAxisEquation;
            y = (float)(eq.outerCoefficient * Math.Sin(time * eq.innerCoefficient));
        }
        else if (yAxisEquation.equationType == Equation.EquationType.LINEAR)
        {
            LinearEquation eq = (LinearEquation)yAxisEquation;
            y = (float)(eq.coefficient * time);
        }
        if (zAxisEquation.equationType == Equation.EquationType.SQUARE)
        {
            ExponentialEquation eq = (ExponentialEquation)zAxisEquation;
            z = (float)(eq.outerCoefficient * Math.Pow(time * eq.innerCoefficient, eq.exponent));
        }
        else if (zAxisEquation.equationType == Equation.EquationType.SIN)
        {
            SineEquation eq = (SineEquation)zAxisEquation;
            z = (float)(eq.outerCoefficient * Math.Sin(time * eq.innerCoefficient));
        }
        else if (zAxisEquation.equationType == Equation.EquationType.LINEAR)
        {
            LinearEquation eq = (LinearEquation)zAxisEquation;
            z = (float)(eq.coefficient * time);
        }

        transform.position = (transform.rotation * new Vector3((float)x, (float)y, (float)z)) + new Vector3(initX, initY, initZ);

        if (time > lifetime)
        {
            Destroy(this.gameObject);
        }
        time += Time.deltaTime;
    }
Beispiel #2
0
        /// <summary>
        /// Gets a score representing how likely a studio is to crunch based on how
        /// frequently they put out games. The more often they put out games, the more
        /// likely they are to crunch. However, it also accounts for employees. A studio
        /// putting out a game a year with 2000 staff is less likely to be crunching than
        /// the same for a studio with 20 staff.
        /// </summary>
        /// <returns>The crunch overtime score.</returns>
        /// <param name="years">The year values for release dates of all of a studio's games.</param>
        /// <param name="employeeCount">How many employees work at the studio.</param>
        public static float GetCrunchOvertimeScore(int[] years, int employeeCount)
        {
            //Log information
            if (Logger.VERBOSE)
            {
                Logger.Log("Finding crunch over time score.");
            }

            //This is to counteract a bug, where the games that haven't been released yet
            //are returned as '1's.
            List <float> yearsF = new List <float>();

            for (int a = 0; a < years.Length; a++)
            {
                if (years[a].ToString().Length >= 4)
                {
                    yearsF.Add(years[a]);
                }
            }

            //Create a list of x-values. Basically just an array of incrementing values
            //that matches in length to the years.
            float[] inputs = MathUtils.GenInputs(yearsF.Count);

            //When plotted, the years form an exponential graph when sorted. The steeper
            //it is, the less frequently they put out games.
            BestFit             bf  = MathUtils.ExpRegression(inputs, yearsF.ToArray());
            ExponentialEquation exp = (ExponentialEquation)bf.equation;

            //Return the rate. The higher the rate (steeper curve), the less likely to crunch.
            //Takes into account the number of employees.
            float x = exp.r * employeeCount;

            return(x);
        }
Beispiel #3
0
        public void TestExponentialEquation()
        {
            var testSubject = new ExponentialEquation()
            {
                ConstantValue = 4, Power = 3.5
            };
            var x           = 5;
            var testResultY = testSubject.SolveForY(x);
            var testResultX = testSubject.SolveForX(testResultY);

            Assert.AreEqual(x, testResultX);

            testSubject = new ExponentialEquation
            {
                ConstantValue = System.Math.Pow(10, -13),
                Power         = 6.547
            };

            testResultY = testSubject.SolveForY(50);
            Console.WriteLine(testResultY);
        }