How can I make the Update() function of an item run inside a List<>?
I need to run timers that are inside items in a List<> in the Update() function Here is the code of the Item:
using UnityEngine;
using System.Collections;
[System.Serializable]
public class Units {
public string Name = "John";
public int Life;
public int Food = 14;
public int Water = 3;
public bool Infected = false;
public bool Dead = false;
public int Strength = 0;
public int Agility = 0;
public int Inteligence = 0;
public int Medicine = 0;
public int Science = 0;
public int Survival = 0;
public int LockPicking = 0;
public int Electronics = 0;
public int Hacking = 0;
public int Combat = 0;
public int traps = 0;
public int InfectedSeconds;
public int InfectedMinutes;
public int InfectedHours;
public int InfectedDays = 3;
// Use this for initialization
void Start () {
}
// Update is called once per frame
void Update () {
if (Infected){
InfectedSeconds -= Mathf.CeilToInt(Time.deltaTime);
if (InfectedSeconds <= 0){
InfectedMinutes -= 1;
InfectedSeconds = 59;
}
if (InfectedMinutes <= 0){
InfectedHours -= 1;
InfectedMinutes = 59;
}
if (InfectedHours <= 0){
InfectedDays -=1;
InfectedHours = 23;
}
}
if (InfectedDays <=0 || Food <=0 || Water <=0){
Dead = true;
}
}
}
Thanks!