Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Finalbranchsprint6sophia #78

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file added src/Sounds/ray_gun.mp3
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ public void shootButton(Level currentLevel, KeyCode k) {
//shoot = new ShootRight(maxX + Math.abs(shootgroup.getTranslateX()),midY,currentLevel);
shoot = new ShootRight(currentLevel, k);
shoot.execute();

}


Expand Down
13 changes: 13 additions & 0 deletions src/edu/uco/sdd/rocketdog/controller/DefaultKeyMapping.java
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ public void handleKeyPressed(RocketDogController rdController, Level currentLeve
break;
case J:
rdController.shootButton(currentLevel, KeyCode.J);
currentLevel.getSoundManager().playAudioClip("shoot");
/*int i = currentLevel.checkFiredLaser();
if (i == -1) {
break;
Expand All @@ -62,6 +63,7 @@ public void handleKeyPressed(RocketDogController rdController, Level currentLeve
break;
case K:
rdController.shootButton(currentLevel, KeyCode.K);
currentLevel.getSoundManager().playAudioClip("shootbig");
/*int charge = currentLevel.largeLaserCharge();
currentLevel.update(charge);
if(charge == 3){
Expand Down Expand Up @@ -115,6 +117,17 @@ else if(currentLevel.getMenu().getCd().getCreditsPane().isVisible()){
currentLevel.getMainMenu().setVisible(true);}
}
break;
case M:
//Mute / Unmute Game Music
if(currentLevel.getSoundManager().isMusicEnabled()){
System.out.println(currentLevel.getSoundManager().isMusicEnabled());
currentLevel.getSoundManager().muteAllMusic();
}
else if(!currentLevel.getSoundManager().isMusicEnabled()){
System.out.println(!currentLevel.getSoundManager().isMusicEnabled());
currentLevel.getSoundManager().unmuteAllMusic();
}
break;
}
}

Expand Down
52 changes: 36 additions & 16 deletions src/edu/uco/sdd/rocketdog/model/HighScore.java
Original file line number Diff line number Diff line change
Expand Up @@ -47,15 +47,7 @@ public class HighScore {
// GridPane grid;

public HighScore() {
// try {
scoresList = new ArrayList<>();
//adding records to our file and arraylist
// ScoreInformation s1 = new ScoreInformation("lilian", 100);
// ScoreInformation s2 = new ScoreInformation("kkk", 500);
// ScoreInformation s3 = new ScoreInformation("appp", 700);
// addNewScore(s1);
// addNewScore(s2);
// addNewScore(s3);
file = new File(fileName);
if (!file.exists()) {
try {
Expand All @@ -65,11 +57,39 @@ public HighScore() {
}
}
scoresList = getAllRecords();
// } catch (IOException ex) {
// Logger.getLogger(HighScore.class.getName()).log(Level.SEVERE, null, ex);
// } catch (ClassNotFoundException ex) {
// Logger.getLogger(HighScore.class.getName()).log(Level.SEVERE, null, ex);
// }

}

public void addFillerScores() {
// adding records to our file and arraylist
try {
ScoreInformation s0 = new ScoreInformation("s0", 111);
ScoreInformation s1 = new ScoreInformation("s1", 300);
ScoreInformation s2 = new ScoreInformation("s2", 500);
ScoreInformation s3 = new ScoreInformation("s3", 700);
ScoreInformation s4 = new ScoreInformation("s4", 200);
ScoreInformation s5 = new ScoreInformation("s5", 400);
ScoreInformation s6 = new ScoreInformation("s6", 650);
ScoreInformation s7 = new ScoreInformation("s7", 1500);
ScoreInformation s8 = new ScoreInformation("s8", 70);
ScoreInformation s9 = new ScoreInformation("s9", 369);
ScoreInformation s11 = new ScoreInformation("s11", 2);

addNewScore(s1);
addNewScore(s2);
addNewScore(s3);
addNewScore(s4);
addNewScore(s5);
addNewScore(s6);
addNewScore(s7);
addNewScore(s8);
addNewScore(s9);
addNewScore(s11);
} catch (IOException ex) {
Logger.getLogger(HighScore.class.getName()).log(Level.SEVERE, null, ex);
} catch (ClassNotFoundException ex) {
Logger.getLogger(HighScore.class.getName()).log(Level.SEVERE, null, ex);
}
}

public int getCurrentSize(ArrayList<ScoreInformation> scoresList) {
Expand Down Expand Up @@ -126,14 +146,14 @@ public void readHighScores() throws ClassNotFoundException, IOException {
currentSize = scoresList.size();
if (!scoresList.isEmpty()) {
minScore = scoresList.get(0).getScore();
maxScore = scoresList.get(scoresList.size()-1).getScore();
maxScore = scoresList.get(scoresList.size() - 1).getScore();
}
}

public ArrayList<ScoreInformation> getAllRecords() {
loadRecordsFromFile();
sortRecord();
System.out.println("CurrentSize="+currentSize+" | MinScore= "+minScore+" | MaxScore= "+maxScore);
System.out.println("CurrentSize=" + currentSize + " | MinScore= " + minScore + " | MaxScore= " + maxScore);
return scoresList;
}

Expand Down Expand Up @@ -190,7 +210,7 @@ public void addNewScore(String n, int s) {
public void addNewScore(int score) {
String name = "";

if (score > scoresList.get(scoresList.size() - 1).getScore()) {
if (scoresList.isEmpty() || score >= scoresList.get(scoresList.size() - 1).getScore()) {
name = JOptionPane.showInputDialog("New high score! Enter your name:");

if (name.isEmpty()) {
Expand Down
53 changes: 31 additions & 22 deletions src/edu/uco/sdd/rocketdog/model/Level.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

import edu.uco.sdd.rocketdog.commands.RocketDogController;
import edu.uco.sdd.rocketdog.controller.KeyMappingContext;
import edu.uco.sdd.rocketdog.view.GameOver;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
Expand All @@ -14,11 +13,8 @@
import javafx.scene.text.Font;
import javafx.scene.text.Text;
import java.util.Map;
import java.util.Timer;
import java.util.TimerTask;
import javafx.scene.layout.StackPane;


public class Level extends Scene implements Observer, ILevel {

public SoundManager soundManager;
Expand Down Expand Up @@ -93,6 +89,7 @@ public Level(Group root, ImageView background, int width, int height) {
rocketDog.getHitbox().setHeight(130);
rocketDog.setLevel(this);
rocketDog.setCurrentHealth(100);
rocketDog.getHealthbar().setMaxHealth(rocketDog.getCurrentHealth());

//Invisible obstruction on screen border
//addObstruction(new Obstruction(new Point2D(0,0)),width, 1);
Expand Down Expand Up @@ -130,18 +127,27 @@ public Level(Group root, ImageView background, int width, int height) {
update(rocketDog.getCurrentHealth());
scoreText.setText("Score : " + rocketDog.getScore() + " Health: " + rocketDog.getCurrentHealth());
scoreText.setFont(new Font(20));

menu.displayMenu(false);
menu.displayHsd(false);
menu.getHsd().getBackButton().setOnAction((ActionEvent) -> {
menu.displayMenu(true);
menu.displayHsd(false);
});
rocketDog.setPosition(new Point2D(150, 600));
rocketDog.getCurrentHealthLabelpb().setTranslateX(150);
rocketDog.getCurrentHealthLabelpb().setTranslateY(600-40);
rocketDog.getHealthbar().setPosition(new Point2D(150, 600-40));
rocketDog.getCurrentHealthLabelpb().setText(Double.toString(rocketDog.getCurrentHealth()));
viewportItems.getChildren().add(menu.getHsd().getScoresPane());
viewportItems.getChildren().add(menu.getCd().getCreditsPane());
viewportItems.getChildren().add(rocketDog.getGameover().getGameOVerPane());
viewportItems.getChildren().add(getMainMenu());

rocketDog.getHealthbar().displayHealthBar(true);
rocketDog.getHealthbar().setHealth(rocketDog.getCurrentHealth());
rocketDog.getHealthbar().getHealthProgressBar().setProgress(rocketDog.getCurrentHealth());
viewportItems.getChildren().add(rocketDog.getHealthbar().getHealthPane());
viewportItems.getChildren().add(rocketDog.getCurrentHealthLabelpb());
}

public LaserAttack getLaserWeapon(int i) {
Expand Down Expand Up @@ -178,28 +184,32 @@ public List<TangibleEntity> getAllEntities() {
entities.addAll(getEnemies());
return entities;
}
public StackPane getMainMenu(){

public StackPane getMainMenu() {
return menu.getMenupane();
}

public SoundManager getSoundManager() {
return soundManager;
}
public MenuItem getMenu(){

public MenuItem getMenu() {
return menu;
}
public StackPane getHsdPane(){

public StackPane getHsdPane() {
return this.menu.hsd.getScoresPane();
}

public void addEnemy(Enemy enemy, double width, double height) {
//Setup enemy hitbox information
enemy.getHitbox().setWidth(width);
enemy.getHitbox().setHeight(height);
if(enemy instanceof DeliveryMan)
if (enemy instanceof DeliveryMan) {
enemy.setCurrentHealth(100);
else
} else {
enemy.setCurrentHealth(10);
}
enemy.setLevel(this);

//Add enemy information to level
Expand All @@ -210,7 +220,7 @@ public void addEnemy(Enemy enemy, double width, double height) {
} else if (enemy.isMultiHibox()) {
enemy.getHitboxes().stream().forEach((hitbox) -> {
this.levelItems.getChildren().add(hitbox);
});
});
}
}

Expand All @@ -224,7 +234,6 @@ public void removeEnemy(Enemy enemy) {

//Make sure the root has the enemy in its children
//before ting to remove

if (!enemy.isMultiHibox()) {
this.levelItems.getChildren().remove(enemy.getHitbox());
} else if (enemy.isMultiHibox()) {
Expand Down Expand Up @@ -503,25 +512,23 @@ public void levelUpdate() {
if (rocketDog.getPosition().getX() > 500 && rocketDog.getLuckAttribute() > 1 && Math.random() > 0.9991) {
this.addAidItem(new HealthItem(new Point2D(100, 1)), 56, 56);
}

//Set rocketDog hitbox visibility
rocketDog.getHitbox().setVisible(visibleHitBoxes);
rocketDog.getHealthText().setVisible(visibleHitBoxes);
rocketDog.addObserver(this);


Map<Entity, Boolean> changed = new HashMap<>();
changed.put(rocketDog, true);

//enemies.stream().forEach((enemy) -> {
//Update enemy
// enemy.update();
//Update enemy
// enemy.update();
//});

//Update the weapon attack
weapon.stream().forEach((laser) -> {
//checkFiredLaser();
if(laser.getPosition().getX() > super.getWidth() || laser.getPosition().getX() < 0){
if (laser.getPosition().getX() > super.getWidth() || laser.getPosition().getX() < 0) {
laser.setPos(0, -45);
laser.setDead(false);
laser.setVisableOff();
Expand All @@ -530,7 +537,6 @@ public void levelUpdate() {
laser.update();
laser.getHitbox().setVisible(visibleHitBoxes);


for (int i = 0; i < enemies.size(); i++) {
if (laser.hasCollided(enemies.get(i))) {
laser.setPos(0, -45);
Expand All @@ -553,7 +559,7 @@ public void levelUpdate() {
//weapon.getHitbox().setVisible(visibleHitBoxes);
//Update the large weapon attack
largeWeapon.stream().forEach((largeLaser) -> {
if(largeLaser.getPosition().getX() > super.getWidth() || largeLaser.getPosition().getX() < 0){
if (largeLaser.getPosition().getX() > super.getWidth() || largeLaser.getPosition().getX() < 0) {
largeLaser.setPos(0, -150);
largeLaser.setDead(false);
largeLaser.setVisableOff();
Expand Down Expand Up @@ -667,6 +673,7 @@ public void levelUpdate() {
aidItem.processCollision(rocketDog);

if (aidItem.isDead()) { //aid item has been collected
soundManager.playAudioClip("got_item");
rocketDog.setScore(rocketDog.getScore() + 5);
rocketDog.setPowerAttribute(25);
rocketDog.setDefenseAttribute(50);
Expand Down Expand Up @@ -758,6 +765,8 @@ public void update(double currentHealth) {
+ "\nAgility: " + rocketDog.getAgilityAttribute()
+ "\nLuck: " + rocketDog.getLuckAttribute()
+ "\nCharisma: " + rocketDog.getChrismaAttribute());
this.rocketDog.getHealthbar().setHealth(rocketDog.getCurrentHealth());
this.rocketDog.getCurrentHealthLabelpb().setText(Double.toString(rocketDog.getCurrentHealth()));
}

@Override
Expand Down
Loading