예제 #1
0
 public void DisableService(DataPackage.Service _service)
 {
     if (enabledServices != null)
     {
         enabledServices.Remove(_service);
     }
 }
예제 #2
0
 public bool HasService(DataPackage.Service _service)
 {
     foreach (ServiceStatus ss in serviceStatuses)
     {
         if (ss.service == _service)
         {
             return(true);
         }
     }
     return(false);
 }
예제 #3
0
        public void EnableService(DataPackage.Service _service)
        {
            if (enabledServices == null)
            {
                enabledServices = new List <DataPackage.Service> ();
            }

            if (!enabledServices.Contains(_service))
            {
                enabledServices.Add(_service);
            }
        }
예제 #4
0
        public float GetServiceMultiplier(DataPackage.Service _service)
        {
            float _multiplier = 0f;

            foreach (ServiceStatus ss in serviceStatuses)
            {
                if (ss.service == _service)
                {
                    _multiplier += ss.isStable ? 1f : 0.5f;
                }
            }
            return(_multiplier);
        }
예제 #5
0
        public int GetSameServiceCount(DataPackage.Service _service)
        {
            int _total = 0;

            foreach (ServiceStatus ss in serviceStatuses)
            {
                if (ss.service == _service)
                {
                    ++_total;
                }
            }
            return(_total);
        }
예제 #6
0
 public ServiceStatus(DataPackage.Service service, bool isStable)
 {
     this.service  = service;
     this.isStable = isStable;
 }
예제 #7
0
        protected void Update()
        {
            timer -= Time.deltaTime;
            if (timer <= 0)
            {
                timer  = Random.Range(minGenerateDataInterval, maxGenerateDataInterval);
                timer *= GetIntervalMultiplier();

                string[] _serviceNames = System.Enum.GetNames(typeof(DataPackage.Service));
                string[] _typeNames    = System.Enum.GetNames(typeof(DataPackage.Type));
                List <DataPackage.Service> _toSpawnServices = new List <DataPackage.Service> ();
                _toSpawnServices.AddRange(enabledServices);

                int _maxServiceTypes = enabledServices.Count + 1;
                if (_maxServiceTypes >= _serviceNames.Length)
                {
                    _maxServiceTypes = _serviceNames.Length;
                }

                int _serviceIndex = 0;
                while (_toSpawnServices.Count < _maxServiceTypes &&
                       _serviceIndex < _serviceNames.Length)
                {
                    DataPackage.Service _service = (DataPackage.Service)_serviceIndex;
                    if (!_toSpawnServices.Contains(_service))
                    {
                        _toSpawnServices.Add(_service);
                    }

                    ++_serviceIndex;
                }

                if (UI_MAIN.enabled &&
                    UI_MAIN.currentSection == UI_Main.Section.transmission)
                {
                    AudioController.Play("ui_data_new");
                }

                // A more elaborate random system that rewards the higher enabled service
                List <DataPackage.Service> _randServices = new List <DataPackage.Service> ();
                while (_randServices.Count <= 0)
                {
                    for (int a = 0; a < _toSpawnServices.Count; ++a)
                    {
                        DataPackage.Service _service = _toSpawnServices[a];
                        int   _sameServiceCount      = GAME.GetSameServiceCount(_service);
                        float _chanceDiv             = (1f / ( float )GAME.tmMachines.Length);
                        float _chance = _chanceDiv * 1.5f;
                        if (_sameServiceCount > 0)
                        {
                            _chance = _chanceDiv * _sameServiceCount;
                        }
                        float _rand = Random.Range(0f, 1f);
                        if (_rand <= _chance)
                        {
                            _randServices.Add(_service);
                        }
                    }
                }

                pendingData.Add(new DataPackage(
                                    // ( DataPackage.Service ) Random.Range ( 0, _maxServiceTypes ),
                                    _randServices[Random.Range(0, _randServices.Count)],
                                    (DataPackage.Type)Random.Range(0, _typeNames.Length),
                                    Random.Range(0, 3)
                                    ));
            }

            RunPendingData();
            RunActiveData();

            if (UI_MAIN_TRANSMISSION != null)
            {
                UI_MAIN_TRANSMISSION.UpdatePendingDataLabel(pendingData);
                UI_MAIN_TRANSMISSION.UpdateActiveDataLabel(activeData);
                UI_MAIN_TRANSMISSION.UpdateTransmittedDataLabel(transmittedData);
            }
        }
예제 #8
0
 public bool ServiceIsEnabled(DataPackage.Service _service)
 {
     return(enabledServices != null &&
            enabledServices.Contains(_service));
 }