private IEnumerator _StartTraining() { ItemsCollection.ItemData itemData = Items.GetItem(_currentTrainingTroop); float buildTime = itemData.configuration.buildTime; trainingStartTime = Time.realtimeSinceStartup; yield return(new WaitForSeconds(buildTime)); Vector3 randomFrontCell = _baseItem.GetRandomFrontCellPosition(); BaseItemScript newUnit = SceneManager.instance.AddItem(_currentTrainingTroop, -1, (int)randomFrontCell.x, (int)randomFrontCell.y, true, true); BaseItemScript nearestArmyCamp = SceneManager.instance.GetNearestArmyCamp(newUnit.GetPosition()); if (nearestArmyCamp != null) { newUnit.WalkRandom(nearestArmyCamp); } _currentTrainingTroop = -1; trainingQueue.RemoveAt(0); if (trainingQueue.Count > 0) { _Train(trainingQueue[0]); } if (TrainTroopsWindowScript.instance != null) { TrainTroopsWindowScript.instance.RenderTrainingQueue(); } }