Exemple #1
0
 public int Repair(int generatorId, int count)
 {
     if (Units.ContainsKey(generatorId))
     {
         var unitInfo = Units[generatorId];
         int repaired = unitInfo.Repair(count);
         GameEvents.OnGeneratorUnitsCountChanged(unitInfo);
         return(repaired);
     }
     return(0);
 }
Exemple #2
0
        public void SetLiveUnits(int generatorId, int count)
        {
            int oldCount = 0;

            if (Units.ContainsKey(generatorId))
            {
                oldCount = Units[generatorId].LiveCount;
            }
            Units[generatorId].SetLive(count);
            GameEvents.OnGeneratorUnitsCountChanged(Units[generatorId]);
        }
Exemple #3
0
        public void ForceBroke(int generatorId, int count)
        {
            int liveCount = GetUnitLiveCount(generatorId);
            var unit      = GetUnit(generatorId);

            unit.Broke(count);
            if (liveCount != unit.LiveCount)
            {
                GameEvents.OnGeneratorUnitsCountChanged(unit);
            }
        }
Exemple #4
0
        public void AddLiveUnits(int generatorId, int count)
        {
            int oldCount = 0;

            if (Units.ContainsKey(generatorId))
            {
                oldCount = Units[generatorId].LiveCount;
                Units[generatorId].AddLive(count);
            }
            else
            {
                Units.Add(generatorId, new TransportUnitInfo(generatorId, count));
            }
            GameEvents.OnGeneratorUnitsCountChanged(Units[generatorId]);
        }
Exemple #5
0
        private bool UpdateBroke(float deltaTime)
        {
            bool isWasBroked = false;

            if (IsLoaded && Services.ResourceService.IsLoaded && Services.GameModeService.IsGame)
            {
                if (MechanicService != null)
                {
                    foreach (var kvp in Units)
                    {
                        GeneratorData generatorData = Services.ResourceService.Generators.GetGeneratorData(kvp.Key);

                        if (generatorData.Type == GeneratorType.Normal)
                        {
                            if (Services.ManagerService.IsHired(kvp.Key))
                            {
                                MechanicData mechanicData            = ResourceService.MechanicDataRepository.GetMechanicData(kvp.Key);
                                int          mechanicCount           = MechanicService.GetMechanicCount(kvp.Key);
                                int          unitsWhichCanBrokeCount = GetUnitsWhichCanBroke(kvp.Key, mechanicData, mechanicCount);
                                if (unitsWhichCanBrokeCount > 0)
                                {
                                    int minLiveCount = MechanicService.GetServicedUnitCount(generatorData.Id);

                                    int totalUnitCount = GetUnitTotalCount(generatorData.Id);

                                    float speed = GetUnitBrokenSpeed(mechanicData, totalUnitCount);

                                    bool isManagerHired = Services.ManagerService.IsHired(kvp.Key);
                                    bool isBrokeAllowed = Services.MechanicService.IsUnlocked;

                                    if (isManagerHired && isBrokeAllowed)
                                    {
                                        if (kvp.Value.UpdateBroke(deltaTime, speed, minLiveCount, Services))
                                        {
                                            isWasBroked = true;
                                            GameEvents.OnGeneratorUnitsCountChanged(kvp.Value);
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
                //UDebug.Log($"was broked => {isWasBroked}");
            }
            return(isWasBroked);
        }