public override Task Create() { CalculatorTask task = new CalculatorTask(); task.InitTaskWithTaskSO(this); task.taskPanel = ShipPanel.Calculator; return(task); }
public override bool OnStartJob(JobParameters @params) { parameters = @params; calculator = new CalculatorTask(this); calculator.Execute(); return(false); // No more work to do! }
// Use this for initialization public override void Start() { task = (CalculatorTask)panelController.currentTask; QuestionText.text = task.questionText; AnswerText.text = ""; for (int i = 0; i < Buttons.Length; i++) { int j = i; Button b = Buttons[i]; b.onClick.RemoveAllListeners(); b.onClick.AddListener(() => this.PressButton(j)); } }
public void GenerateQuestion(CalculatorTask task) { int x = (int)Random.Range(1, 10); int y = (int)Random.Range(1, 10); int rand = (int)Random.RandomRange(0, 3); string questionText; int correctAnswer; switch (rand) { case 0: correctAnswer = x + y; questionText = "What is\n\n" + x + " + " + y + "? "; break; case 1: correctAnswer = x * y; questionText = "What is\n\n" + x + " * " + y + "? "; break; case 2: default: if (x < y) { int temp = x; x = y; y = temp; } correctAnswer = x - y; questionText = "What is\n\n" + x + " - " + y + "? "; break; } task.operand1 = x; task.operand2 = y; task.correctAnswer = correctAnswer; task.questionText = questionText; }