Example #1
0
 public void UpdateCropsArea()
 {
     if (!IsUIOpen)
     {
         return;
     }
     while (cropAgents.Count < CurrentField.Crops.Count)
     {
         CropAgent ca = ObjectPool.Get(UI.cropPrefab, UI.cropCellsParent).GetComponent <CropAgent>();
         cropAgents.Add(ca);
     }
     while (cropAgents.Count > CurrentField.Crops.Count)
     {
         cropAgents[cropAgents.Count - 1].Clear(true);
         cropAgents.RemoveAt(cropAgents.Count - 1);
     }
     for (int i = 0; i < CurrentField.Crops.Count; i++)
     {
         cropAgents[i].Init(CurrentField.Crops[i]);
     }
 }
Example #2
0
 private void Clear()
 {
     if (Data && Data.Info)
     {
         GameManager.Crops.TryGetValue(Data.Info, out var crops);
         if (crops != null)
         {
             crops.Remove(this);
             if (crops.Count < 1)
             {
                 GameManager.Crops.Remove(Data.Info);
             }
         }
         Data = null;
     }
     if (Parent)
     {
         Parent.Crops.Remove(this);
         Parent = null;
     }
     resourceInfo = null;
     UI           = null;
 }