public void check() { if (MyTime.getInstance().passed - start >= ttl) { Dispose(); MyTime.getInstance().remove(this); } }
public static MyTime getInstance() { if (instance == null) { instance = new MyTime(); } return(instance); }
public static void demo() { Console.ReadKey(); Hero h = new Hero(); h.collect(new DexterityGem()); h.collect(new IntelligenceGem()); Console.WriteLine(h); Console.ReadKey(); h.collect(new StrengthGem()); h.collect(new LeapSlam()); Console.WriteLine(h); Console.ReadKey(); MyTime.getInstance().tick(); Console.WriteLine(h); Console.ReadKey(); MyTime.getInstance().tick(); Console.WriteLine(h); Console.ReadKey(); h.collect(new IntelligenceGem()); h.collect(new StrengthGem()); Console.WriteLine(h); Console.ReadKey(); MyTime.getInstance().tick(); MyTime.getInstance().tick(); Console.WriteLine(h); Console.ReadKey(); }
public Gem() { start = MyTime.getInstance().passed; ttl = 3; MyTime.getInstance().add(this); }
private MyTime() { instance = this; passed = 0; ihasTTLs = new IhasTTL[10]; }
public void collect(Gem gem) { gem.apply(this); MyTime.getInstance().tick(); }