Back to project page Station42.
The source code is released under:
Apache License Version 2.0, January 2004 http://www.apache.org/licenses/ TERMS AND CONDITIONS FOR USE, REPRODUC...
If you think the Android project Station42 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.station42.hacking; // ww w . ja v a 2 s . c o m import com.station42.base.Engine; import com.station42.base.EngineUpdateListener; import com.station42.base.Entity; import com.station42.basic.EntityLocation; public class HackingActionUpdater implements EngineUpdateListener{ private float interval = 0.25f; private float sinceLast = 1f; @Override public void update(Engine engine, float delta) { for (Entity entity : engine.getEntitiesWithComponent(HackingAction.class)) { EntityLocation hackerLocation = entity.getComponent(EntityLocation.class); HackingAction hackingAction = entity.getComponent(HackingAction.class); sinceLast += delta; if (sinceLast > interval) { if (hackingAction != null) { hackingAction.calculateEntitiesInRange(engine, hackerLocation); } } Entity target = hackingAction.getTarget(); if (target != null) { float distance = target.getComponent(EntityLocation.class).getDistance(hackerLocation); if (distance < target.getComponent(Hackable.class).range && hackingAction.getHackingWanted()) { hackingAction.update(delta); } else { hackingAction.setTarget(null); } } else { HackingActionParticles particles = entity.getComponent(HackingActionParticles.class); if (particles != null && particles.alive()) particles.die(); } } } }