public void GenerateSimpleChart() { print("Create basic empty"); #region configure default values height = 180; weight = 80; weightIncrementRate = 3; heightIncrementRate = 2; double middleIndex = Math.Round(((chartSize - 1) / 2f)) + 1; startWeight = float.Parse((weight - (weightIncrementRate * (middleIndex - 1))).ToString()); startHeight = float.Parse((height - (heightIncrementRate * (middleIndex - 1))).ToString()); #endregion ; for (int i = chartSize - 1; i >= 0; i--) { for (int j = 0; j < chartSize; j++) { height = startHeight + ((j - 1) * heightIncrementRate); weight = startWeight + ((i - 1) * weightIncrementRate); float BMI = BMICalculator.GetBMI(weight, height); var singleGridCell = Instantiate(GridCell); singleGridCell.transform.SetParent(this.transform); singleGridCell.transform.localScale = Vector3.one; MakeShureBMITextIsDecimal(BMI, singleGridCell); UpdateColor(BMI, singleGridCell.transform.Find("ColorBackground").GetComponent <SpriteRenderer>()); ConfigureIfAxisLabels(i, j, singleGridCell); } } }
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"); }