//////////////////////////////////////////////////////////////////////////////////////////////////////////////// /// <summary> // /// </summary> public void UpdateSelectionWheelItemCounters() { // Get selection wheel reference SelectionWheel selectionWheel = null; if (GameManager.Instance._IsRadialMenu) { selectionWheel = GameManager.Instance.SelectionWheel.GetComponentInChildren <SelectionWheel>(); } else { selectionWheel = GameManager.Instance.selectionWindow.GetComponentInChildren <SelectionWheel>(); } // Update each item counter in the selection wheel based off the current building queue List <AbstractionCounter> absCounter = new List <AbstractionCounter>(); absCounter = GetAmountOfEachUnits(); for (int i = 0; i < selectionWheel._WheelButtons.Count; i++) { SelectionWheelUnitRef wheelUnitRef = selectionWheel._WheelButtons[i].GetComponent <SelectionWheelUnitRef>(); if (absCounter != null) { if (absCounter.Count > 0) { // Button item has a valid abstraction reference Abstraction absRef = wheelUnitRef.AbstractRef; if (absRef != null) { for (int k = 0; k < absCounter.Count; k++) { // Button item abstraction type matches the building queue abstraction type if (absRef.GetType() == absCounter[k]._Abstraction.GetType()) { // Update button item counter wheelUnitRef.SetQueueCounter(absCounter[k]._AbsCount); break; } // Reached the end of the absCounter array if (k == absCounter.Count - 1) { // Button item abstraction counter is 0 wheelUnitRef.SetQueueCounter(0); } } } else { continue; } } else { wheelUnitRef.SetQueueCounter(0); } } } }
private static TimeSpan MeasureTypeofPerformance(Abstraction instance) { var stopwatch = new Stopwatch(); stopwatch.Start(); for (long i = 0; i < 100000000; ++i) { // ReSharper disable once UnusedVariable var foo = instance.GetType() == typeof(ConcreteType); } stopwatch.Stop(); return(stopwatch.Elapsed); }
//////////////////////////////////////////////////////////////////////////////////////////////////////////////// /// <summary> // /// </summary> /// <param name="abs"></param> public void UpdateLogoSliders(Abstraction abs) { for (int i = 0; i < _WheelButtons.Count; i++) { // Find matching slider SelectionWheelUnitRef unitRef = _WheelButtons[i].GetComponent <SelectionWheelUnitRef>(); if (unitRef.AbstractRef != null) { if (unitRef.AbstractRef.GetType() == abs.GetType()) { // Match found - update the slider attached to this button unitRef.SetCurrentBuildProgress(abs.GetBuildPercentage()); } else { unitRef.SetCurrentBuildProgress(0f); } } } }
public override List <RepresentationMesh> PlaceRepresentations(Ensemble ensemble, Abstraction abstraction, GameObject compositionGameObject) { List <RepresentationMesh> resultMesh = new List <RepresentationMesh> (); List <Structure> resultStructures = new List <Structure> (); this.ensemble = ensemble; List <KeyValuePair <string, float> > paramsValues = new List <KeyValuePair <string, float> > (); for (int i = 0; i < axisParameters.Count; i++) { paramsValues.Add(new KeyValuePair <string, float>(axisParameters[i].name, axisParameters[i].value)); } ParameterInfo xPI = ensemble.parametersInfo [axisParameters [0].name]; float xDelta = (xPI.maxValue - xPI.minValue) / (float)(xPI.count - 1); ParameterInfo zPI = ensemble.parametersInfo [axisParameters [1].name]; float zDelta = (zPI.maxValue - zPI.minValue) / (float)(zPI.count - 1); List <float> xDeltas = new List <float> (); for (float i = xPI.minValue; i <= xPI.maxValue; i += xDelta) { xDeltas.Add(i); } if (xDeltas.Count > dimSizeX) { int diffCount = xDeltas.Count - dimSizeX; for (int i = 0; i < diffCount; i++) { xDeltas.RemoveAt(Random.Range(0, xDeltas.Count - 1)); } } List <float> zDeltas = new List <float> (); for (float i = zPI.minValue; i <= zPI.maxValue; i += zDelta) { zDeltas.Add(i); } foreach (float xValue in xDeltas) { foreach (float zValue in zDeltas) { paramsValues[0] = new KeyValuePair <string, float>(paramsValues[0].Key, xValue); paramsValues[1] = new KeyValuePair <string, float>(paramsValues[1].Key, zValue); resultStructures.Add(ensemble.GetStructure(paramsValues)); } } Camera cam = Camera.main; yPosStart = cam.gameObject.transform.position.y - cam.orthographicSize / 2f + (float)camOffset; int val = 0; if (abstraction.GetType() == typeof(AbstractionScale1D)) { xPosStart += itemSizeX / 2f; } foreach (Structure structure in resultStructures) { (structure.representation as RepresentationMesh).gameObject.SetActive(true); RepresentationMesh newRep = abstraction.Process(structure.representation as RepresentationMesh) as RepresentationMesh; (structure.representation as RepresentationMesh).gameObject.SetActive(false); newRep.gameObject.transform.parent = compositionGameObject.transform; float valX = (float)(val / dimSizeZ); float valZ = (float)(val % dimSizeZ); newRep.gameObject.transform.parent = compositionGameObject.transform; newRep.gameObject.transform.position = new Vector3(xPosStart + valX * (itemSizeX + itemOffset) + newRep.offset.x, yPosStart, zPosStart + valZ); val++; switch (type) { case SPType.None: { break; } case SPType.Transparent: { newRep.SetMaterialTransparency(0.25f); break; } case SPType.Colorify: { float zVal = valZ / zPI.count; Color zColor = Color.white; if (zVal <= 0.5f) { zColor = new Color(1f, zVal * 2f, zVal * 2f); } else { zColor = new Color(2f - 2f * zVal, 2f - 2f * zVal, 1f); } newRep.SetMaterialColor(zColor); break; } case SPType.BlendColor: { float zVal = valZ / zPI.count; Color zColor = Color.white; if (zVal <= 0.5f) { zColor = new Color(1f, zVal * 2f, zVal * 2f); } else { zColor = new Color(2f - 2f * zVal, 2f - 2f * zVal, 1f); } newRep.BlendMaterialColor(zColor); break; } case SPType.ColorTransparent: { float zVal = valZ / zPI.count; Color zColor = Color.white; if (zVal <= 0.5f) { zColor = new Color(1f, zVal * 2f, zVal * 2f); } else { zColor = new Color(2f - 2f * zVal, 2f - 2f * zVal, 1f); } newRep.SetMaterialColorTransparency(zColor, 0.25f); break; } default: { newRep.SetMaterialTransparency(0.25f); break; } } } GameObject uiGO = GameObject.Find("UI") as GameObject; GameObject xPanel = uiGO.transform.Find("X Axis Panel").gameObject; GameObject sliderGO = xPanel.transform.Find("Slider").gameObject; sliderGO.SetActive(true); Slider slider = sliderGO.GetComponent <Slider> (); slider.minValue = xPI.minValue; slider.maxValue = xPI.maxValue; slider.value = xPI.minValue; slider.onValueChanged.RemoveAllListeners(); slider.onValueChanged.AddListener(CameraPositionChanged); cameraXEndPos = xPosStart + ((float)xPI.count - 0.5f) * itemSizeX + ((float)xPI.count - 1f) * itemOffset - cam.orthographicSize + camOffset; return(resultMesh); }