Renamed GameScore class to GameData.

Makes more sense, since the class is responsible for more than just the score.

Signed-off-by: Jeffrey Han <itdelatrisu@gmail.com>
This commit is contained in:
Jeffrey Han
2015-01-27 03:19:39 -05:00
parent ef9e38bf2d
commit 44bdf70c98
6 changed files with 113 additions and 113 deletions

View File

@@ -20,7 +20,7 @@ package itdelatrisu.opsu.objects;
import itdelatrisu.opsu.GameImage;
import itdelatrisu.opsu.GameMod;
import itdelatrisu.opsu.GameScore;
import itdelatrisu.opsu.GameData;
import itdelatrisu.opsu.OsuHitObject;
import itdelatrisu.opsu.Utils;
import itdelatrisu.opsu.audio.MusicController;
@@ -40,8 +40,8 @@ public class Circle implements HitObject {
/** The associated Game object. */
private Game game;
/** The associated GameScore object. */
private GameScore score;
/** The associated GameData object. */
private GameData data;
/** The color of this circle. */
private Color color;
@@ -66,14 +66,14 @@ public class Circle implements HitObject {
* Constructor.
* @param hitObject the associated OsuHitObject
* @param game the associated Game object
* @param score the associated GameScore object
* @param data the associated GameData object
* @param color the color of this circle
* @param comboEnd true if this is the last hit object in the combo
*/
public Circle(OsuHitObject hitObject, Game game, GameScore score, Color color, boolean comboEnd) {
public Circle(OsuHitObject hitObject, Game game, GameData data, Color color, boolean comboEnd) {
this.hitObject = hitObject;
this.game = game;
this.score = score;
this.data = data;
this.color = color;
this.comboEnd = comboEnd;
}
@@ -94,15 +94,15 @@ public class Circle implements HitObject {
Utils.drawCentered(GameImage.HITCIRCLE.getImage(), x, y, color);
color.a = oldAlpha;
Utils.COLOR_WHITE_FADE.a = 1f;
score.drawSymbolNumber(hitObject.getComboNumber(), x, y,
GameImage.HITCIRCLE.getImage().getWidth() * 0.40f / score.getDefaultSymbolImage(0).getHeight());
data.drawSymbolNumber(hitObject.getComboNumber(), x, y,
GameImage.HITCIRCLE.getImage().getWidth() * 0.40f / data.getDefaultSymbolImage(0).getHeight());
}
}
/**
* Calculates the circle hit result.
* @param time the hit object time (difference between track time)
* @return the hit result (GameScore.HIT_* constants)
* @return the hit result (GameData.HIT_* constants)
*/
private int hitResult(int time) {
int trackPosition = MusicController.getPosition();
@@ -110,14 +110,14 @@ public class Circle implements HitObject {
int[] hitResultOffset = game.getHitResultOffsets();
int result = -1;
if (timeDiff < hitResultOffset[GameScore.HIT_300])
result = GameScore.HIT_300;
else if (timeDiff < hitResultOffset[GameScore.HIT_100])
result = GameScore.HIT_100;
else if (timeDiff < hitResultOffset[GameScore.HIT_50])
result = GameScore.HIT_50;
else if (timeDiff < hitResultOffset[GameScore.HIT_MISS])
result = GameScore.HIT_MISS;
if (timeDiff < hitResultOffset[GameData.HIT_300])
result = GameData.HIT_300;
else if (timeDiff < hitResultOffset[GameData.HIT_100])
result = GameData.HIT_100;
else if (timeDiff < hitResultOffset[GameData.HIT_50])
result = GameData.HIT_50;
else if (timeDiff < hitResultOffset[GameData.HIT_MISS])
result = GameData.HIT_MISS;
//else not a hit
return result;
@@ -130,7 +130,7 @@ public class Circle implements HitObject {
if (distance < circleRadius) {
int result = hitResult(hitObject.getTime());
if (result > -1) {
score.hitResult(
data.hitResult(
hitObject.getTime(), result,
hitObject.getX(), hitObject.getY(),
color, comboEnd, hitObject.getHitSoundType()
@@ -151,19 +151,19 @@ public class Circle implements HitObject {
int[] hitResultOffset = game.getHitResultOffsets();
boolean isAutoMod = GameMod.AUTO.isActive();
if (overlap || trackPosition > time + hitResultOffset[GameScore.HIT_50]) {
if (overlap || trackPosition > time + hitResultOffset[GameData.HIT_50]) {
if (isAutoMod) // "auto" mod: catch any missed notes due to lag
score.hitResult(time, GameScore.HIT_300, x, y, color, comboEnd, hitSound);
data.hitResult(time, GameData.HIT_300, x, y, color, comboEnd, hitSound);
else // no more points can be scored, so send a miss
score.hitResult(time, GameScore.HIT_MISS, x, y, null, comboEnd, hitSound);
data.hitResult(time, GameData.HIT_MISS, x, y, null, comboEnd, hitSound);
return true;
}
// "auto" mod: send a perfect hit result
else if (isAutoMod) {
if (Math.abs(trackPosition - time) < hitResultOffset[GameScore.HIT_300]) {
score.hitResult(time, GameScore.HIT_300, x, y, color, comboEnd, hitSound);
if (Math.abs(trackPosition - time) < hitResultOffset[GameData.HIT_300]) {
data.hitResult(time, GameData.HIT_300, x, y, color, comboEnd, hitSound);
return true;
}
}

View File

@@ -20,7 +20,7 @@ package itdelatrisu.opsu.objects;
import itdelatrisu.opsu.GameImage;
import itdelatrisu.opsu.GameMod;
import itdelatrisu.opsu.GameScore;
import itdelatrisu.opsu.GameData;
import itdelatrisu.opsu.OsuFile;
import itdelatrisu.opsu.OsuHitObject;
import itdelatrisu.opsu.Utils;
@@ -52,8 +52,8 @@ public class Slider implements HitObject {
/** The associated Game object. */
private Game game;
/** The associated GameScore object. */
private GameScore score;
/** The associated GameData object. */
private GameData data;
/** The color of this slider. */
private Color color;
@@ -258,14 +258,14 @@ public class Slider implements HitObject {
* Constructor.
* @param hitObject the associated OsuHitObject
* @param game the associated Game object
* @param score the associated GameScore object
* @param data the associated GameData object
* @param color the color of this circle
* @param comboEnd true if this is the last hit object in the combo
*/
public Slider(OsuHitObject hitObject, Game game, GameScore score, Color color, boolean comboEnd) {
public Slider(OsuHitObject hitObject, Game game, GameData data, Color color, boolean comboEnd) {
this.hitObject = hitObject;
this.game = game;
this.score = score;
this.data = data;
this.color = color;
this.comboEnd = comboEnd;
@@ -311,8 +311,8 @@ public class Slider implements HitObject {
if (sliderClicked)
; // don't draw current combo number if already clicked
else
score.drawSymbolNumber(hitObject.getComboNumber(), x, y,
hitCircle.getWidth() * 0.40f / score.getDefaultSymbolImage(0).getHeight());
data.drawSymbolNumber(hitObject.getComboNumber(), x, y,
hitCircle.getWidth() * 0.40f / data.getDefaultSymbolImage(0).getHeight());
color.a = oldAlpha;
Utils.COLOR_WHITE_FADE.a = oldAlphaFade;
@@ -350,7 +350,7 @@ public class Slider implements HitObject {
* Calculates the slider hit result.
* @param time the hit object time (difference between track time)
* @param lastCircleHit true if the cursor was held within the last circle
* @return the hit result (GameScore.HIT_* constants)
* @return the hit result (GameData.HIT_* constants)
*/
private int hitResult() {
int lastIndex = hitObject.getSliderX().length - 1;
@@ -358,20 +358,20 @@ public class Slider implements HitObject {
int result;
if (tickRatio >= 1.0f)
result = GameScore.HIT_300;
result = GameData.HIT_300;
else if (tickRatio >= 0.5f)
result = GameScore.HIT_100;
result = GameData.HIT_100;
else if (tickRatio > 0f)
result = GameScore.HIT_50;
result = GameData.HIT_50;
else
result = GameScore.HIT_MISS;
result = GameData.HIT_MISS;
if (currentRepeats % 2 == 0) // last circle
score.hitResult(hitObject.getTime() + (int) sliderTimeTotal, result,
data.hitResult(hitObject.getTime() + (int) sliderTimeTotal, result,
hitObject.getSliderX()[lastIndex], hitObject.getSliderY()[lastIndex],
color, comboEnd, hitObject.getHitSoundType());
else // first circle
score.hitResult(hitObject.getTime() + (int) sliderTimeTotal, result,
data.hitResult(hitObject.getTime() + (int) sliderTimeTotal, result,
hitObject.getX(), hitObject.getY(), color, comboEnd, hitObject.getHitSoundType());
return result;
@@ -390,16 +390,16 @@ public class Slider implements HitObject {
int[] hitResultOffset = game.getHitResultOffsets();
int result = -1;
if (timeDiff < hitResultOffset[GameScore.HIT_50]) {
result = GameScore.HIT_SLIDER30;
if (timeDiff < hitResultOffset[GameData.HIT_50]) {
result = GameData.HIT_SLIDER30;
ticksHit++;
} else if (timeDiff < hitResultOffset[GameScore.HIT_MISS])
result = GameScore.HIT_MISS;
} else if (timeDiff < hitResultOffset[GameData.HIT_MISS])
result = GameData.HIT_MISS;
//else not a hit
if (result > -1) {
sliderClicked = true;
score.sliderTickResult(hitObject.getTime(), result,
data.sliderTickResult(hitObject.getTime(), result,
hitObject.getX(), hitObject.getY(), hitObject.getHitSoundType());
return true;
}
@@ -439,23 +439,23 @@ public class Slider implements HitObject {
int time = hitObject.getTime();
// start circle time passed
if (trackPosition > time + hitResultOffset[GameScore.HIT_50]) {
if (trackPosition > time + hitResultOffset[GameData.HIT_50]) {
sliderClicked = true;
if (isAutoMod) { // "auto" mod: catch any missed notes due to lag
ticksHit++;
score.sliderTickResult(time, GameScore.HIT_SLIDER30,
data.sliderTickResult(time, GameData.HIT_SLIDER30,
hitObject.getX(), hitObject.getY(), hitSound);
} else
score.sliderTickResult(time, GameScore.HIT_MISS,
data.sliderTickResult(time, GameData.HIT_MISS,
hitObject.getX(), hitObject.getY(), hitSound);
}
// "auto" mod: send a perfect hit result
else if (isAutoMod) {
if (Math.abs(trackPosition - time) < hitResultOffset[GameScore.HIT_300]) {
if (Math.abs(trackPosition - time) < hitResultOffset[GameData.HIT_300]) {
ticksHit++;
sliderClicked = true;
score.sliderTickResult(time, GameScore.HIT_SLIDER30,
data.sliderTickResult(time, GameData.HIT_SLIDER30,
hitObject.getX(), hitObject.getY(), hitSound);
}
}
@@ -514,32 +514,32 @@ public class Slider implements HitObject {
if ((Utils.isGameKeyPressed() && distance < followCircleRadius) || isAutoMod) {
// mouse pressed and within follow circle
followCircleActive = true;
score.changeHealth(delta * GameScore.HP_DRAIN_MULTIPLIER);
data.changeHealth(delta * GameData.HP_DRAIN_MULTIPLIER);
// held during new repeat
if (isNewRepeat) {
ticksHit++;
if (currentRepeats % 2 > 0) // last circle
score.sliderTickResult(trackPosition, GameScore.HIT_SLIDER30,
data.sliderTickResult(trackPosition, GameData.HIT_SLIDER30,
hitObject.getSliderX()[lastIndex], hitObject.getSliderY()[lastIndex], hitSound);
else // first circle
score.sliderTickResult(trackPosition, GameScore.HIT_SLIDER30,
data.sliderTickResult(trackPosition, GameData.HIT_SLIDER30,
c[0], c[1], hitSound);
}
// held during new tick
if (isNewTick) {
ticksHit++;
score.sliderTickResult(trackPosition, GameScore.HIT_SLIDER10,
data.sliderTickResult(trackPosition, GameData.HIT_SLIDER10,
c[0], c[1], (byte) -1);
}
} else {
followCircleActive = false;
if (isNewRepeat)
score.sliderTickResult(trackPosition, GameScore.HIT_MISS, 0, 0, (byte) -1);
data.sliderTickResult(trackPosition, GameData.HIT_MISS, 0, 0, (byte) -1);
if (isNewTick)
score.sliderTickResult(trackPosition, GameScore.HIT_MISS, 0, 0, (byte) -1);
data.sliderTickResult(trackPosition, GameData.HIT_MISS, 0, 0, (byte) -1);
}
return false;

View File

@@ -20,7 +20,7 @@ package itdelatrisu.opsu.objects;
import itdelatrisu.opsu.GameImage;
import itdelatrisu.opsu.GameMod;
import itdelatrisu.opsu.GameScore;
import itdelatrisu.opsu.GameData;
import itdelatrisu.opsu.OsuHitObject;
import itdelatrisu.opsu.Utils;
import itdelatrisu.opsu.audio.MusicController;
@@ -43,8 +43,8 @@ public class Spinner implements HitObject {
/** The associated OsuHitObject. */
private OsuHitObject hitObject;
/** The associated GameScore object. */
private GameScore score;
/** The associated GameData object. */
private GameData data;
/** The last rotation angle. */
private float lastAngle = -1f;
@@ -68,14 +68,14 @@ public class Spinner implements HitObject {
* Constructor.
* @param hitObject the associated OsuHitObject
* @param game the associated Game object
* @param score the associated GameScore object
* @param data the associated GameData object
*/
public Spinner(OsuHitObject hitObject, Game game, GameScore score) {
public Spinner(OsuHitObject hitObject, Game game, GameData data) {
this.hitObject = hitObject;
this.score = score;
this.data = data;
// calculate rotations needed
float spinsPerMinute = 100 + (score.getDifficulty() * 15);
float spinsPerMinute = 100 + (data.getDifficulty() * 15);
rotationsNeeded = spinsPerMinute * (hitObject.getEndTime() - hitObject.getTime()) / 60000f;
}
@@ -117,13 +117,13 @@ public class Spinner implements HitObject {
GameImage.SPINNER_CLEAR.getImage().drawCentered(width / 2, height / 4);
int extraRotations = (int) (rotations - rotationsNeeded);
if (extraRotations > 0)
score.drawSymbolNumber(extraRotations * 1000, width / 2, height * 2 / 3, 1.0f);
data.drawSymbolNumber(extraRotations * 1000, width / 2, height * 2 / 3, 1.0f);
}
}
/**
* Calculates and sends the spinner hit result.
* @return the hit result (GameScore.HIT_* constants)
* @return the hit result (GameData.HIT_* constants)
*/
private int hitResult() {
// TODO: verify ratios
@@ -132,16 +132,16 @@ public class Spinner implements HitObject {
float ratio = rotations / rotationsNeeded;
if (ratio >= 1.0f ||
GameMod.AUTO.isActive() || GameMod.SPUN_OUT.isActive()) {
result = GameScore.HIT_300;
result = GameData.HIT_300;
SoundController.playSound(SoundEffect.SPINNEROSU);
} else if (ratio >= 0.8f)
result = GameScore.HIT_100;
result = GameData.HIT_100;
else if (ratio >= 0.5f)
result = GameScore.HIT_50;
result = GameData.HIT_50;
else
result = GameScore.HIT_MISS;
result = GameData.HIT_MISS;
score.hitResult(hitObject.getEndTime(), result, width / 2, height / 2,
data.hitResult(hitObject.getEndTime(), result, width / 2, height / 2,
Color.transparent, true, (byte) -1);
return result;
}
@@ -164,12 +164,12 @@ public class Spinner implements HitObject {
// spin automatically (TODO: correct rotation angles)
if (GameMod.AUTO.isActive()) {
// "auto" mod (fast)
score.changeHealth(delta * GameScore.HP_DRAIN_MULTIPLIER);
data.changeHealth(delta * GameData.HP_DRAIN_MULTIPLIER);
rotate(delta / 20f);
return false;
} else if (GameMod.SPUN_OUT.isActive()) {
// "spun out" mod (slow)
score.changeHealth(delta * GameScore.HP_DRAIN_MULTIPLIER);
data.changeHealth(delta * GameData.HP_DRAIN_MULTIPLIER);
rotate(delta / 32f);
return false;
}
@@ -188,7 +188,7 @@ public class Spinner implements HitObject {
if (lastAngle >= 0f) { // skip initial clicks
float angleDiff = Math.abs(lastAngle - angle);
if (angleDiff < Math.PI / 2) { // skip huge angle changes...
score.changeHealth(delta * GameScore.HP_DRAIN_MULTIPLIER);
data.changeHealth(delta * GameData.HP_DRAIN_MULTIPLIER);
rotate(angleDiff);
}
}
@@ -207,10 +207,10 @@ public class Spinner implements HitObject {
// added one whole rotation...
if (Math.floor(newRotations) > rotations) {
if (newRotations > rotationsNeeded) { // extra rotations
score.changeScore(1000);
data.changeScore(1000);
SoundController.playSound(SoundEffect.SPINNERBONUS);
} else {
score.changeScore(100);
data.changeScore(100);
SoundController.playSound(SoundEffect.SPINNERSPIN);
}
}