public void AddToBuildQueue(MobileUnitType unitType)
 {
     _buildQueue.Add(new BuildingUnit()
     {
         buildProgress = 0f,
         unitType      = unitType
     });
 }
예제 #2
0
    public bool TryBuildUnit(MobileUnitType type)
    {
        var buildingUnitConfig = _unitsConfig.GetConfigByType(type);

        if (_gameData.TryChangePlayerMoney(UnitModel.teamId, -buildingUnitConfig.cost))
        {
            _factoryModel.AddToBuildQueue(type);
            return(true);
        }

        return(false);
    }
예제 #3
0
    public UnitFacade Create(MobileUnitType type, int team, Transform spawnTransform)
    {
        var subContainer = _container.CreateSubContainer();
        var settings     = new MovableUnitInstaller.Parameters()
        {
            teamId = team
        };

        subContainer.BindInstance(settings);

        var unit = subContainer.InstantiatePrefab(_unitsConfig.GetConfigByType(type).prefab, spawnTransform.position, spawnTransform.rotation, null);

        return(unit.GetComponent <UnitFacade>());
    }
    private void OnBuildProgressUpdated(MobileUnitType typeId, float progress)
    {
        if (typeId == _buildableUnitType)
        {
            if (progress >= 1)
            {
                _progressImage.fillAmount = 0;

                ShowUnitsInQueueCount();
            }
            else
            {
                _progressImage.fillAmount = progress < 1 ? progress : 0;
            }
        }
    }
 public int GetUnitsCountInBuildQueue(MobileUnitType type)
 {
     return(_buildQueue.FindAll(u => u.unitType == type).Count);
 }
예제 #6
0
 public MobileUnitConfig GetConfigByType(MobileUnitType type)
 {
     return(Array.Find(mobileUnits, u => u.typeId == type));
 }