/// <summary> /// Addition operation stability update. Coroutine moving the stability pointer towards the right of the number line. /// </summary> /// <param name="numerator">Numerator of the affecting fraction</param> /// <param name="denominator">Denominator of the affecting fraction</param> /// <param name="color">Highlight Color to be added.</param> /// <returns>None</returns> public IEnumerator AddStability(float numerator, float denominator, Color color) { // The new stability will be the current stability + the added stability float[] addedStability = General.AddFractions(this.GetNumerator(), this.GetDenominator(), numerator, denominator); // Simplify (Reduced form) float[] newStability = General.SimplifyFraction(addedStability[0], addedStability[1]); float newNumerator = addedStability[0]; float newDenominator = addedStability[1]; this.GetStabilityPointer().SetNumerator(newNumerator); this.GetStabilityPointer().SetDenominator(newDenominator); // Where the new fraction point should be located in the numberline // float endPosition = this.GetLineLength () * this.GetNumerator() / this.GetDenominator(); // ADDED MAX CHANGE but was working <!!!> //float endPosition = this.GetLineLength() * this.GetNumerator() / this.GetDenominator() / GetMaxPoint(); float startPosition = this.GetHighlightEnd(); float endPosition = startPosition + ((this.GetLineLength() / GetMaxPoint()) * numerator / denominator); // WAS WORKING //float endPosition = (this.GetLineLength() / (this.GetMaxPoint() + 1)) * numerator / denominator; Debug.Log("End Position: " + endPosition); Debug.Log("Line Length: " + this.GetLineLength()); Debug.Log("Fraction: " + this.GetNumerator() / this.GetDenominator()); Debug.Log("Max Point: " + GetMaxPoint()); // Added highlight's start position will be the end position of the last highlight //float startPosition = this.GetHighlightEnd(); // AddHighlight (numerator, denominator, startPosition, endPosition); yield return(StartCoroutine(AddHighlight(numerator, denominator, color, startPosition, endPosition))); }
public void UpdateCurrentStability() { if (this.skyPieces != null && this.skyPieces.Count > 0) { float num1 = this.skyPieces [0].GetNumerator() * this.skyPieces [0].GetBlockSize(); float den1 = this.skyPieces [0].GetDenominator(); float num2; float den2; float[] results; for (int i = 1; i < this.skyPieces.Count; i++) { num2 = skyPieces [i].GetNumerator() * skyPieces [i].GetBlockSize(); den2 = skyPieces [i].GetDenominator(); results = General.AddFractions(num1, den1, num2, den2); num1 = results [0]; den1 = results [1]; } float[] simplifiedResults = General.SimplifyFraction(num1, den1); this.stabilityNumerator = simplifiedResults [0]; this.stabilityDenominator = simplifiedResults [1]; } else { this.stabilityNumerator = 0; this.stabilityDenominator = this.hollowBlock.GetDenominator(); } }
/// <summary> /// Addition operation stability update. Coroutine moving the stability pointer towards the right of the number line. /// </summary> /// <param name="numerator">Numerator of the affecting fraction</param> /// <param name="denominator">Denominator of the affecting fraction</param> /// <param name="color">Highlight Color to be added.</param> /// <returns>None</returns> public IEnumerator AddStabilityInstant(float numerator, float denominator, Color color) { Debug.Log("<color=orange>STAB Value: </color>" + numerator + " / " + denominator); // The new stability will be the current stability + the added stability float[] addedStability = General.AddFractions(this.GetNumerator(), this.GetDenominator(), numerator, denominator); // Simplify (Reduced form) float[] newStability = General.SimplifyFraction(addedStability[0], addedStability[1]); float newNumerator = addedStability[0]; float newDenominator = addedStability[1]; this.GetStabilityPointer().SetNumerator(newNumerator); this.GetStabilityPointer().SetDenominator(newDenominator); // Where the new fraction point should be located in the numberline // float endPosition = this.GetLineLength () * this.GetNumerator() / this.GetDenominator(); //float endPosition = this.GetLineLength() * numerator / denominator / GetMaxPoint(); // Added highlight's start position will be the end position of the last highlight float startPosition = this.GetHighlightEnd(); //float endPosition = startPosition+((this.GetLineLength()/(this.GetMaxPoint()+1)) * numerator / denominator); // ADDED MAX CHANGED but was working float endPosition = startPosition + ((this.GetLineLength() / (this.GetMaxPoint())) * numerator / denominator); Debug.LogError("INSTA ADD"); Debug.LogError("Highlight size: " + this.highlights.Count); Debug.LogError("Line Length is: " + GetLineLength()); Debug.LogError("Start Position: " + startPosition); Debug.LogError("End Position: " + endPosition); Debug.LogError("Line Length: " + this.GetLineLength()); Debug.LogError("Fraction: " + numerator / denominator); Debug.LogError("Fraction WHOLE: " + newNumerator / newDenominator); Debug.LogError("Max Point: " + GetMaxPoint()); // AddHighlight (numerator, denominator, startPosition, endPosition); yield return(StartCoroutine(AddHighlightInstant(numerator, denominator, color, startPosition, endPosition))); }