|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectgroup1.model.gameobject.InvincibilityHandler
public class InvincibilityHandler
A singleton class that handles temporary invicincibility. Holds a set of invincible living game objects, which can be referenced whenever something might take damage. Invincibility is handled via a simple counter in the LivingObj class, based on the number of time clicks that pass. The Environment must tell this class when time clicks occur, and this info is passed to the appropriate living objects. This is actually a very important detail!!! Otherwise, objects would hit each other thousands of times in the span of mere seconds. On a side note, the reason that I'm making a spearate class for this: -- I can't put in GameObj because not all GameObjs can take damage, or even have appropriate code. -- I could put in the subclasses, but I would have to put it in the move() function of every subclass. Not good. -- I can't put it LivingObj because there's no clean way to decrement the counter every time click without class-casting left and right. But, here, I can manage a list of LivingObjs, so that no messing class-casting is required.
| Method Summary | |
|---|---|
static InvincibilityHandler |
getInstance()
Get an instance of this class. |
static boolean |
setInvincible(LivingObj obj)
Add a object to our list to make it invincible. |
static void |
timeClick()
Run a time click of invincibility counters. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Method Detail |
|---|
public static InvincibilityHandler getInstance()
public static boolean setInvincible(LivingObj obj)
obj - The oject to be added to the "invincible" list.
public static void timeClick()
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||