public override void OnHumanPlayerClick()
    {
        base.OnHumanPlayerClick();

        var message = new CreatingUnit_Data(Prefab, Price, CreatingDuration);

        (_player as HumanPlayer).CommandSender.SendCommand(ObjectCommand.AddUnitToFactory, message);
    }
    public override void OnCompPlayerClick(List <Transform> commandReceivers)
    {
        base.OnCompPlayerClick(commandReceivers);

        var message = new CreatingUnit_Data(Prefab, Price, CreatingDuration);

        foreach (Transform receiver in commandReceivers)
        {
            receiver.SendMessage(ObjectCommand.AddUnitToFactory.ToString(), message, SendMessageOptions.DontRequireReceiver);
        }
    }
 void DequeueUnitData()
 {
     _currentTaskData = null;
     if (_taskDataList.Count > 0)
     {
         _hasCreatingUnit = true;
         _currentTaskData = _taskDataList[0];
         _timeBeforeSpawn = _currentTaskData.CreatingDuration;
         _taskDataList.RemoveAt(0);
     }
     else
     {
         _hasCreatingUnit = false;
         enabled          = false;
     }
 }
    public void AddUnitToFactory(CreatingUnit_Data data)
    {
        if (OwnerPlayer == null)
        {
            OwnerPlayer      = GameObjectManager.GetOwnerPlayer(gameObject);
            _currentTaskData = null;
        }

        if (data != null)
        {
            if (OwnerPlayer.Money - data.Price >= 0) //добавить юнит, только если у игрока хватает денег
            {
                OwnerPlayer.Money -= data.Price;
                _taskDataList.Add(data);
                enabled          = true;
                _hasCreatingUnit = true;
                if (_timeBeforeSpawn <= 0)
                {
                    DequeueUnitData();
                }
            }
        }
    }