public void AddToBuildQueue(MobileUnitType unitType) { _buildQueue.Add(new BuildingUnit() { buildProgress = 0f, unitType = unitType }); }
public bool TryBuildUnit(MobileUnitType type) { var buildingUnitConfig = _unitsConfig.GetConfigByType(type); if (_gameData.TryChangePlayerMoney(UnitModel.teamId, -buildingUnitConfig.cost)) { _factoryModel.AddToBuildQueue(type); return(true); } return(false); }
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); }
public MobileUnitConfig GetConfigByType(MobileUnitType type) { return(Array.Find(mobileUnits, u => u.typeId == type)); }