저는 사람들이 수학을 배우는 데 도움이되는 교육용 게임을 만들고 있지만 문제를 놓고 비틀 거리고 있습니다.C# 난수의 존재 확인
플레이어가 클릭 한 지식을 테스트하기 위해 클릭 한 일부 큐브 내의 텍스트를 무작위로 추출합니다. 그러나 현재 사용하고있는 코드로 인해 화면에 정답이없는 경우가 있습니다. 나는 이것을 치료할 수 있니?
코드 : 어떤 도움을 크게 감상 할 수
글로벌 재 Randomise
using UnityEngine;
using System.Collections;
public class RandomiseAll : MonoBehaviour {
public GUIText[] answer;
int randomNumber;
int[] test;
public void Randomise(){
for (int i = 0; i < answer.Length; i++) {
randomNumber = Random.Range (0, 36);
answer [i].text = randomNumber.ToString();
}
}
}
버튼
using UnityEngine;
using System.Collections;
public class RNG : MonoBehaviour
{
public GUIText thisAnswer;
public RandomiseAll reRoll;
int randomNumber = 0;
int miniScore = 0;
// Use this for initialization
void Awake()
{
randomNumber = Random.Range (0, 36);
thisAnswer.text = randomNumber.ToString();
}
void OnMouseUpAsButton()
{
if (randomNumber % 3 == 0) {
miniScore += 100;
reRoll.Randomise();
Debug.Log (miniScore.ToString());
} else if (randomNumber % 3 != 0) {
reRoll.Randomise();
Debug.Log (miniScore.ToString());
}
}
}.
당신은뿐만 아니라 중복 답변을하지 마세요? –
역 퀴즈 (Jeopardy)를하지 않는 한,'thisAnswer.text = randomNumber.ToString();'은 너무 심오합니다. –