Exemplo n.º 1
0
    public void UpdateSimpleGraphForBmi(BMICalculateScript calculationResult)
    {
        Pointer.SetActive(true);
        BMIValue = calculationResult.RecentCalculatedBMIValue;
        Pointer.transform.localPosition = startingPosition;

        GetBMITypeBasedOnBMIValue(out bmiType, BMIValue);

        DimmingAllBMISections();

        float startPosition;

        switch (bmiType)
        {
        case BMIType.underweight:
            startPosition          = startingPosition.x;
            positionAdjustForScale = sectionWidth * (BMIValue / 18.5f);

            Pointer.transform.localPosition  = new Vector2(startPosition + (positionAdjustForScale), startingPosition.y);
            listOfDimBg.ElementAt(0).enabled = false;
            break;

        case BMIType.normal:
            startPosition          = startingPosition.x + sectionWidth;
            positionAdjustForScale = sectionWidth * ((BMIValue - 18.5f) / (24.99f - 18.5f));

            Pointer.transform.localPosition  = new Vector2(startPosition + (positionAdjustForScale), startingPosition.y);
            listOfDimBg.ElementAt(1).enabled = false;
            break;

        case BMIType.overweight:
            startPosition          = startingPosition.x + (2 * sectionWidth);
            positionAdjustForScale = sectionWidth * ((BMIValue - 24.99f) / (29.99f - 24.99f));

            Pointer.transform.localPosition  = new Vector2(startPosition + (positionAdjustForScale), startingPosition.y);
            listOfDimBg.ElementAt(2).enabled = false;
            break;

        case BMIType.obese:
            startPosition          = startingPosition.x + (3 * sectionWidth);
            positionAdjustForScale = sectionWidth * ((BMIValue - 29.99f) / (34.99f - 29.99f));

            Pointer.transform.localPosition  = new Vector2(startPosition + (positionAdjustForScale), startingPosition.y);
            listOfDimBg.ElementAt(3).enabled = false;
            break;

        case BMIType.extremeObese:
            if (BMIValue > 40f)
            {
                BMIValue = 40f;
            }

            startPosition          = startingPosition.x + (4 * sectionWidth);
            positionAdjustForScale = sectionWidth * ((BMIValue - 35.99f) / (39.99f - 34.99f));

            Pointer.transform.localPosition  = new Vector2(startPosition + (positionAdjustForScale), startingPosition.y);
            listOfDimBg.ElementAt(4).enabled = false;
            break;
        }
    }
Exemplo n.º 2
0
    public void OnClick_CreateUser()
    {
        string guidID   = Guid.NewGuid().ToString();
        string nickName = NickName.text;
        string name     = Name.text;
        int    age      = Convert.ToInt32(Age.text);

        int    day      = Convert.ToInt32(Birthday_Day.text);
        int    month    = Convert.ToInt32(Birthday_Month.text);
        int    year     = Convert.ToInt32(Birthday_Year.text);
        string birthday = new DateTime(year, month, day).ToShortDateString();

        float weight = float.Parse(Weight.text);
        float height = float.Parse(Height.text);

        string genre = Genre.ActiveToggles().FirstOrDefault().GetComponentInChildren <Text>().text;

        var calculator = new BMICalculateScript();

        UserListHolderScript script = new UserListHolderScript();
        List <User>          users  = script.FetchUsersDataFromDevice();

        users.Add(
            new User(
                guidID,
                nickName,
                true,
                new PersonalData(
                    name,
                    age,
                    weight,
                    height,
                    birthday,
                    genre,
                    new List <WeightRecord>()
        {
            new WeightRecord(
                DateTime.Now.ToString(),
                weight,
                height,
                calculator.GetBMI(weight, height)
                )
        }
                    ),
                0
                )
            );
        script.SaveUsersDataInDeviceAsJsonFile(users);

        SceneManager.LoadScene("LandingStartScene");
    }
Exemplo n.º 3
0
 void Start()
 {
     BMICalculator = GameObject.FindObjectOfType <BMICalculateScript>().GetComponent <BMICalculateScript>();
     //GenerateSimpleChart();
 }