Back to project page Tanks.
The source code is released under:
MIT License
If you think the Android project Tanks listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.
package com.ThirtyNineEighty.Game.Gameplay; /*from w w w . ja v a2 s . com*/ import com.ThirtyNineEighty.Game.Gameplay.Characteristics.Characteristic; import com.ThirtyNineEighty.Game.Gameplay.Characteristics.CharacteristicFactory; import com.ThirtyNineEighty.Game.IEngineObject; import com.ThirtyNineEighty.Game.Worlds.GameWorld; import com.ThirtyNineEighty.Game.Worlds.IWorld; import com.ThirtyNineEighty.System.GameContext; import com.ThirtyNineEighty.System.IContent; import com.ThirtyNineEighty.System.ISubprogram; public class Bullet extends GameObject { private ISubprogram subprogram; public static Bullet Create(String type) { Characteristic c = CharacteristicFactory.get(type); return new Bullet(c); } protected Bullet(Characteristic characteristic) { super(characteristic); final Bullet bullet = this; final GameWorld world = (GameWorld)GameContext.getContent().getWorld(); IContent content = GameContext.getContent(); content.bindProgram(subprogram = new ISubprogram() { @Override public void update() { world.collisionManager.move(bullet); } }); } @Override public void onCollide(IEngineObject object) { super.onCollide(object); if (!(object instanceof GameObject)) return; GameObject gameObject = (GameObject)object; Characteristic c = gameObject.getCharacteristics(); c.addHealth(10); //TODO get form Characteristic IWorld world = GameContext.getContent().getWorld(); world.remove(this); } @Override public void onRemoved() { super.onRemoved(); IContent content = GameContext.getContent(); content.unbindProgram(subprogram); } }