public void SetTarget(GameObject target, TargetParams targetParams = null) { var goWrapper = GetOrCreateGOWrapper(); bool isCloneMaterial = (bool)(targetParams?.isCloneMaterial); goWrapper.SetWrapTarget(target, isCloneMaterial); }
public bool TryAddNewTarget(string tag, AIState state, float priority, out TargetParams targetParams) { var element = TargetParams.CreateNewElement(tag, state, priority); if (TryAddTarget(element, out targetParams)) { Element.Add(element); } return(targetParams != null); }
public async Task <string> SaveTargetAsync(TargetParams target, string stationId) { var filter = Builders <Station> .Filter.Eq(s => s._id, stationId); var update = Builders <Station> .Update.Set(u => u.Targets[target.ID], target); await _MongoCollectionStations.UpdateOneAsync(filter, update); return(target.ID); }
public StringFunction(Func <IFitness> getFitnessMethod, GAStatus bestStatus, GAFunction fitnessFunc, OnGeneration generationFunc, double crossoverRate, double mutationRate, int genomeSize, TargetParams targetParams) { _getFitnessFunc = getFitnessMethod; _bestStatus = bestStatus; _crossoverRate = crossoverRate; _mutationRate = mutationRate; _genomeSize = genomeSize; _fitnessFunc = fitnessFunc; _generationFunc = generationFunc; _targetParams = targetParams; }
public StringFunctionChunk(Func <IFitness> getFitnessMethod, Action <string, object> onStepComplete, GAStatus bestStatus, GAFunction fitnessFunc, OnGeneration generationFunc, double crossoverRate, double mutationRate, int genomeSize, TargetParams targetParams, int chunkSize = 4) { _getFitnessFunc = getFitnessMethod; _onStepComplete = onStepComplete; _bestStatus = bestStatus; _crossoverRate = crossoverRate; _mutationRate = mutationRate; _genomeSize = genomeSize; _fitnessFunc = fitnessFunc; _generationFunc = generationFunc; _targetParams = targetParams; _chunkSize = chunkSize; }
private bool TryAddTarget(XElement targetElement, out TargetParams target) { string tag = targetElement.GetAttributeString("tag", null); if (HasTag(tag)) { target = null; DebugConsole.ThrowError($"Multiple targets with the same tag ('{tag}') defined! Only the first will be used!"); return(false); } else { target = new TargetParams(targetElement, Character); targets.Add(target); SubParams.Add(target); return(true); } }
void CreateGridButton(TargetParams targetParams) { // create button, set display parameters GameObject newButton = (GameObject)Instantiate(gridButtonPrefab); newButton.transform.SetParent(targetGrid.transform); newButton.GetComponent <RectTransform> ().localScale = Vector3.one; // apparently CanvasScaler modifies this newButton.GetComponentInChildren <Text> ().text = targetParams.displayName + " : " + targetParams.displayVersion; // handle button click Button buttonComponent = newButton.GetComponent <Button> (); buttonComponent.onClick.AddListener( () => StartCoroutine(HandleButtonClick(targetParams)) ); }
public TargetParams GetNewTargetParams(TerrestrialRound terrestrialRound, string targetId) { TargetParams targetParams = new TargetParams() { ID = targetId, RoundProcessed = terrestrialRound._id, AllTimeMean = new AllTimeMean() { count = 1, Position = terrestrialRound.Results.LocalCoordinates[targetId], }, TempMean = new Dictionary <string, TempMean>(), }; int temp = Convert.ToInt32(terrestrialRound.Observations[targetId].MeanF1F2.Temperature); targetParams.TempMean.Add(temp.ToString(), new TempMean() { Temperature = temp, count = 1, Position = terrestrialRound.Results.LocalCoordinates[targetId] }); return(targetParams); }
public TargetParams UpdateTargetParams(TargetParams targetParams, TerrestrialRound terrestrialRound, string targetId) { targetParams.RoundProcessed = terrestrialRound._id; targetParams.AllTimeMean.Position = MeanWeightedLocalPoint(targetParams.AllTimeMean.Position, terrestrialRound.Results.LocalCoordinates[targetId], targetParams.AllTimeMean.count); targetParams.AllTimeMean.count++; string temp = (Convert.ToInt32(terrestrialRound.Observations[targetId].MeanF1F2.Temperature)).ToString(); if (targetParams.TempMean.ContainsKey(temp)) { targetParams.TempMean[temp].Position = MeanWeightedLocalPoint(targetParams.TempMean[temp].Position, terrestrialRound.Results.LocalCoordinates[targetId], targetParams.TempMean[temp].count); targetParams.TempMean[temp].count++; } else { targetParams.TempMean.Add(temp, new TempMean() { Temperature = Convert.ToInt32(temp), count = 1, Position = terrestrialRound.Results.LocalCoordinates[targetId] }); } return(targetParams); }
private bool ProcessNewObsTime(TerrestrialRound lastRound, TerrestrialRound previRound, TerrestrialRound refRound) { Console.WriteLine("Process 2 rounds: " + lastRound._id + "and: " + previRound._id); foreach (var obs in lastRound.Observations) { if (!_Station.TerrestrialRounds[lastRound._id].FlaggedObs.Contains(obs.Key) && !_Station.TerrestrialRounds[previRound._id].FlaggedObs.Contains(obs.Key))//lastRound.Observations[obs.Key].MeanF1F2 != null) { Console.WriteLine("Process new Obs: " + obs.Key); if (lastRound.IntegrityData.ObservationIntegrityTime == null) { lastRound.IntegrityData.ObservationIntegrityTime = new Dictionary <string, ObservationIntegrityTime>(); } if (!lastRound.IntegrityData.ObservationIntegrityTime.ContainsKey(obs.Key)) { TargetParams targetParams = new TargetParams(); targetParams = _Station.Targets.ContainsKey(obs.Key) ? _Station.Targets[obs.Key] : null; lastRound.IntegrityData.ObservationIntegrityTime.Add(obs.Key, _Features.GetObservationIntegrityTime(lastRound, refRound, previRound, targetParams, obs.Key)); } } } _Round.IntegrityData = lastRound.IntegrityData; Console.WriteLine("saved round"); return(true); }
public bool TryGetTarget(string targetTag, out TargetParams target) { target = targets.FirstOrDefault(t => string.Equals(t.Tag, targetTag, StringComparison.OrdinalIgnoreCase)); return(target != null); }
public bool RemoveTarget(TargetParams target) => RemoveSubParam(target, targets);
public bool TryAddEmptyTarget(out TargetParams targetParams) => TryAddNewTarget("newtarget" + targets.Count, AIState.Attack, 0f, out targetParams);
public bool TryGetTarget(string targetTag, out TargetParams target) { target = targets.FirstOrDefault(t => t.Tag == targetTag); return(target != null); }
public ObservationIntegrityTime GetObservationIntegrityTime(TerrestrialRound currentRound, TerrestrialRound referenceRound, TerrestrialRound comparativelyRounds, TargetParams targetParams, string targetId) { if (currentRound.IntegrityData.ObservationIntegrity[targetId].Flag == true) { return(null); } ObservationIntegrityTime obstime = new ObservationIntegrityTime() { PointId = targetId, Face = "MeanF1F2", }; if (referenceRound.Results.LocalCoordinates.ContainsKey(targetId)) { obstime.DistToRef = Get2dDist(currentRound.Results.LocalCoordinates[targetId], referenceRound.Results.LocalCoordinates[targetId]); } else { var task = _LoadSaveRepo.SaveLocalCoords(currentRound.Results.LocalCoordinates[targetId], referenceRound._id); var result = task.Result; referenceRound.Results.LocalCoordinates.Add(targetId, currentRound.Results.LocalCoordinates[targetId]); obstime.DistToRef = Get2dDist(currentRound.Results.LocalCoordinates[targetId], referenceRound.Results.LocalCoordinates[targetId]); } if (comparativelyRounds.Results.LocalCoordinates.ContainsKey(targetId)) { obstime.DistToLast = Get2dDist(currentRound.Results.LocalCoordinates[targetId], comparativelyRounds.Results.LocalCoordinates[targetId]); } if (targetParams != null) { obstime.DistToAllTimeMean = Get2dDist(currentRound.Results.LocalCoordinates[targetParams.ID], targetParams.AllTimeMean.Position); int obstemp = Convert.ToInt32(currentRound.Observations[targetParams.ID].MeanF1F2.Temperature); if (targetParams.TempMean.ContainsKey(obstemp.ToString())) { obstime.DistToTempMean = Get2dDist(currentRound.Results.LocalCoordinates[targetParams.ID], targetParams.TempMean[obstemp.ToString()].Position); } else { string point = "0"; int minDeltaTemp = 1000; int deltaTemp = 0; foreach (var temp in targetParams.TempMean) { deltaTemp = Math.Abs(temp.Value.Temperature - obstemp); if (minDeltaTemp > deltaTemp) { minDeltaTemp = deltaTemp; point = temp.Key; } } obstime.DistToTempMean = Get2dDist(currentRound.Results.LocalCoordinates[targetParams.ID], targetParams.TempMean[point].Position); } } return(obstime); }
// A sample handler for loading the scene and assets when a button is clicked in the grid. // Loops over all the bundles specified for the scene to which the button corresponds, and // loads each of them from the cache or downloads them, as necessary. // This function then just retrieves all asset names, scene paths. // If it gets asset names, it checks for any assembly (".bytes") files and loads in all the contained types. // If it gets a scene name, it loads that scene at the end (i.e. after all other bundles have been processed) IEnumerator HandleButtonClick(TargetParams targetParams) { string[] allAssetNames, allScenePaths; string nextSceneName = ""; GameObject test = new GameObject("TEST TYPES"); DontDestroyOnLoad(test); foreach (TargetParams.BundleParams bundleParams in targetParams.bundleParamList) { while (!Caching.ready) { yield return(null); } using ( WWW bundleReq = WWW.LoadFromCacheOrDownload( bundleParams.bundleURL, bundleParams.version) ) { yield return(bundleReq); if (!string.IsNullOrEmpty(bundleReq.error)) { throw new UnityException("Error fetching specific bundle: " + bundleReq.error); } allAssetNames = bundleReq.assetBundle.GetAllAssetNames(); allScenePaths = bundleReq.assetBundle.GetAllScenePaths(); if (allAssetNames.Length > 0) { Debug.Log("Asset names in bundle: " + string.Join(",", allAssetNames)); foreach (string assetName in allAssetNames) { if (assetName.EndsWith(".bytes", true, System.Globalization.CultureInfo.CurrentCulture)) { TextAsset assemblyText = bundleReq.assetBundle.LoadAsset <TextAsset> (assetName); var assembly = Assembly.Load(assemblyText.bytes); var types = assembly.GetTypes(); if (types == null) { Debug.LogError("No types loaded"); } else { foreach (System.Type type in types) { var component = test.AddComponent(type); // The following part depends on the assembly loaded. // For the TestAssemblyy.bytes included with this sample, // there exist "public int x", and "public Vector3 r" fields // and this code serves as an example of how to use reflection // to access these fields using the types loaded from the assembly. /* var xFieldInfo = type.GetField ("x", BindingFlags.Instance | BindingFlags.Public); * var rFieldInfo = type.GetField ("r", BindingFlags.Instance | BindingFlags.Public); * * Debug.Log ("x value = " + (int)(xFieldInfo.GetValue (component))); * Debug.Log ("r value = " + (Vector3)(rFieldInfo.GetValue (component))); */ } } } } } if (allScenePaths.Length > 0) { Debug.Log("Scene paths in bundle: " + string.Join(",", allScenePaths)); if (nextSceneName == "") { nextSceneName = allScenePaths [0]; } } } } if (nextSceneName != "") { SceneManager.LoadScene(nextSceneName); } }