//-------------------------------------------------- // private //-------------------------------------------------- //-------------------------------------------------- // public //-------------------------------------------------- //-------------------------------------------------- // protected //-------------------------------------------------- protected void OnEnable() { if (GAME == null) { return; } for (int a = 0; a < DATA_PACKAGE.serviceSignalPatterns.Length; ++a) { ServiceSignalPattern ssp = DATA_PACKAGE.serviceSignalPatterns[a]; if (!DATA_PACKAGE.ServiceIsEnabled(ssp.service)) { labels[a].text = ""; continue; } labels[a].text = "<size=25><b>" + ssp.service + " (" + ssp.signalPatterns.Length + ")</b></size>"; for (int b = 0; b < ssp.signalPatterns.Length; ++b) { SignalPattern sp = ssp.signalPatterns[b]; labels[a].text += "\n frequency " + b + ":"; labels[a].text += "\n signal strength: " + sp.strength; labels[a].text += "\n signal speed: " + sp.speed; } } }
//-------------------------------------------------- // public //-------------------------------------------------- public ServiceStatus GetServiceStatus(SignalPattern[] _signalPatterns) { foreach (ServiceSignalPattern ssp in serviceSignalPatterns) { List <SignalPattern> _tempSP = new List <SignalPattern> (); _tempSP.AddRange(_signalPatterns); if (ssp.signalPatterns.Length != _signalPatterns.Length || !enabledServices.Contains(ssp.service)) { continue; } for (int a = 0; a < ssp.signalPatterns.Length; ++a) { SignalPattern sp = ssp.signalPatterns[a]; for (int b = 0; b < _tempSP.Count; ++b) { SignalPattern spCompare = _tempSP[b]; float _strengthDiff = Mathf.Abs(sp.strength - spCompare.strength); float _speedDiff = Mathf.Abs(sp.speed - spCompare.speed); if (_strengthDiff < signalAccuracy && _speedDiff < signalAccuracy) // stable enough { _tempSP.RemoveAt(b); break; } } } if (_tempSP.Count <= 0) { return(new ServiceStatus(ssp.service, true)); } else if (( float )_tempSP.Count / ( float )ssp.signalPatterns.Length <= minOverallSignalAccuracy) { return(new ServiceStatus(ssp.service, false)); } } return(null); }