// TODO: Validate results /// <summary> /// Absorbs a SkyFragmentPiece and adds its value back to it. /// Also destroy the piece here. /// </summary> /// <param name="piece">Sky Fragment</param> public void Absorb(SkyFragmentPiece piece) { // If empty, set numerator and denominator as the absorbed piece's // if (this.GetNumerator() == 0) { // this.SetNumerator (piece.GetNumerator()); // this.SetDenominator (piece.GetDenominator()); // } // // Else get the LCD and update the value by adding the current value // // with the absorbed piece's value // else { int lcd = General.LCD((int)this.GetDenominator(), (int)piece.GetDenominator()); // float lcdPieceNumVal = piece.GetDenominator () / lcd * piece.GetNumerator (); // float lcdBlockNumeratorVal = this.GetDenominator () / lcd * this.GetNumerator (); float lcdPieceNumVal = lcd / piece.GetDenominator() * piece.GetNumerator(); float lcdBlockNumeratorVal = lcd / this.GetDenominator() * this.GetNumerator(); float newNum = lcdPieceNumVal + lcdBlockNumeratorVal; this.SetNumerator((int)newNum); this.SetDenominator(lcd); float[] results = General.SimplifyFraction(this.GetNumerator(), this.GetDenominator()); this.SetNumerator(results[0]); this.SetDenominator(results[1]); // } this.skyFragmentPieces.Remove(piece); Destroy(piece.gameObject); }
// For player fragment label public void SkyOverlapUpdate(Parameters parameters) { SkyFragmentPiece overlappingPiece = parameters.GetObjectExtra(OVERLAPPING_PIECE) as SkyFragmentPiece; if (overlappingPiece != null) { this.UpdateLabel((int)overlappingPiece.GetNumerator(), (int)overlappingPiece.GetDenominator()); this.ShowHint(); } else { this.HideHint(); } }