dimanche 30 avril 2017

How do I multiply or gather random numbers?

Can someone help me and tell me how to multiply these random numbers. As you can see in the code, I gave the condition that only 6 numbers appear. I need that when the last figure appears I will make an input to indicate the result of multiplying these numbers. Now I only need an idea how to make them multiply or gather. Thanks.

This is my code:

     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() {

}

}




Aucun commentaire:

Enregistrer un commentaire