Merge branch 'easter_eggs' into 'master'

Easter eggs

Acceptance Criteria:

- Seagulls make sounds when your boat is close to them (can be changed to where your pivot point is but unsure what to use).
- After putting in sails in sails out sails in sails out upwind downwind upwind downwind tack/gybe vmg the tomato should change as well as the seagull sounds.
- Matching finding should be working now.

Note: Islands have been removed as it looked bad in night mode.


See merge request !72
main
Hamish Ball 8 years ago
commit 4d6de8bc9f

@ -32,6 +32,7 @@ import javafx.scene.shape.Shape3D;
import javafx.scene.shape.Sphere;
import javafx.scene.transform.Translate;
import javafx.util.Callback;
import network.Messages.Enums.BoatActionEnum;
import network.Messages.Enums.BoatStatusEnum;
import network.Messages.Enums.RaceStatusEnum;
import shared.dataInput.RaceDataSource;
@ -79,7 +80,9 @@ public class RaceViewController extends Controller {
private boolean mapToggle = true;
private GPSConverter gpsConverter;
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
@ -147,7 +150,16 @@ public class RaceViewController extends Controller {
initKeypressHandler();
healthLoop();
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();
}
}
checkKonami(controlKey.getProtocolCode());
controllerClient.sendKey(controlKey);
event.consume();
} catch (InterruptedException e) {
@ -331,11 +343,16 @@ public class RaceViewController extends Controller {
new Sparkline(this.raceState, this.sparklineChart);
}
private void initialiseHealthPane() {
private void initialiseHealthPane(){
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);
try {
@ -462,6 +479,7 @@ public class RaceViewController extends Controller {
// Configure visualiser for client's boat
if (boat.isClientBoat()) {
clientBoat = boatModel;
// Add player boat highlight
// Shockwave boatHighlight = new Shockwave(10);
// 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
*/
@ -1276,6 +1315,14 @@ public class RaceViewController extends Controller {
@Override
public void handle(long now) {
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) {
//System.out.println(xPosition + " " + yPosition);
seagull.setHeading(GPSConverter.getAngle(new GraphCoordinate(seagull.getX(), seagull.getZ()),

@ -26,6 +26,7 @@ import javafx.stage.StageStyle;
import javafx.util.Duration;
import mock.app.Event;
import visualiser.layout.Assets3D;
import visualiser.model.SoundAssets;
public class App extends Application {
private static Stage stage;
@ -98,6 +99,8 @@ public class App extends Application {
updateMessage("Adding the " + nextFilling + " . . .");
if (i == 0){
Assets3D.loadAssets();
} else if (i == 1){
SoundAssets.loadAssets();
}
}
Thread.sleep(100);

@ -147,7 +147,9 @@ public class Assets3D {
public static Shape3D getSharks(){
String path = "assets/V1.0 Sharks.x3d";
return loadX3d(path);
Shape3D shark = loadX3d(path);
shark.setMouseTransparent(true);
return shark;
}
public static Shape3D loadX3d(String path){

@ -4,6 +4,8 @@ import javafx.animation.AnimationTimer;
import javafx.scene.paint.Color;
import javafx.scene.paint.PhongMaterial;
import javafx.scene.shape.MeshView;
import visualiser.model.SeagullSound;
import visualiser.model.SoundAssets;
import java.util.Random;
@ -16,6 +18,10 @@ public class SeagullMesh extends MeshView{
private int flapPeriod;
private int flapStrength;
private int periodElapsed = 0;
private SeagullSound sound;
private SeagullSound konamiSound;
private int cryCooldown = 600;
private int cryState = 0;
public SeagullMesh() {
setMesh(Assets3D.seagull[0].getMesh());
@ -26,6 +32,9 @@ public class SeagullMesh extends MeshView{
flapPeriod = 60 * (11 + flapPeriod);
flapStrength = rand.nextInt(3) + 2;
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() {
@ -51,10 +60,24 @@ public class SeagullMesh extends MeshView{
startFlapping();
}
periodElapsed = (periodElapsed + 1) % flapPeriod;
if (cryState > 0) {
cryState -= 1;
}
}
};
public void startFlapping(){
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);
}
}

@ -33,9 +33,9 @@ public class HttpMatchBrowserClient extends Thread {
Thread.sleep(5000);
} catch (IOException e) {
e.printStackTrace();
//e.printStackTrace();
} catch (InterruptedException e) {
e.printStackTrace();
//e.printStackTrace();
}
}
}

@ -42,7 +42,8 @@ public class HttpMatchBrowserHost extends Thread {
Enumeration<NetworkInterface> e = NetworkInterface.getNetworkInterfaces();
boolean matches = false;
String ip = "";
Pattern ipPattern = Pattern.compile("192.168.1.*");
Pattern localIpPattern = Pattern.compile("192\\.168\\.1\\..*");
Pattern ipPattern = Pattern.compile("192\\.168\\..{0,3}\\..*");
while(e.hasMoreElements())
{
if (matches){
@ -54,10 +55,12 @@ public class HttpMatchBrowserHost extends Thread {
{
InetAddress i = ee.nextElement();
matches = ipPattern.matcher(i.getHostAddress()).matches();
System.out.println(i.getHostAddress());
if (matches){
ip = i.getHostAddress();
//System.out.println(ip);
break;
if (!localIpPattern.matcher(i.getHostAddress()).matches()) {
ip = i.getHostAddress();
//break;
}
}
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 92 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 102 KiB

Loading…
Cancel
Save