有人可以帮助我并告诉我如何将这些随机数相乘。正如您在代码中看到的那样,我给出的条件是只出现6个数字。我需要在最后一个数字出现时,我将输入一个输入来指示乘以这些数字的结果。现在我只需要知道如何使它们成倍增加或聚集。感谢。
这是我的代码:
using System.Collections;
using System.Collections.Generic;
using UnityEngine.UI;
using UnityEngine;
public class RandomNumbers : MonoBehaviour {
public Transform mCanvas;
public Text[] numbers;
bool activate = true;
public int suma;
int idx = 0;
void Start()
{
Shuffle(numbers);
StartCoroutine("CreateNum");
}
IEnumerator CreateNum()
{
yield return new WaitForSeconds(3f);
while (idx < numbers.Length)
{
if (activate)
{
Text g = Instantiate(numbers[idx], new Vector3(Random.Range(-450, 450), Random.Range(-450, 450), 0), Quaternion.identity);
g.transform.SetParent(mCanvas, false);
}
yield return new WaitForSeconds(2f);
++idx;
if(idx >= 6)
{
activate = false;
}
}
}
public void Shuffle<T>(IList<T> list)
{
int n = list.Count;
while (n > 1)
{
n--;
int k = Random.Range(0, n + 1);
T value = list[k];
list[k] = list[n];
list[n] = value;
}
}
// Update is called once per frame
void Update() {
}
}