示例#1
0
    void Start()
    {
        instance  = this;
        encounter = GameController.Encounter;

        if (encounter == null)
        {
            encounter               = new Encounter();
            encounter.gender        = Game.Gender.MALE;
            encounter.size          = Game.Size.LARGE;
            encounter.weight        = UnityEngine.Random.Range(35, 150);
            encounter.fatPercentage = UnityEngine.Random.Range(5, 75);
            encounter.CalculateStars();
        }

        Debug.Log("====================ENCOUNTER STARTED====================");
        Debug.Log("Encounter :: " + encounter + ", value :: " + encounter.CalculatePercentage());
        Debug.Log("=========================================================");

        weightValue.text        = "" + String.Format("{0:.##}", encounter.weight) + "kg";
        fatPercentageValue.text = "" + encounter.fatPercentage + "%";
        genderValue.text        = "" + (encounter.gender == Game.Gender.MALE ? "Male" : "Female");

        // Calculations based on encounter
        mashLoseSpaces = encounter.stars * 2;
        totalSpaces    = encounter.CalculatePercentage() * 10 + (10 - encounter.CalculatePercentage());
        time           = 20 + (encounter.CalculatePercentage() * 2);
        if (totalSpaces < 10)
        {
            totalSpaces = 10;
        }

        // Start encounter
        StartCoroutine(StartEncounterMashing());
    }
    public Encounter GenerateEncounter()
    {
        Encounter encounter = new Encounter();

        encounter.size          = size;
        encounter.fatPercentage = Random.Range(Game.Limits.fatPercentageMin * GetMinFatModifierBySize(), Game.Limits.fatPercentageMax / GetMaxFatModifierBySize());
        encounter.gender        = Random.Range(0, 2) == 0 ? Game.Gender.MALE : Game.Gender.FEMALE;
        encounter.weight        = Random.Range((float)Game.Limits.weightMin * GetMinWeightModifierBySize(), (float)Game.Limits.weightMax / GetMaxWeightModifierBySize());
        encounter.CalculateStars();
        return(encounter);
    }