mirror of
https://github.com/michaelrausch/Party-Parrots-At-Sea.git
synced 2026-05-09 14:28:43 +00:00
Packets are sent out when collision happens and receiver is able to interpret and display as visual alert. Updated visual alert to looks better.
- Created yacht event code message to be sent out as packet. - Added observers to main server thread on yacht so when collision detected, main server thread will send out yacht event message to all server to client threads. - Updated collision visual alert using circle and animation timer. #story[1117]
This commit is contained in:
@@ -16,6 +16,7 @@ import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import java.util.Observable;
|
||||
|
||||
import static seng302.utilities.GeoUtility.getGeoCoordinate;
|
||||
|
||||
@@ -25,7 +26,7 @@ import static seng302.utilities.GeoUtility.getGeoCoordinate;
|
||||
* Class created to store more variables (eg. boat statuses) compared to the XMLParser boat class,
|
||||
* also done outside Boat class because some old variables are not used anymore.
|
||||
*/
|
||||
public class Yacht {
|
||||
public class Yacht extends Observable {
|
||||
|
||||
@FunctionalInterface
|
||||
public interface YachtLocationListener {
|
||||
@@ -148,8 +149,15 @@ public class Yacht {
|
||||
if (shouldDoCollisionUpdate()){
|
||||
Yacht collidedYacht = checkCollision(calculatedPoint);
|
||||
|
||||
if (collidedYacht != null || markCollidedWith() != null) {
|
||||
if (collidedYacht != null) {
|
||||
location = calculateBounceBack(new GeoPoint(collidedYacht.getLocation().getLat(),
|
||||
collidedYacht.getLocation().getLng()));
|
||||
setChanged();
|
||||
notifyObservers(this.sourceId);
|
||||
} else if (markCollidedWith() != null) {
|
||||
location = calculateBounceBack(new GeoPoint(markCollidedWith().getLat(), markCollidedWith().getLng()));
|
||||
setChanged();
|
||||
notifyObservers(this.sourceId);
|
||||
} else {
|
||||
location = calculatedPoint;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user