|
@ -0,0 +1,73 @@ |
|
|
|
|
|
package playground; |
|
|
|
|
|
|
|
|
|
|
|
// import utilities.* ; |
|
|
|
|
|
import java.awt.Color; |
|
|
|
|
|
import java.awt.Font; |
|
|
|
|
|
import java.awt.Graphics2D; |
|
|
|
|
|
import java.awt.Polygon; |
|
|
|
|
|
import java.awt.RenderingHints; |
|
|
|
|
|
import java.awt.font.TextAttribute; |
|
|
|
|
|
import java.awt.image.BufferedImage; |
|
|
|
|
|
import java.io.*; |
|
|
|
|
|
import java.text.AttributedString; |
|
|
|
|
|
import java.util.LinkedList; |
|
|
|
|
|
import controller.EnemyController; |
|
|
|
|
|
import controller.FallingStarController; |
|
|
|
|
|
import controller.LimitedTimeController; |
|
|
|
|
|
import controller.ObjectController; |
|
|
|
|
|
import controller.EgoController; |
|
|
|
|
|
import controller.CollisionAwareEgoController; |
|
|
|
|
|
import gameobjects.AnimatedGameobject; |
|
|
|
|
|
import gameobjects.FallingStar; |
|
|
|
|
|
import gameobjects.GameObject; |
|
|
|
|
|
import gameobjects.EgoObject; |
|
|
|
|
|
import gameobjects.TextObject; |
|
|
|
|
|
import org.apache.logging.log4j.Logger; |
|
|
|
|
|
import org.apache.logging.log4j.LogManager; |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
* Class that realizes all the game logic of a very simple game level. The level contains for now |
|
|
|
|
|
* only two objects that are {@link GameObject} subclasses: {@link FallingStar} and |
|
|
|
|
|
* {@link EgoObject}. Functions performed by this class are: |
|
|
|
|
|
* <ul> |
|
|
|
|
|
* <li>initially set up the level, spawn all object etc., in method {@link #prepareLevel} |
|
|
|
|
|
* <li>React to game events in {@link #actionIfEgoCollidesWithCollect(GameObject, GameObject)} , |
|
|
|
|
|
* {@link #actionIfEgoCollidesWithEnemy(GameObject, GameObject)}, etc. |
|
|
|
|
|
* <li>define basic object movement rules for all objects in the level in the various |
|
|
|
|
|
* ObjectController subclasses: {@link EgoController} and {@link FallingStarController}. |
|
|
|
|
|
* </ul> |
|
|
|
|
|
*/ |
|
|
|
|
|
public class SpaceInvadersLevelAua extends SpaceInvadersLevel { |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
* implements game behavior if an enemy object is hit by a players' shot. It creates an explosion |
|
|
|
|
|
* effect, plays a sound and adds 200 points to the current score (and it removes the enemy object |
|
|
|
|
|
* and the shot object). |
|
|
|
|
|
* |
|
|
|
|
|
* @param e enemy which was hit |
|
|
|
|
|
* @param shot the shot object that hit the enemy |
|
|
|
|
|
*/ |
|
|
|
|
|
void actionIfEnemyIsHit(GameObject e, GameObject shot) { |
|
|
|
|
|
|
|
|
|
|
|
double gameTime = this.getGameTime(); |
|
|
|
|
|
createExplosion(gameTime, e, "shard", DYING_INTERVAL, Color.RED); |
|
|
|
|
|
|
|
|
|
|
|
Music.music(smash); |
|
|
|
|
|
|
|
|
|
|
|
// delete enemy |
|
|
|
|
|
deleteObject(e.getId()); |
|
|
|
|
|
|
|
|
|
|
|
// delete shot |
|
|
|
|
|
deleteObject(shot.getId()); |
|
|
|
|
|
|
|
|
|
|
|
// add to points counter |
|
|
|
|
|
Integer pts = (Integer) getGlobalFlag("points"); |
|
|
|
|
|
setGlobalFlag("points", pts + 200); |
|
|
|
|
|
|
|
|
|
|
|
//print aua on console |
|
|
|
|
|
System.out.println("AUA!!"); |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
} |