コード例 #1
0
ファイル: Program.cs プロジェクト: Cons-Cat/PG1-Idle
        // Method for game loop thread.
        #region

        static void GameLoop()
        {
            while (!exitCheck)
            {
                // Loop through all agents to increase the player's points bank.
                for (uint i = 0; i < 10; i++)
                {
                    if (!agentObjsArr[i].isLocked)
                    {
                        if (agentObjsArr[i].count.value > 0)
                        {
                            MassiveNumber tempNumber = new MassiveNumber();

                            // Evaluate agents.
                            tempNumber.value = tempNumber.Add(agentObjsArr[i].pointsRate.Mult((agentObjsArr[i].count.value), agentObjsArr[i].count.echelon), agentObjsArr[i].pointsRate.echelon);
                            tempNumber.UpdateEchelon();

                            // Evaluate upgrades.
                            if (upgraObjsArr[i].count.value > 0)
                            {
                                tempNumber.value = tempNumber.Mult(upgraObjsArr[i].count.Mult(upgraObjsArr[i].incomeMultiplier, upgraObjsArr[i].count.echelon) + 1, 1);
                                tempNumber.UpdateEchelon();
                            }

                            gamePoints.value = gamePoints.Add(tempNumber.value, tempNumber.echelon);
                            gamePoints.UpdateEchelon();
                        }
                    }
                }

                RenderWindow.gamePoints = gamePoints;
                gamePoints.UpdateEchelon();

                lock (raceConditionLocker)
                {
                    // Attempt to update the console.
                    UpdateConsole();
                    SharedResource++;

                    // Attempt to unlock every locked agent.
                    UnlockAgents();
                }

                // Loop every second.
                Thread.Sleep(1000);
            }
        }
コード例 #2
0
        // Exponentiation operation:
        public MassiveNumber Pow(double argExponent)
        {
            // Instantiate and initialize variables.
            MassiveNumber returnNumber = new MassiveNumber();

            returnNumber.value   = 1;
            returnNumber.echelon = 1;

            MassiveNumber fractionNumber = new MassiveNumber();

            fractionNumber.value   = 1;
            fractionNumber.echelon = 1;

            double fractionExpo = argExponent % 1d;

            // If the exponent is not an integer.
            if (fractionExpo > 0)
            {
                fractionNumber.value   = this.value;
                fractionNumber.echelon = this.echelon;

                // (x*1,000) ^ y = (x)^y * (10^3)^y
                fractionNumber.value = Math.Pow(fractionNumber.value, fractionExpo);
                fractionNumber.UpdateEchelon();

                for (int i = 0; i < fractionNumber.echelon + 1; i++)
                {
                    fractionNumber.value *= Math.Pow(10, fractionExpo);
                    fractionNumber.UpdateEchelon();
                }
            }

            returnNumber.value   = this.value;
            returnNumber.echelon = this.echelon;

            // x^4 = ( x*x*x*x )
            if ((uint)argExponent > 1)
            {
                for (uint i = 1; i < (uint)argExponent; i++)
                {
                    returnNumber.value = returnNumber.Mult(this.value, this.echelon);
                    returnNumber.UpdateEchelon();

                    if (i < (uint)argExponent - 1)
                    {
                        returnNumber.echelon *= returnNumber.echelon;
                    }
                }
            }
            else
            {
                if ((uint)argExponent > 1)
                {
                    // Mult at least once
                    returnNumber.value = returnNumber.Mult(returnNumber.value, 1);
                    returnNumber.UpdateEchelon();
                }
            }

            // Mult whole exponentiated value to fractional exponentiated value.
            // This method is equivalent to:
            // x^4.5 = ( x*x*x*x ) * ( x^0.5 )

            if (argExponent >= 1)
            {
                if (fractionExpo > 0)
                {
                    returnNumber.value = returnNumber.Mult(fractionNumber.value, fractionNumber.echelon);
                }
            }
            else
            {
                returnNumber.value = fractionNumber.value;
            }

            returnNumber.UpdateEchelon();

            return(returnNumber);
        }