Hello.
How are you?
I have a question with my list. I have some variables within a list that I want to be rounded up when I pass the limit. The problem with having a for is that I don’t know how to tell you that if any variable in one of my list elements exceeds the file I put in so that it is rounded, I rounded only that one, not the whole list. I leave you the code, to see if you can help me.
By the way, the method “OperationMines”, is applied in an Invoke Repeating, every second.
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
using TMPro;
public class CaracteristicasMinas : MonoBehaviour
{
[System.Serializable]
public struct Mejoras
{
public int siguienteMejora;
}
[System.Serializable]
public class Minas
{
public Sprite image;
public string nombre;
public float produccion, almacen, multi, mejora, habitantes;
public TextMeshProUGUI panelTexto;
}
public List<Minas> recursos = new List<Minas>();
public void FuncionamientoMinas()
{
for (var i = 0; i < recursos.Count; i++)
{
recursos[i].produccion = recursos[i].produccion + (recursos[i].multi * recursos[i].habitantes);
//recursos[i].produccion = Mathf.Ceil(recursos[i].produccion);
recursos[i].panelTexto.text = recursos[i].produccion.ToString();
if(recursos[i].produccion > 10.000)
{
// recursos[i].panelTexto.text = (recursos[i].produccion / 1000).ToString()+"K";
}
if (recursos[i].almacen < recursos[i].produccion)
{
recursos[i].produccion = recursos[i].almacen;
recursos[i].panelTexto.text = recursos[i].produccion.ToString();
}
}
}
}

