Seagulls have their own voices when konami cheat code is done and fannypride replaces the tomato.
This commit is contained in:
@@ -32,6 +32,7 @@ import javafx.scene.shape.Shape3D;
|
|||||||
import javafx.scene.shape.Sphere;
|
import javafx.scene.shape.Sphere;
|
||||||
import javafx.scene.transform.Translate;
|
import javafx.scene.transform.Translate;
|
||||||
import javafx.util.Callback;
|
import javafx.util.Callback;
|
||||||
|
import network.Messages.Enums.BoatActionEnum;
|
||||||
import network.Messages.Enums.BoatStatusEnum;
|
import network.Messages.Enums.BoatStatusEnum;
|
||||||
import network.Messages.Enums.RaceStatusEnum;
|
import network.Messages.Enums.RaceStatusEnum;
|
||||||
import shared.dataInput.RaceDataSource;
|
import shared.dataInput.RaceDataSource;
|
||||||
@@ -79,7 +80,9 @@ public class RaceViewController extends Controller {
|
|||||||
private boolean mapToggle = true;
|
private boolean mapToggle = true;
|
||||||
private GPSConverter gpsConverter;
|
private GPSConverter gpsConverter;
|
||||||
private ArrayList<HealthEffect> healthEffectList = new ArrayList<>();
|
private ArrayList<HealthEffect> healthEffectList = new ArrayList<>();
|
||||||
|
private Subject3D clientBoat;
|
||||||
|
private List<BoatActionEnum> konamiCodes = new ArrayList<>();
|
||||||
|
private int konamiIndex = 0;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Arrow pointing to next mark in third person
|
* Arrow pointing to next mark in third person
|
||||||
@@ -147,7 +150,16 @@ public class RaceViewController extends Controller {
|
|||||||
initKeypressHandler();
|
initKeypressHandler();
|
||||||
healthLoop();
|
healthLoop();
|
||||||
initialiseRaceVisuals();
|
initialiseRaceVisuals();
|
||||||
|
konamiCodes.add(BoatActionEnum.SAILS_IN);
|
||||||
|
konamiCodes.add(BoatActionEnum.SAILS_OUT);
|
||||||
|
konamiCodes.add(BoatActionEnum.SAILS_IN);
|
||||||
|
konamiCodes.add(BoatActionEnum.SAILS_OUT);
|
||||||
|
konamiCodes.add(BoatActionEnum.UPWIND);
|
||||||
|
konamiCodes.add(BoatActionEnum.DOWNWIND);
|
||||||
|
konamiCodes.add(BoatActionEnum.UPWIND);
|
||||||
|
konamiCodes.add(BoatActionEnum.DOWNWIND);
|
||||||
|
konamiCodes.add(BoatActionEnum.TACK_GYBE);
|
||||||
|
konamiCodes.add(BoatActionEnum.VMG);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -201,7 +213,7 @@ public class RaceViewController extends Controller {
|
|||||||
checkTutorialState();
|
checkTutorialState();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
checkKonami(controlKey.getProtocolCode());
|
||||||
controllerClient.sendKey(controlKey);
|
controllerClient.sendKey(controlKey);
|
||||||
event.consume();
|
event.consume();
|
||||||
} catch (InterruptedException e) {
|
} catch (InterruptedException e) {
|
||||||
@@ -331,11 +343,16 @@ public class RaceViewController extends Controller {
|
|||||||
new Sparkline(this.raceState, this.sparklineChart);
|
new Sparkline(this.raceState, this.sparklineChart);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
private void initialiseHealthPane(){
|
private void initialiseHealthPane(){
|
||||||
InputStream tomato = this.getClass().getClassLoader().getResourceAsStream("visualiser/images/tomato.png");
|
InputStream tomato = this.getClass().getClassLoader().getResourceAsStream("visualiser/images/tomato.png");
|
||||||
HealthSlider healthSlider = new HealthSlider(new Image(tomato));
|
initialiseHealthPane(tomato);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void initialiseHealthPane(InputStream picture) {
|
||||||
|
while(playerHealthContainer.getChildren().size() > 0) {
|
||||||
|
playerHealthContainer.getChildren().remove(0);
|
||||||
|
}
|
||||||
|
HealthSlider healthSlider = new HealthSlider(new Image(picture));
|
||||||
playerHealthContainer.add(healthSlider, 0, 0);
|
playerHealthContainer.add(healthSlider, 0, 0);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
@@ -462,6 +479,7 @@ public class RaceViewController extends Controller {
|
|||||||
|
|
||||||
// Configure visualiser for client's boat
|
// Configure visualiser for client's boat
|
||||||
if (boat.isClientBoat()) {
|
if (boat.isClientBoat()) {
|
||||||
|
clientBoat = boatModel;
|
||||||
// Add player boat highlight
|
// Add player boat highlight
|
||||||
// Shockwave boatHighlight = new Shockwave(10);
|
// Shockwave boatHighlight = new Shockwave(10);
|
||||||
// boatHighlight.getMesh().setMaterial(new PhongMaterial(new Color(1, 1, 0, 0.1)));
|
// boatHighlight.getMesh().setMaterial(new PhongMaterial(new Color(1, 1, 0, 0.1)));
|
||||||
@@ -1218,6 +1236,27 @@ public class RaceViewController extends Controller {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void checkKonami(BoatActionEnum protocolCode){
|
||||||
|
if (protocolCode == konamiCodes.get(konamiIndex)){
|
||||||
|
if (konamiIndex < konamiCodes.size() - 1) {
|
||||||
|
konamiIndex++;
|
||||||
|
System.out.println("Next Konami Code is: " + konamiCodes.get(konamiIndex));
|
||||||
|
} else {
|
||||||
|
turnOnTheKonami();
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
konamiIndex = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void turnOnTheKonami(){
|
||||||
|
for(Subject3D seagull: seagulls){
|
||||||
|
((SeagullMesh) seagull.getMesh()).konamiTriggered();
|
||||||
|
}
|
||||||
|
InputStream newHp = this.getClass().getClassLoader().getResourceAsStream("visualiser/images/fannypride.png");
|
||||||
|
initialiseHealthPane(newHp);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Initialises the map
|
* Initialises the map
|
||||||
*/
|
*/
|
||||||
@@ -1276,6 +1315,14 @@ public class RaceViewController extends Controller {
|
|||||||
@Override
|
@Override
|
||||||
public void handle(long now) {
|
public void handle(long now) {
|
||||||
for (Subject3D seagull: seagulls) {
|
for (Subject3D seagull: seagulls) {
|
||||||
|
// view3D.getPivot().getX(), view3D.getPivot().getZ();
|
||||||
|
|
||||||
|
// if (Math.abs(seagull.getX() - view3D.getPivot().getX()) < 75 &&
|
||||||
|
// Math.abs(seagull.getZ() - view3D.getPivot().getZ()) < 75) {
|
||||||
|
if (Math.abs(seagull.getX() - clientBoat.getX()) < 75 &&
|
||||||
|
Math.abs(seagull.getZ() - clientBoat.getZ()) < 75) {
|
||||||
|
((SeagullMesh) seagull.getMesh()).playCry();
|
||||||
|
}
|
||||||
if (seagullsGoToX.get(seagull).size() > 0) {
|
if (seagullsGoToX.get(seagull).size() > 0) {
|
||||||
//System.out.println(xPosition + " " + yPosition);
|
//System.out.println(xPosition + " " + yPosition);
|
||||||
seagull.setHeading(GPSConverter.getAngle(new GraphCoordinate(seagull.getX(), seagull.getZ()),
|
seagull.setHeading(GPSConverter.getAngle(new GraphCoordinate(seagull.getX(), seagull.getZ()),
|
||||||
|
|||||||
@@ -26,6 +26,7 @@ import javafx.stage.StageStyle;
|
|||||||
import javafx.util.Duration;
|
import javafx.util.Duration;
|
||||||
import mock.app.Event;
|
import mock.app.Event;
|
||||||
import visualiser.layout.Assets3D;
|
import visualiser.layout.Assets3D;
|
||||||
|
import visualiser.model.SoundAssets;
|
||||||
|
|
||||||
public class App extends Application {
|
public class App extends Application {
|
||||||
private static Stage stage;
|
private static Stage stage;
|
||||||
@@ -98,6 +99,8 @@ public class App extends Application {
|
|||||||
updateMessage("Adding the " + nextFilling + " . . .");
|
updateMessage("Adding the " + nextFilling + " . . .");
|
||||||
if (i == 0){
|
if (i == 0){
|
||||||
Assets3D.loadAssets();
|
Assets3D.loadAssets();
|
||||||
|
} else if (i == 1){
|
||||||
|
SoundAssets.loadAssets();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Thread.sleep(100);
|
Thread.sleep(100);
|
||||||
|
|||||||
@@ -4,6 +4,8 @@ import javafx.animation.AnimationTimer;
|
|||||||
import javafx.scene.paint.Color;
|
import javafx.scene.paint.Color;
|
||||||
import javafx.scene.paint.PhongMaterial;
|
import javafx.scene.paint.PhongMaterial;
|
||||||
import javafx.scene.shape.MeshView;
|
import javafx.scene.shape.MeshView;
|
||||||
|
import visualiser.model.SeagullSound;
|
||||||
|
import visualiser.model.SoundAssets;
|
||||||
|
|
||||||
import java.util.Random;
|
import java.util.Random;
|
||||||
|
|
||||||
@@ -16,6 +18,10 @@ public class SeagullMesh extends MeshView{
|
|||||||
private int flapPeriod;
|
private int flapPeriod;
|
||||||
private int flapStrength;
|
private int flapStrength;
|
||||||
private int periodElapsed = 0;
|
private int periodElapsed = 0;
|
||||||
|
private SeagullSound sound;
|
||||||
|
private SeagullSound konamiSound;
|
||||||
|
private int cryCooldown = 600;
|
||||||
|
private int cryState = 0;
|
||||||
|
|
||||||
public SeagullMesh() {
|
public SeagullMesh() {
|
||||||
setMesh(Assets3D.seagull[0].getMesh());
|
setMesh(Assets3D.seagull[0].getMesh());
|
||||||
@@ -26,6 +32,9 @@ public class SeagullMesh extends MeshView{
|
|||||||
flapPeriod = 60 * (11 + flapPeriod);
|
flapPeriod = 60 * (11 + flapPeriod);
|
||||||
flapStrength = rand.nextInt(3) + 2;
|
flapStrength = rand.nextInt(3) + 2;
|
||||||
scheduledFlap.start();
|
scheduledFlap.start();
|
||||||
|
cryCooldown = rand.nextInt(10) * 60 + 600;//chirpyness factor
|
||||||
|
sound = SoundAssets.defaultSound;
|
||||||
|
konamiSound = SoundAssets.seagullSounds.get(rand.nextInt(SoundAssets.seagullSounds.size()));
|
||||||
}
|
}
|
||||||
|
|
||||||
private AnimationTimer flap = new AnimationTimer() {
|
private AnimationTimer flap = new AnimationTimer() {
|
||||||
@@ -51,10 +60,24 @@ public class SeagullMesh extends MeshView{
|
|||||||
startFlapping();
|
startFlapping();
|
||||||
}
|
}
|
||||||
periodElapsed = (periodElapsed + 1) % flapPeriod;
|
periodElapsed = (periodElapsed + 1) % flapPeriod;
|
||||||
|
if (cryState > 0) {
|
||||||
|
cryState -= 1;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
public void startFlapping(){
|
public void startFlapping(){
|
||||||
flap.start();
|
flap.start();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void konamiTriggered(){
|
||||||
|
sound = konamiSound;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void playCry(){
|
||||||
|
if (cryState == 0) {
|
||||||
|
sound.play();
|
||||||
|
cryState = cryCooldown;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,25 @@
|
|||||||
|
package visualiser.model;
|
||||||
|
|
||||||
|
|
||||||
|
import javafx.scene.media.AudioClip;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Created by Gondr on 9/10/2017.
|
||||||
|
*/
|
||||||
|
public class SeagullSound {
|
||||||
|
|
||||||
|
private AudioClip sound;
|
||||||
|
|
||||||
|
public SeagullSound(String file){
|
||||||
|
this.sound = new AudioClip(file);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setVolume(double volume){
|
||||||
|
sound.setVolume(volume);
|
||||||
|
sound.volumeProperty().setValue(volume);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void play(){
|
||||||
|
this.sound.play();
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,38 @@
|
|||||||
|
package visualiser.model;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Created by Gondr on 9/10/2017.
|
||||||
|
*/
|
||||||
|
public class SoundAssets {
|
||||||
|
public static SeagullSound defaultSound;
|
||||||
|
public static List<SeagullSound> seagullSounds = new ArrayList<>();
|
||||||
|
|
||||||
|
public static void loadAssets(){
|
||||||
|
loadSeagullSounds();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void loadSeagullSounds(){
|
||||||
|
defaultSound = new SeagullSound(SoundAssets.class.getClassLoader().getResource("assets/Seagull Sounds/default.wav").toExternalForm());
|
||||||
|
defaultSound.setVolume(0.02);
|
||||||
|
seagullSounds.add(new SeagullSound(SoundAssets.class.getClassLoader().getResource("assets/Seagull Sounds/seagle.mp3").toExternalForm()));
|
||||||
|
seagullSounds.get(0).setVolume(0.05);
|
||||||
|
seagullSounds.add(new SeagullSound(SoundAssets.class.getClassLoader().getResource("assets/Seagull Sounds/Seagull 1.wav").toExternalForm()));
|
||||||
|
seagullSounds.get(1).setVolume(0.03);
|
||||||
|
seagullSounds.add(new SeagullSound(SoundAssets.class.getClassLoader().getResource("assets/Seagull Sounds/Seagull 2.wav").toExternalForm()));
|
||||||
|
seagullSounds.get(2).setVolume(0.03);
|
||||||
|
seagullSounds.add(new SeagullSound(SoundAssets.class.getClassLoader().getResource("assets/Seagull Sounds/Seagull 3.wav").toExternalForm()));
|
||||||
|
seagullSounds.get(3).setVolume(0.03);
|
||||||
|
seagullSounds.add(new SeagullSound(SoundAssets.class.getClassLoader().getResource("assets/Seagull Sounds/Seagull 4.wav").toExternalForm()));
|
||||||
|
seagullSounds.get(4).setVolume(0.03);
|
||||||
|
seagullSounds.add(new SeagullSound(SoundAssets.class.getClassLoader().getResource("assets/Seagull Sounds/seagulls.wav").toExternalForm()));
|
||||||
|
seagullSounds.get(5).setVolume(0.06);
|
||||||
|
seagullSounds.add(new SeagullSound(SoundAssets.class.getClassLoader().getResource("assets/Seagull Sounds/Voice 001.wav").toExternalForm()));
|
||||||
|
seagullSounds.get(6).setVolume(0.015);
|
||||||
|
seagullSounds.add(new SeagullSound(SoundAssets.class.getClassLoader().getResource("assets/Seagull Sounds/Why.mp3").toExternalForm()));
|
||||||
|
seagullSounds.get(7).setVolume(0.06);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
|
After Width: | Height: | Size: 102 KiB |
Reference in New Issue
Block a user