Exemplo n.º 1
0
    // +-----------+----------------------------------------------------------------------------------------------------------------------------------------------
    // | Evolution |
    // +-----------+

    // Checks if this strain of illness has evolved to the next strain
    // Returns 0 if no mutation, 1 if mutated into an existing strain, 2 if mutated into a new strain
    public int NextStrain(int currentStrain, GameObject person)
    {
        // If evolution is turned off, then do not mutate
        if (!GameControllerScript.canEvolve || GameControllerScript.totalUpdates <= 50)
        {
            return(0);
        }

        int maxStrain     = GameControllerScript.maxStrain;
        int maxNumStrains = strainColors.Length;

        if (currentStrain < strainColors.Length && currentStrain < resistantStrain)
        {
            float constant = GameControllerScript.baseMutationChance / ((maxNumStrains - 1) / (float)maxNumStrains);

            float chanceOfMutation = maxNumStrains - currentStrain;
            chanceOfMutation /= (float)maxNumStrains;
            chanceOfMutation *= constant;
            chanceOfMutation /= 5f;

            if (Random.value < chanceOfMutation)
            {
                person.SendMessage("Infect", currentStrain + 1);

                if (currentStrain == maxStrain)
                {
                    GameControllerScript.maxStrain = maxStrain + 1;

                    StartCoroutine(GameControllerScript.ChangePopupText(
                                       "A new strain that is resistant to treatment " + treatmentName + " has appeared!"
                                       ));

                    return(2);
                }
                else
                {
                    return(1);
                }
            }
            else if (resistantStrain > maxNumStrains && currentStrain < maxStrain && Random.value < 0.015625f)
            {
                StartCoroutine(GameControllerScript.ChangePopupText(
                                   "Strain " + (currentStrain + 1) + " has become resistant to treatment " + treatmentName + "!"
                                   ));

                return(2);
            }
        }

        return(0);
    }