public void SetBlock(float weightValue, int unitValue) { Mass = WeightUnitConverter.TrueWeight(weightValue, unitValue);; if (_weightValueVisualText != null) { _weightValueVisualText.text = weightValue.ToString(); } if (_weightUnitVisualText != null) { _weightUnitVisualText.text = weightUnitDictionary[unitValue].ToString(); } if (Mass > 0) { _boundaryPositionY = 11.4f; _boundaryPositionX = 16.42f; } else { _boundaryPositionY = 8.2f; _boundaryPositionX = 16.25f; } BlockController.SelectedWeightBlock = this; }
public void CheckAnswer() { if (_answerInputValue.text != "") { float answer = WeightUnitConverter.TrueWeight(float.Parse(_answerInputValue.text), _answerInputUnit.value); if (answer == _trueWeight) { _answerCorrectionFeedback.text = "Correto !"; _confirmAnswerButton.SetActive(false); _nextChallengeButton.SetActive(true); } else { _answerCorrectionFeedback.text = "Incorreto !"; } } }
public override void StartChallenge() { _confirmAnswerButton.SetActive(true); _nextChallengeButton.SetActive(false); GameController.Singleton.BlockController.ResetWeightBlocks(); _numberOfWeightBlocks = Random.Range(1, 4); int randomWeight = Random.Range(-1, 1); do { _convertedWeight = Random.Range(-100, 100); _convertedWeight /= 10; } while (_convertedWeight == 0); _trueWeight = WeightUnitConverter.TrueWeight(_convertedWeight, 0); _answerInputValue.text = ""; _answerCorrectionFeedback.text = ""; for (int i = 0; i < _numberOfWeightBlocks; i++) { if (randomWeight < 0) { _desiredHook = Random.Range(8, 16); } else { _desiredHook = Random.Range(0, 8); } GameController.Singleton.BlockController.CreateChallengeBlock(randomWeight, _convertedWeight, 0, GameController.Singleton.LevelController.MainBalance.GetHooks()[_desiredHook].transform.position); } if (GameController.Singleton.LevelController.MainBalance.GetTotalWeight() == 0) { GameController.Singleton.BlockController.CreateChallengeBlock(randomWeight, _convertedWeight, 0, GameController.Singleton.LevelController.MainBalance.GetHooks()[_desiredHook].transform.position); } Debug.Log("True Weight: " + _trueWeight); }