Esempio n. 1
0
    public void UpdateValue(int value)
    {
        if (_list.Count == value)
        {
            return;
        }

        if (_list.Count < value)
        {
            for (int i = _list.Count; i < value; i++)
            {
                var spawned = Spawner.Spawn(Template, transform);
                _list.Add(spawned);
            }
        }
        else if (_list.Count > 0)
        {
            for (int i = _list.Count - 1; value < _list.Count; i--)
            {
                var spawned = _list[i];
                _list.RemoveAt(i);
                Spawner.Despawn(spawned);
            }
        }
    }
Esempio n. 2
0
 public void ExecuteDestruction(GameObject destroyer = null)
 {
     if (OnDestruction != null)
     {
         OnDestruction(gameObject, destroyer);
     }
     _spawner.Despawn(gameObject);
 }