void Update() { if (_hasCreatingUnit) { _timeBeforeSpawn -= Time.deltaTime; if (_timeBeforeSpawn <= 0) { Quaternion unitRotation = new Quaternion(); unitRotation.eulerAngles = _spawnRotation; unitRotation = transform.rotation * unitRotation; UnitAI newUnit = GameObjectManager.CreateObject(_currentTaskData.Prefab, PositionChecker.FindNearestFreePosition(transform.TransformPoint(_spawnPoint)), unitRotation).GetComponent <UnitAI>(); GameObjectManager.AddToPlayerObjectsList(OwnerPlayer, newUnit.transform); ////отправка юнита в пункт сбора //var message = new TaskDataMessage { // TaskData = new FollowToPoint_Task.FollowToPoint_TaskData(AssemblyPoint ), // NewQueue = true //}; //newUnit.AddTask(message); DequeueUnitData(); } } }
public void Place() { if (!_placingMode) { Debug.LogError("placing mode not enabled"); } if (_materialChanger != null) { _materialChanger.RevertMaterials(); //Destroy(_materialChanger); } //удаляем Rigidbody, если он бы добавлен ранее в StartPlacing() if (!_hasDefaultRigidbody) { var objectRigidbody = PlaceableObjectGrid.GetComponent <Rigidbody>(); Destroy(objectRigidbody); } PlaceableObjectGrid.collider.isTrigger = false;//включаем влияение объекта на физику в игре var objectAI = PlaceableObjectGrid.GetComponent <BaseObjectAI>(); if (objectAI != null) { objectAI.enabled = true; } GameObjectManager.AddToPlayerObjectsList(_player, PlaceableObjectGrid.transform); _player.Money -= PlaceableObjectPrice; //вычесть стоимость объекта из денег игрока PlaceableObjectGrid.DoUpdateGraphs(GridTags.Buildings); //обновление сетки PlaceableObjectGrid.IsGhost = false; RuntimeBatching.DoStaticBatching(PlaceableObjectGrid.transform); PlaceableObjectGrid = null; PlaceableObjectPrice = 0; _player.CursorState = CursorStates.Default; _placingMode = false; }