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(); } }
//private int _barrackID = 8833; //private int _elixirCollectorID = 4856; //private int _elixirStorageID = 2090; //private int _goldMineID = 3265; //private int _goldStorageID = 9074; //private int _towerID = 4764; //private int _townCenterID = 2496; //private int _windMillID = 6677; //private int _armyCampID = 2728; //private BaseItemScript _townCenterInstance; //private BaseItemScript _builderHutInstance; //private BaseItemScript _builderInstance; //private BaseItemScript _towerInstance; //private BaseItemScript _armyCampForSwordManInstance; //private BaseItemScript _armyCampForArcherInstance; //public BaseItemScript testCharacter; //private BaseItemScript[] _swordManInstances; //private BaseItemScript[] _archerInstances; public void LoadUserScene() { this.ClearScene(); SceneData sceneData = DataBaseManager.instance.GetScene(); foreach (ItemData itemData in sceneData.items) { this.AddItem(itemData.itemId, itemData.instanceId, itemData.posX, itemData.posZ, true, true); } //LOAD UNITS ON CAMP BaseItemScript[] armyCamps = GetArmyCamps(); if (armyCamps.Length > 0) { for (int index = 0; index < _swordManCount; index++) { var camp = armyCamps[Random.Range(0, armyCamps.Length)]; BaseItemScript unit = this.AddItem(_swordMan_ID, -1, camp.GetPositionX(), camp.GetPositionZ(), true, true); unit.WalkRandom(camp); } for (int index = 0; index < _archerCount; index++) { var camp = armyCamps[Random.Range(0, armyCamps.Length)]; BaseItemScript unit = this.AddItem(_archer_ID, -1, camp.GetPositionX(), camp.GetPositionZ(), true, true); unit.WalkRandom(camp); } } //for (int index = 0; index < 25; index++) //{ // //tree // BaseItemScript tree = this.AddItem(5341, true, true); // tree.SetPosition(GroundManager.instance.GetRandomFreePosition()); //} GroundManager.instance.UpdateAllNodes(); this.UpdateWalls(); UIManager.instance.ShowGameOverlayWindow(); }